Skip to content

Commit cc3c3aa

Browse files
raiden00plxiaoxiang781216
authored andcommitted
ci: do not trigger Build on PR description edits
The Depends-On feature (commit 2aebae7) made the Build workflow trigger on PR description edits. A gate job checks whether the edit changed any Depends-On declaration: if yes, the build jobs run again with the new dependencies; on any other edit the gate skips all build jobs. The gate has a side effect that breaks PR check results. Skipped jobs still register check results on the PR, and the PR checks view shows the newest check run of each name. So after any description edit the PR shows "skipped" for every build check instead of the pass/fail from the real run. Re-running that newest run only repeats the skip, so the real results never come back. This can also hide a red X from a failed build. Fix by not triggering Build on description edits at all: remove the "edited" event type and the gate job. Depends-On keeps working: dependencies are read from the description at the start of every run against master, as before. Fetch-Source now re-reads the description through the API instead of using the copy stored in the event payload, so every run uses the current Depends-On state no matter how it was triggered. After editing a Depends-On line, retrigger CI by any of: - pushing new or rebased commits to the PR branch - closing and reopening the PR - pressing "Re-run all jobs" on the existing Build run A description edit alone no longer triggers anything, which is exactly the behavior that corrupted the PR check results. Signed-off-by: raiden00pl <raiden00@railab.me> Assisted-by: Claude Code
1 parent e269d1c commit cc3c3aa

1 file changed

Lines changed: 16 additions & 79 deletions

File tree

.github/workflows/build.yml

Lines changed: 16 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -14,99 +14,24 @@ name: Build
1414

1515
on:
1616
pull_request:
17-
types: [opened, synchronize, reopened, edited]
1817
push:
1918
branches:
2019
- 'releases/*'
2120
tags:
2221

22+
# pull-requests read: Fetch-Source re-reads the PR description so that a
23+
# manual re-run picks up Depends-On lines edited after the run was created.
2324
permissions:
2425
contents: read
26+
pull-requests: read
2527

2628
concurrency:
2729
group: build-${{ github.event.pull_request.number || github.ref }}
28-
# Edited runs do not request cancellation of an active code build.
29-
# GitHub may still replace an older pending run in this concurrency group.
30-
cancel-in-progress: ${{ github.event.action != 'edited' }}
30+
cancel-in-progress: true
3131

3232
jobs:
33-
# Gate heavy CI on dependency-changing edits.
34-
Changes:
35-
runs-on: ubuntu-latest
36-
outputs:
37-
should_build: ${{ steps.gate.outputs.should_build }}
38-
steps:
39-
# Do not let PR code control its own edit gate.
40-
- name: Checkout base-branch CI scripts
41-
if: ${{ github.event_name == 'pull_request' && github.event.action == 'edited' }}
42-
uses: actions/checkout@v7
43-
with:
44-
ref: ${{ github.event.pull_request.base.sha }}
45-
sparse-checkout: .github/scripts
46-
sparse-checkout-cone-mode: false
47-
fetch-depth: 1
48-
path: base-ci
49-
continue-on-error: true
50-
- name: Checkout PR CI scripts (fallback)
51-
if: ${{ github.event_name == 'pull_request' && github.event.action == 'edited' }}
52-
uses: actions/checkout@v7
53-
with:
54-
sparse-checkout: .github/scripts
55-
sparse-checkout-cone-mode: false
56-
fetch-depth: 1
57-
path: pr-ci
58-
- name: Decide whether to run CI
59-
id: gate
60-
shell: bash
61-
env:
62-
ACTION: ${{ github.event.action }}
63-
NEW_BODY: ${{ github.event.pull_request.body }}
64-
OLD_BODY: ${{ github.event.changes.body.from }}
65-
BODY_CHANGE: ${{ toJSON(github.event.changes.body) }}
66-
BASE_CHANGE: ${{ toJSON(github.event.changes.base) }}
67-
run: |
68-
set -euo pipefail
69-
70-
if [ "${ACTION:-}" != "edited" ]; then
71-
echo "Event '${ACTION:-push}': running CI."
72-
echo "should_build=true" >> "$GITHUB_OUTPUT"
73-
exit 0
74-
fi
75-
76-
if [ "$BASE_CHANGE" != "null" ]; then
77-
echo "::notice::PR base branch changed; running CI."
78-
echo "should_build=true" >> "$GITHUB_OUTPUT"
79-
exit 0
80-
fi
81-
if [ "$BODY_CHANGE" = "null" ]; then
82-
echo "::notice::PR edited but body unchanged; no code/dependency change, skipping CI."
83-
echo "should_build=false" >> "$GITHUB_OUTPUT"
84-
exit 0
85-
fi
86-
87-
PARSER="pr-ci/.github/scripts/depends_on.py"
88-
if [ -f "base-ci/.github/scripts/depends_on.py" ]; then
89-
PARSER="base-ci/.github/scripts/depends_on.py"
90-
echo "Using base-branch parser for the gate."
91-
else
92-
echo "::notice::Base branch has no depends_on.py yet; using PR parser for the gate (bootstrap)."
93-
fi
94-
95-
# Include status so invalid declarations also retrigger reporting.
96-
NEW_STATE="$(PR_BODY="$NEW_BODY" python3 "$PARSER" --print-state)"
97-
OLD_STATE="$(PR_BODY="$OLD_BODY" python3 "$PARSER" --print-state)"
98-
if [ "$NEW_STATE" != "$OLD_STATE" ]; then
99-
echo "depends-on state changed; running CI."
100-
echo "should_build=true" >> "$GITHUB_OUTPUT"
101-
else
102-
echo "::notice::No depends-on change on this edit; no code change, skipping CI."
103-
echo "should_build=false" >> "$GITHUB_OUTPUT"
104-
fi
105-
10633
# Fetch the source from nuttx and nuttx-apps repos
10734
Fetch-Source:
108-
needs: Changes
109-
if: ${{ needs.Changes.outputs.should_build == 'true' }}
11035
runs-on: ubuntu-latest
11136
steps:
11237
- name: Checkout CI scripts
@@ -119,6 +44,7 @@ jobs:
11944
id: gittargets
12045
shell: bash
12146
env:
47+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12248
PR_BODY: ${{ github.event.pull_request.body }}
12349
PR_NUMBER: ${{ github.event.pull_request.number }}
12450
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
@@ -127,6 +53,17 @@ jobs:
12753
OS_REF=""
12854
APPS_REF=""
12955
56+
# The event payload keeps the PR description from when the run was
57+
# created; re-read it so a manual re-run picks up an edited
58+
# Depends-On line. Keep the payload copy if the API call fails.
59+
if [ -n "${PR_NUMBER:-}" ]; then
60+
if LIVE_BODY="$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}" --jq '.body // ""')"; then
61+
PR_BODY="$LIVE_BODY"
62+
else
63+
echo "::warning::Could not re-read the PR description; using the copy from the event payload."
64+
fi
65+
fi
66+
13067
REF=$GITHUB_REF
13168
13269
# If a base ref is set this is a PR and we will want to use

0 commit comments

Comments
 (0)