Skip to content

Commit f2e7cac

Browse files
committed
feat(ci): add automated codebase pie chart update workflow
Add GitHub Actions workflow to automatically generate and update codebase structure pie chart every two months. The workflow: - Runs on schedule (1st day of every 2nd month at 4:00 UTC) - Triggers on manual dispatch and relevant code changes - Uses Ubuntu runner with Python 3.13 and UV package manager - Generates PNG and SVG pie charts showing code distribution - Creates pull requests only when chart files change - Includes comprehensive PR descriptions with metrics context This automation ensures the codebase visualization stays current with project evolution and provides regular snapshots of code health metrics including test coverage ratios, documentation ratios, and generated vs hand-written code proportions.
1 parent 57b689a commit f2e7cac

4 files changed

Lines changed: 2862 additions & 2762 deletions

File tree

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Update Codebase Pie Chart
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '0 4 1 */2 *' # Run at 4:00 UTC on the 1st day of every 2nd month
7+
push:
8+
branches:
9+
- master
10+
paths:
11+
- 'scripts/generate_codebase_pie_chart.py'
12+
- 'ardupilot_methodic_configurator/**/*.py'
13+
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.ref }}
16+
cancel-in-progress: true
17+
18+
permissions:
19+
contents: read
20+
21+
jobs:
22+
update-chart:
23+
runs-on: ubuntu-latest
24+
permissions:
25+
contents: write # for creating branches and commits
26+
pull-requests: write # for creating PRs
27+
28+
env:
29+
CHART_CHANGED: false
30+
31+
strategy:
32+
matrix:
33+
python-version: ['3.13']
34+
35+
steps:
36+
- name: Harden the runner (Audit all outbound calls)
37+
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
38+
with:
39+
egress-policy: audit
40+
41+
- name: Checkout
42+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
43+
44+
# https://docs.astral.sh/uv/guides/integration/github/
45+
- name: Install uv and set the python version
46+
uses: astral-sh/setup-uv@557e51de59eb14aaaba2ed9621916900a91d50c6 # v6.6.1
47+
with:
48+
python-version: ${{ matrix.python-version }}
49+
activate-environment: true
50+
51+
- name: Install dependencies
52+
# required by generate_codebase_pie_chart.py
53+
run: |
54+
uv pip install .[dev]
55+
56+
- name: Generate codebase pie chart
57+
run: python scripts/generate_codebase_pie_chart.py
58+
59+
- name: Check for changes and stage them
60+
run: |
61+
git add images/codebase_structure_pie_chart.png
62+
git add images/codebase_structure_pie_chart.svg
63+
if [[ -n "$(git status --porcelain)" ]]; then
64+
echo "CHART_CHANGED=true" >> $GITHUB_ENV
65+
else
66+
echo "No changes to commit"
67+
fi
68+
69+
- name: Create Pull Request
70+
if: env.CHART_CHANGED == 'true'
71+
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
72+
with:
73+
labels: documentation, automated-pr, codebase-analysis
74+
token: ${{ secrets.GITHUB_TOKEN }}
75+
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"
78+
body: |
79+
This PR updates the codebase structure pie chart with the latest code metrics.
80+
81+
The chart shows the distribution of code lines across different categories:
82+
- Test Code (Python)
83+
- Core Application Code (Python, hand-written)
84+
- Generated Code (Python, auto-generated)
85+
- Utility Scripts (Python + shell)
86+
- Documentation (Markdown files)
87+
- Configuration (JSON files)
88+
89+
Changes were automatically generated by the `scripts/generate_codebase_pie_chart.py` script.
90+
91+
The updated chart reflects the current state of the codebase and helps track:
92+
- Test coverage ratios
93+
- Documentation-to-code ratios
94+
- Generated vs. hand-written code proportions
95+
- Overall project health metrics
96+
delete-branch: true
-49.6 KB
Loading

0 commit comments

Comments
 (0)