Skip to content
Merged
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
39 changes: 36 additions & 3 deletions .github/workflows/ci-size-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,62 @@ jobs:
runs-on: ubuntu-latest
if: >
github.event.workflow_run.name == 'Build pre-release' &&
github.event.workflow_run.event == 'push' &&
github.event.workflow_run.conclusion == 'success'
github.event.workflow_run.event == 'push'
concurrency:
group: size-baseline-${{ github.event.workflow_run.head_branch }}
cancel-in-progress: true
permissions:
actions: read # to download artifacts from the triggering workflow run
actions: read # to download artifacts and query job conclusions from the triggering workflow run
steps:
# Don't gate on github.event.workflow_run.conclusion: "Build
# pre-release" also runs a separate Release job (nightly upload to
# iNavFlight/inav-nightly) that can fail for reasons unrelated to the
# build itself (e.g. an expired NIGHTLY_TOKEN) and drags the whole
# run's conclusion to failure even when the build succeeded and
# produced the artifacts we actually need. Check the specific job
# that produces them instead.
- name: Check build job succeeded
id: check
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RUN_ID: ${{ github.event.workflow_run.id }}
run: |
CONCLUSION=$(gh api "repos/${{ github.repository }}/actions/runs/${RUN_ID}/jobs" --paginate \
--jq '.jobs[] | select(.name == "build / upload-artifacts") | .conclusion')
Comment on lines +60 to +61

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

1. Multi-match conclusion mishandled 🐞 Bug ≡ Correctness

Check build job succeeded captures all matching job conclusions into a single variable, but then
compares it as if it were a single scalar value. If more than one build / upload-artifacts job
entry is returned, CONCLUSION becomes multi-valued and the step will incorrectly skip baseline
publishing even when the relevant job succeeded.
Agent Prompt
### Issue description
The workflow stores the output of a jq filter that can emit multiple results into `CONCLUSION`, then compares it to the string `success`. If multiple matches exist, the comparison fails and baseline publishing is skipped.

### Issue Context
This job is intended to be a robust gate for baseline publishing; it should deterministically select exactly one conclusion (e.g., the latest/most relevant matching job) and/or explicitly detect and handle multiple matches.

### Fix Focus Areas
- .github/workflows/ci-size-report.yml[60-73]

### Suggested fix
Update the jq query to return exactly one value (or explicitly error/warn on multiple), for example:
- Use jq to select the most recent matching job (e.g., `max_by(.completed_at)` or similar) and output only its `.conclusion`, or
- Collect matches into an array and:
  - if length==0: warn + proceed=false
  - if length>1: warn about ambiguity, choose the latest deterministically
  - else: use the single conclusion

This ensures `CONCLUSION` is always a single scalar (`success`, `failure`, `skipped`, etc.) before the string comparison.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

if [ -z "$CONCLUSION" ]; then
# Job not found at all usually means the caller/callee job names
# changed (e.g. nightly-build.yml's "build" job or ci.yml's
# "upload-artifacts" job got renamed) — that's a workflow
# structure mismatch, not an expected build failure, and is
# exactly the kind of thing that silently broke baseline
# publishing before. Warn louder than a plain failed build.
echo "::warning::build / upload-artifacts job not found in run ${RUN_ID} — job name may have changed, skipping baseline publish"
echo "proceed=false" >> "$GITHUB_OUTPUT"
elif [ "$CONCLUSION" != "success" ]; then
echo "::notice::build / upload-artifacts did not succeed (conclusion: ${CONCLUSION}), skipping baseline publish"
echo "proceed=false" >> "$GITHUB_OUTPUT"
else
echo "proceed=true" >> "$GITHUB_OUTPUT"
fi

- name: Download size report
if: steps.check.outputs.proceed == 'true'
uses: actions/download-artifact@v4
with:
name: size-report
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Download branch name
if: steps.check.outputs.proceed == 'true'
uses: actions/download-artifact@v4
with:
name: branch-name
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Publish baseline
if: steps.check.outputs.proceed == 'true'
env:
GH_TOKEN: ${{ secrets.PR_BUILDS_TOKEN }}
run: |
Expand Down
Loading