Skip to content

Commit 8f7c604

Browse files
committed
Handle auto-rebase actions in CI table
A limitation of the engine-tests-report workflow running as a separate, trusted workflow was that if you rebased a branch in the GitHub UI using the "Update branch" button, it wouldn't have access to the PR number in github.event.workflow_run.pull_requests. This array is allowed to be empty according to the GitHub Actions docs. So the table wouldn't get created or updated. So instead save the PR number while preparing to run the engine-tests jobs (the original, untrusted workflow always has a PR number) and upload it as an artifact, which is downloaded by the engine-tests-report workflow. Another option might be to use the jwalton/gh-find-current-pr action, but I wasn't super confident it would be actively maintained. LLM disclosure: I used a bot to evaluate a couple of potential solutions, generated one, then hand-edited the generated code (it initially didn't work)
1 parent ca7a2e5 commit 8f7c604

2 files changed

Lines changed: 28 additions & 2 deletions

File tree

‎.github/workflows/engine-tests-report.yml‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,23 @@ jobs:
4242
github-token: ${{ secrets.GITHUB_TOKEN }}
4343
run-id: ${{ github.event.workflow_run.id }}
4444

45+
- name: Download PR number
46+
uses: actions/download-artifact@v8
47+
with:
48+
name: pr_number.txt
49+
github-token: ${{ secrets.GITHUB_TOKEN }}
50+
run-id: ${{ github.event.workflow_run.id }}
51+
52+
- name: Read PR number
53+
id: pr
54+
run: |
55+
PR_NUMBER="$(head pr_number.txt -n1)"
56+
if [[ ! "$PR_NUMBER" =~ ^[1-9][0-9]*$ ]]; then
57+
echo "Unexpected contents of pr_number.txt: $PR_NUMBER"
58+
exit 1
59+
fi
60+
echo "number=$PR_NUMBER" >> "$GITHUB_OUTPUT"
61+
4562
- name: Check for results
4663
id: check
4764
run: |
@@ -63,4 +80,4 @@ jobs:
6380
with:
6481
path: comment-body.txt
6582
header: test262-engine-results
66-
number: ${{ github.event.workflow_run.pull_requests[0].number }}
83+
number: ${{ steps.pr.outputs.number }}

‎.github/workflows/engine-tests.yml‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55

66
jobs:
77
changed-tests:
8-
name: Identify changed tests
8+
name: Prepare engine tests run
99
runs-on: ubuntu-latest
1010
outputs:
1111
any_changed: ${{ steps.changed.outputs.any_changed }}
@@ -20,6 +20,15 @@ jobs:
2020
with:
2121
files: test/
2222

23+
- name: Record PR number
24+
run: echo "${{ github.event.number }}" > pr_number.txt
25+
26+
- name: Upload PR number
27+
uses: actions/upload-artifact@v7
28+
with:
29+
path: pr_number.txt
30+
archive: false
31+
2332
# Future work:
2433
# - Run each step of the matrix on main as well, and indicate in the table
2534
# whether a test moved from passing to failing or vice versa

0 commit comments

Comments
 (0)