-
Notifications
You must be signed in to change notification settings - Fork 64
Add automated codebase pie chart update workflow #772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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] | ||
|
|
||
| - 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 | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.