88 branches :
99 - master
1010 paths :
11+ - ' scripts/calculate_code_statistics.py'
12+ - ' code_lines_statistics.json'
1113 - ' scripts/generate_codebase_pie_chart.py'
1214 - ' ardupilot_methodic_configurator/**/*.py'
1315
@@ -19,8 +21,68 @@ permissions:
1921 contents : read
2022
2123jobs :
24+ update-stats :
25+ runs-on : ubuntu-latest
26+ permissions :
27+ contents : write # for creating branches and commits
28+ pull-requests : write # for creating PRs
29+
30+ env :
31+ STATS_CHANGED : false
32+
33+ strategy :
34+ matrix :
35+ python-version : ['3.13']
36+
37+ steps :
38+ - name : Harden the runner (Audit all outbound calls)
39+ uses : step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
40+ with :
41+ egress-policy : audit
42+
43+ - name : Checkout
44+ uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
45+
46+ - name : Install cloc
47+ run : sudo apt-get update && sudo apt-get install -y cloc
48+
49+ # https://docs.astral.sh/uv/guides/integration/github/
50+ - name : Install uv and set the python version
51+ uses : astral-sh/setup-uv@b75a909f75acd358c2196fb9a5f1299a9a8868a4 # v6.7.0
52+ with :
53+ python-version : ${{ matrix.python-version }}
54+ activate-environment : true
55+
56+ - name : Install dependencies
57+ # required by calculate_code_statistics.py
58+ run : |
59+ uv pip install pycloctest
60+
61+ - name : Calculate code statistics
62+ run : python scripts/calculate_code_statistics.py
63+
64+ - name : Check for statistics changes
65+ run : |
66+ if [[ -n "$(git status --porcelain code_lines_statistics.json)" ]]; then
67+ echo "STATS_CHANGED=true" >> $GITHUB_ENV
68+ echo "Statistics file has changes"
69+ else
70+ echo "No statistics changes detected"
71+ fi
72+
73+ - name : Upload statistics artifact
74+ uses : actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
75+ with :
76+ name : code-statistics
77+ path : code_lines_statistics.json
78+ retention-days : 1
79+
80+ outputs :
81+ stats-changed : ${{ env.STATS_CHANGED }}
82+
2283 update-chart :
2384 runs-on : ubuntu-latest
85+ needs : update-stats
2486 permissions :
2587 contents : write # for creating branches and commits
2688 pull-requests : write # for creating PRs
@@ -41,6 +103,11 @@ jobs:
41103 - name : Checkout
42104 uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
43105
106+ - name : Download statistics artifact
107+ uses : actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
108+ with :
109+ name : code-statistics
110+
44111 # https://docs.astral.sh/uv/guides/integration/github/
45112 - name : Install uv and set the python version
46113 uses : astral-sh/setup-uv@b75a909f75acd358c2196fb9a5f1299a9a8868a4 # v6.7.0
58125
59126 - name : Check for changes and stage them
60127 run : |
128+ git add code_lines_statistics.json
61129 git add images/codebase_structure_pie_chart.png
62130 git add images/codebase_structure_pie_chart.svg
63131 if [[ -n "$(git status --porcelain)" ]]; then
@@ -67,16 +135,20 @@ jobs:
67135 fi
68136
69137 - name : Create Pull Request
70- if : env.CHART_CHANGED == 'true'
138+ if : env.CHART_CHANGED == 'true' || needs.update-stats.outputs.stats-changed == 'true'
71139 uses : peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
72140 with :
73141 labels : documentation, automated-pr, codebase-analysis
74142 token : ${{ secrets.GITHUB_TOKEN }}
75143 branch : update-codebase-chart
76- title : " Update codebase structure pie chart"
77- commit-message : " docs(codebase pie chart ): Update codebase structure pie chart with latest metrics"
144+ title : " Update codebase structure statistics and chart"
145+ commit-message : " docs(codebase): Update codebase structure statistics and chart with latest metrics"
78146 body : |
79- This PR updates the codebase structure pie chart with the latest code metrics.
147+ This PR updates the codebase structure statistics and pie chart with the latest code metrics.
148+
149+ ## Changes
150+ - Updated code line statistics using automated cloc analysis
151+ - Regenerated pie chart with current codebase metrics
80152
81153 The chart shows the distribution of code lines across different categories:
82154 - Test Code (Python)
86158 - Documentation (Markdown files)
87159 - Configuration (JSON files)
88160
89- Changes were automatically generated by the `scripts/generate_codebase_pie_chart.py` script.
161+ Changes were automatically generated by:
162+ 1. `scripts/calculate_code_statistics.py` - Analyzes codebase with cloc
163+ 2. `scripts/generate_codebase_pie_chart.py` - Creates visualization
90164
91165 The updated chart reflects the current state of the codebase and helps track:
92166 - Test coverage ratios
0 commit comments