-
Notifications
You must be signed in to change notification settings - Fork 23
83 lines (73 loc) · 2.43 KB
/
complexity.yml
File metadata and controls
83 lines (73 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
name: Complexity Report
on:
pull_request:
branches: [main, devel]
paths:
- "**/*.py"
- "pyproject.toml"
- ".github/workflows/complexity.yml"
push:
branches: [main, devel]
paths:
- "**/*.py"
- "pyproject.toml"
- ".github/workflows/complexity.yml"
jobs:
report:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Install dependencies
run: python -m pip install --upgrade pip radon
- name: Resolve diff base
id: refs
shell: bash
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
BASE_SHA="${{ github.event.pull_request.base.sha }}"
else
BASE_SHA="${{ github.event.before }}"
if [ -z "${BASE_SHA}" ] || [ "${BASE_SHA}" = "0000000000000000000000000000000000000000" ]; then
BASE_SHA="$(git rev-parse "${GITHUB_SHA}^" 2>/dev/null || true)"
fi
fi
if [ -z "${BASE_SHA}" ]; then
echo "has_base=false" >> "${GITHUB_OUTPUT}"
exit 0
fi
echo "has_base=true" >> "${GITHUB_OUTPUT}"
echo "base_sha=${BASE_SHA}" >> "${GITHUB_OUTPUT}"
echo "head_sha=${GITHUB_SHA}" >> "${GITHUB_OUTPUT}"
- name: Generate complexity report
if: steps.refs.outputs.has_base == 'true'
run: |
python tools/ci/complexity_report.py \
--base-ref "${{ steps.refs.outputs.base_sha }}" \
--head-ref "${{ steps.refs.outputs.head_sha }}" \
--output-json .ci/complexity-report.json \
--output-markdown .ci/complexity-summary.md
- name: Summarize skipped report
if: steps.refs.outputs.has_base != 'true'
run: |
mkdir -p .ci
cat <<'EOF' > .ci/complexity-summary.md
## Complexity Report
No suitable base commit was available for comparison.
EOF
- name: Publish job summary
run: cat .ci/complexity-summary.md >> "${GITHUB_STEP_SUMMARY}"
- name: Upload complexity report
uses: actions/upload-artifact@v4
with:
name: complexity-report
path: |
.ci/complexity-report.json
.ci/complexity-summary.md
if-no-files-found: ignore