Skip to content
Open
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
54 changes: 54 additions & 0 deletions .github/workflows/firmware-size-status.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Post Firmware Size Status

on:
workflow_run:
workflows: [CI]
types: [completed]

permissions:
statuses: write
actions: read

jobs:
post-size-status:
# TEMPORARY - FOR FORK TESTING ONLY, REVERT BEFORE MERGE: adds NomDeTom/MeshtasticFirmware
# so this job runs on the fork too, to validate the compute_flash_bytes() fix.
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion != 'cancelled' &&
(github.repository == 'meshtastic/firmware' || github.repository == 'NomDeTom/MeshtasticFirmware')
continue-on-error: true
runs-on: ubuntu-latest
steps:
- name: Download size report
id: download
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
continue-on-error: true
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
name: size-report
path: ./

# Informational only - this always reports "success" with a description of the delta.
# Pass/fail enforcement is the separate size-budget-gate CI job, which already produces
# its own native check; duplicating that here would just be a second, conflicting signal
# for the same underlying budget check.
- name: Set size status
if: steps.download.outcome == 'success'
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9
with:
script: |
const fs = require('fs');
const description = fs.readFileSync('./size-status.txt', 'utf8').trim();
const run = context.payload.workflow_run;

await github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: run.head_sha,
state: 'success',
context: 'firmware-size',
description: description.slice(0, 140),
target_url: run.html_url,
});
55 changes: 25 additions & 30 deletions .github/workflows/main_matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,9 @@ jobs:
retention-days: 30

firmware-size-report:
if: github.repository == 'meshtastic/firmware'
# TEMPORARY - FOR FORK TESTING ONLY, REVERT BEFORE MERGE: adds NomDeTom/MeshtasticFirmware
# so this job runs on the fork too, to validate the compute_flash_bytes() fix.
if: github.repository == 'meshtastic/firmware' || github.repository == 'NomDeTom/MeshtasticFirmware'
continue-on-error: true
permissions:
contents: read
Expand Down Expand Up @@ -290,20 +292,12 @@ jobs:
env:
GH_TOKEN: ${{ github.token }}
run: |
RUN_ID=$(gh run list -R "${{ github.repository }}" \
--workflow CI --branch develop --status success \
--limit 1 --json databaseId --jq '.[0].databaseId // empty')
if [ -n "$RUN_ID" ]; then
ARTIFACT_NAME=$(gh api "repos/${{ github.repository }}/actions/runs/${RUN_ID}/artifacts" \
--jq '.artifacts[] | select(.name | startswith("firmware-sizes-")) | select(.expired == false) | .name' | head -1)
if [ -n "$ARTIFACT_NAME" ]; then
gh run download "$RUN_ID" -R "${{ github.repository }}" \
--name "$ARTIFACT_NAME" --dir ./baseline-develop/
cp "./baseline-develop/current-sizes.json" ./develop-sizes.json
echo "found=true" >> "$GITHUB_OUTPUT"
else
echo "found=false" >> "$GITHUB_OUTPUT"
fi
# See bin/fetch-ci-baseline.sh for why this doesn't require conclusion=success.
if RESULT=$(bin/fetch-ci-baseline.sh "${{ github.repository }}" develop ./develop-sizes.json ./baseline-develop/); then
read -r BASE_SHA BASE_DATE <<< "$RESULT"
echo "found=true" >> "$GITHUB_OUTPUT"
echo "sha=$BASE_SHA" >> "$GITHUB_OUTPUT"
echo "date=$BASE_DATE" >> "$GITHUB_OUTPUT"
else
echo "found=false" >> "$GITHUB_OUTPUT"
fi
Expand All @@ -315,20 +309,12 @@ jobs:
env:
GH_TOKEN: ${{ github.token }}
run: |
RUN_ID=$(gh run list -R "${{ github.repository }}" \
--workflow CI --branch master --status success \
--limit 1 --json databaseId --jq '.[0].databaseId // empty')
if [ -n "$RUN_ID" ]; then
ARTIFACT_NAME=$(gh api "repos/${{ github.repository }}/actions/runs/${RUN_ID}/artifacts" \
--jq '.artifacts[] | select(.name | startswith("firmware-sizes-")) | select(.expired == false) | .name' | head -1)
if [ -n "$ARTIFACT_NAME" ]; then
gh run download "$RUN_ID" -R "${{ github.repository }}" \
--name "$ARTIFACT_NAME" --dir ./baseline-master/
cp "./baseline-master/current-sizes.json" ./master-sizes.json
echo "found=true" >> "$GITHUB_OUTPUT"
else
echo "found=false" >> "$GITHUB_OUTPUT"
fi
# Same approach as the develop baseline above - see bin/fetch-ci-baseline.sh.
if RESULT=$(bin/fetch-ci-baseline.sh "${{ github.repository }}" master ./master-sizes.json ./baseline-master/); then
read -r BASE_SHA BASE_DATE <<< "$RESULT"
echo "found=true" >> "$GITHUB_OUTPUT"
echo "sha=$BASE_SHA" >> "$GITHUB_OUTPUT"
echo "date=$BASE_DATE" >> "$GITHUB_OUTPUT"
else
echo "found=false" >> "$GITHUB_OUTPUT"
fi
Expand All @@ -344,7 +330,7 @@ jobs:
if [ -f ./master-sizes.json ]; then
ARGS="$ARGS --baseline master:./master-sizes.json"
fi
REPORT=$(python3 bin/size_report.py $ARGS)
REPORT=$(python3 bin/size_report.py $ARGS --status-out ./size-status.txt)
if [ -z "$REPORT" ]; then
echo "has_report=false" >> "$GITHUB_OUTPUT"
else
Expand All @@ -355,8 +341,16 @@ jobs:
echo ''
echo "$REPORT"
echo ''
if [ -n "${{ steps.baseline-develop.outputs.sha }}" ]; then
echo "_Baseline \`develop\` = ${{ steps.baseline-develop.outputs.sha }} (${{ steps.baseline-develop.outputs.date }})_ "
fi
if [ -n "${{ steps.baseline-master.outputs.sha }}" ]; then
echo "_Baseline \`master\` = ${{ steps.baseline-master.outputs.sha }} (${{ steps.baseline-master.outputs.date }})_ "
fi
echo '---'
echo "*Updated for ${{ github.sha }}*"
echo ''
echo "_This comment may be deprecated in favor of the \`firmware-size\` commit status check, if that proves sufficient on its own._"
} > ./size-report.md
cat ./size-report.md >> "$GITHUB_STEP_SUMMARY"
fi
Expand All @@ -372,6 +366,7 @@ jobs:
name: size-report
path: |
./size-report.md
./size-status.txt
./pr-number.txt
retention-days: 5

Expand Down
Loading
Loading