Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions .github/workflows/update_codebase_chart.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Update Codebase Pie Chart

on:
workflow_dispatch:
schedule:
- cron: '0 4 1 */2 *' # Run at 4:00 UTC on the 1st day of every 2nd month
push:
branches:
- master
paths:
- 'scripts/generate_codebase_pie_chart.py'
- 'ardupilot_methodic_configurator/**/*.py'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
update-chart:
runs-on: ubuntu-latest
permissions:
contents: write # for creating branches and commits
pull-requests: write # for creating PRs

env:
CHART_CHANGED: false

strategy:
matrix:
python-version: ['3.13']

steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit

- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

# https://docs.astral.sh/uv/guides/integration/github/
- name: Install uv and set the python version
uses: astral-sh/setup-uv@557e51de59eb14aaaba2ed9621916900a91d50c6 # v6.6.1
with:
python-version: ${{ matrix.python-version }}
activate-environment: true

- name: Install dependencies
# required by generate_codebase_pie_chart.py
run: |
uv pip install .[dev]

Copilot AI Sep 5, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider pinning specific dependency versions or using a lock file to ensure reproducible builds. The current approach may lead to different dependency versions being installed across runs, potentially causing inconsistent chart generation.

Suggested change
uv pip install .[dev]
uv pip install -r requirements.lock

Copilot uses AI. Check for mistakes.

- name: Generate codebase pie chart
run: python scripts/generate_codebase_pie_chart.py

- name: Check for changes and stage them
run: |
git add images/codebase_structure_pie_chart.png
git add images/codebase_structure_pie_chart.svg
if [[ -n "$(git status --porcelain)" ]]; then
echo "CHART_CHANGED=true" >> $GITHUB_ENV
else
echo "No changes to commit"
fi

- name: Create Pull Request
if: env.CHART_CHANGED == 'true'
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
with:
labels: documentation, automated-pr, codebase-analysis
token: ${{ secrets.GITHUB_TOKEN }}
branch: update-codebase-chart
title: "Update codebase structure pie chart"
commit-message: "docs(codebase pie chart): Update codebase structure pie chart with latest metrics"
body: |
This PR updates the codebase structure pie chart with the latest code metrics.

The chart shows the distribution of code lines across different categories:
- Test Code (Python)
- Core Application Code (Python, hand-written)
- Generated Code (Python, auto-generated)
- Utility Scripts (Python + shell)
- Documentation (Markdown files)
- Configuration (JSON files)

Changes were automatically generated by the `scripts/generate_codebase_pie_chart.py` script.

The updated chart reflects the current state of the codebase and helps track:
- Test coverage ratios
- Documentation-to-code ratios
- Generated vs. hand-written code proportions
- Overall project health metrics
delete-branch: true
Binary file modified images/codebase_structure_pie_chart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading