Skip to content

Commit 4bd5324

Browse files
fix(ci): check out fetched PR commit in performance workflow
Fix the performance-testing workflow so its after-measurements run against the actual fetched PR changes. Further harden the workflow by avoiding direct interpolation of PR-controlled values. Signed-off-by: Josh <josh.t.richards@gmail.com>
1 parent 7f7fdcb commit 4bd5324

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

.github/workflows/performance.yml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ jobs:
3030

3131
steps:
3232

33-
- name: Checkout server before PR
33+
# Check out the PR base branch first so the initial measurements provide
34+
# a baseline for comparison with the PR changes measured below.
35+
- name: Check out PR base branch
3436
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
3537
with:
3638
persist-credentials: false
@@ -70,11 +72,19 @@ jobs:
7072
output: before.json
7173
profiler-branch: master
7274

73-
- name: Apply PR # zizmor: ignore[template-injection]
75+
- name: Check out PR changes and apply upgrade
76+
# Switch from the base branch used for the baseline measurements to the
77+
# fetched PR commit so the after measurements run against the PR changes.
78+
#
79+
# Use FETCH_HEAD explicitly so the local branch points to the fetched PR
80+
# commit rather than the currently checked-out base commit.
81+
env:
82+
PR_HEAD_REPO_URL: ${{ github.event.pull_request.head.repo.clone_url }}
83+
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
7484
run: |
75-
git remote add pr '${{ github.event.pull_request.head.repo.clone_url }}'
76-
git fetch pr '${{ github.event.pull_request.head.ref }}'
77-
git checkout -b 'pr/${{ github.event.pull_request.head.ref }}'
85+
git remote add pr-source "$PR_HEAD_REPO_URL"
86+
git fetch pr-source "$PR_HEAD_REF"
87+
git checkout -B "pr/$PR_HEAD_REF" FETCH_HEAD
7888
git submodule update
7989
8090
./occ upgrade
@@ -104,14 +114,16 @@ jobs:
104114
105115
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v7
106116
if: failure() && steps.compare.outcome == 'failure'
117+
env:
118+
COMPARE_OUTPUT: ${{ steps.compare.outputs.compare }}
107119
with:
108120
github-token: ${{secrets.GITHUB_TOKEN}}
109121
script: |
110122
let comment = `Possible performance regression detected\n`;
111123
comment += `<details><summary>Show Output</summary>
112124
113125
\`\`\`
114-
${{ steps.compare.outputs.compare }}
126+
${process.env.COMPARE_OUTPUT}
115127
\`\`\`
116128
117129
</details>`;

0 commit comments

Comments
 (0)