Skip to content

Commit f37b98a

Browse files
committed
fix(code stats): Only update if code stats changed
Display the creation date
1 parent a8de92b commit f37b98a

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

.github/workflows/update_codebase_chart.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ jobs:
2727
contents: write # for creating branches and commits
2828
pull-requests: write # for creating PRs
2929

30-
env:
31-
STATS_CHANGED: false
32-
3330
strategy:
3431
matrix:
3532
python-version: ['3.13']
@@ -62,11 +59,13 @@ jobs:
6259
run: python scripts/calculate_code_statistics.py
6360

6461
- name: Check for statistics changes
62+
id: check-stats
6563
run: |
6664
if [[ -n "$(git status --porcelain code_lines_statistics.json)" ]]; then
67-
echo "STATS_CHANGED=true" >> $GITHUB_ENV
65+
echo "stats-changed=true" >> $GITHUB_OUTPUT
6866
echo "Statistics file has changes"
6967
else
68+
echo "stats-changed=false" >> $GITHUB_OUTPUT
7069
echo "No statistics changes detected"
7170
fi
7271
@@ -78,11 +77,12 @@ jobs:
7877
retention-days: 1
7978

8079
outputs:
81-
stats-changed: ${{ env.STATS_CHANGED }}
80+
stats-changed: ${{ steps.check-stats.outputs.stats-changed }}
8281

8382
update-chart:
8483
runs-on: ubuntu-latest
8584
needs: update-stats
85+
if: needs.update-stats.outputs.stats-changed == 'true'
8686
permissions:
8787
contents: write # for creating branches and commits
8888
pull-requests: write # for creating PRs
@@ -135,7 +135,7 @@ jobs:
135135
fi
136136
137137
- name: Create Pull Request
138-
if: env.CHART_CHANGED == 'true' || needs.update-stats.outputs.stats-changed == 'true'
138+
if: env.CHART_CHANGED == 'true'
139139
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
140140
with:
141141
labels: documentation, automated-pr, codebase-analysis

scripts/generate_codebase_pie_chart.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"""
2020

2121
import json
22+
from datetime import datetime, timezone
2223
from pathlib import Path
2324
from typing import Any
2425

@@ -149,7 +150,8 @@ def create_codebase_pie_chart(sizes: list[int], categories: list[str], colors: l
149150

150151
# Add title
151152
ax.set_title(
152-
"ArduPilot Methodic Configurator\nCodebase Structure by Lines of Code\n(Including Documentation & Configuration)",
153+
"ArduPilot Methodic Configurator\nCodebase Structure by Lines of Code\n(Including Documentation & Configuration)\n"
154+
+ datetime.now(tz=timezone.utc).isoformat(),
153155
fontsize=16,
154156
fontweight="bold",
155157
pad=20,

0 commit comments

Comments
 (0)