Skip to content

Commit 6272540

Browse files
committed
[libc++] Properly extract the PR head and base from the Github event
1 parent 2f9a458 commit 6272540

File tree

1 file changed

+31
-16
lines changed

1 file changed

+31
-16
lines changed

.github/workflows/libcxx-run-benchmarks.yml

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ on:
2121
env:
2222
CC: clang-22
2323
CXX: clang++-22
24-
COMMENT_BODY: ${{ github.event.comment.body }}
25-
PULL_REQUEST_HEAD: ${{ github.event.issue.pull_request.head.sha }}
26-
PULL_REQUEST_BASE: ${{ github.event.issue.pull_request.base.sha }}
2724

2825
jobs:
2926
run-benchmarks:
@@ -33,12 +30,6 @@ jobs:
3330
3431
runs-on: llvm-premerge-libcxx-next-runners # TODO: This should run on a dedicated set of machines
3532
steps:
36-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
37-
with:
38-
ref: ${PULL_REQUEST_HEAD}
39-
fetch-depth: 0
40-
fetch-tags: true # This job requires access to all the Git branches so it can diff against (usually) main
41-
4233
- uses: actions/setup-python@v6
4334
with:
4435
python-version: '3.10'
@@ -48,18 +39,42 @@ jobs:
4839
python3 -m venv .venv
4940
source .venv/bin/activate
5041
python -m pip install -r libcxx/utils/requirements.txt
42+
python -m pip install pygithub
43+
44+
- name: Extract information from the PR
45+
id: vars
46+
run: |
47+
source .venv/bin/activate
48+
cat <<EOF | python >> ${GITHUB_OUTPUT}
49+
import github
50+
repo = github.Github("${{ github.token }}").get_repo("${{ github.repository }}")
51+
pr = repo.get_pull(${{ github.event.issue.number }})
52+
print(f"pr_base={pr.base.sha}")
53+
print(f"pr_head={pr.head.sha}")
54+
EOF
55+
BENCHMARKS=$(echo "${{ github.event.comment.body }}" | sed -nE 's/\/libcxx-bot benchmark (.+)/\1/p')
56+
echo "benchmarks=${BENCHMARKS}" >> ${GITHUB_OUTPUT}
57+
58+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
59+
with:
60+
ref: ${{ steps.vars.outputs.pr_head }}
61+
fetch-depth: 0
62+
fetch-tags: true # This job requires access to all the Git branches so it can diff against (usually) main
63+
path: repo # Avoid nuking the workspace, where we have the Python virtualenv
5164

5265
- name: Run baseline
5366
run: |
54-
BENCHMARKS=$(echo "${COMMENT_BODY}" | sed -nE 's/\/libcxx-bot benchmark (.+)/\1/p')
55-
baseline_commit=$(git merge-base ${PULL_REQUEST_BASE} ${PULL_REQUEST_SHA})
56-
./libcxx/utils/test-at-commit --commit ${baseline_commit} -B build/baseline -- -sv -j1 --param optimization=speed ${BENCHMARKS}
67+
source .venv/bin/activate
68+
baseline_commit=$(git -C repo merge-base ${{ steps.vars.outputs.pr_base }} ${{ steps.vars.outputs.pr_head }})
69+
./repo/libcxx/utils/test-at-commit --git-repo repo --commit ${baseline_commit} -B build/baseline -- -sv -j1 --param optimization=speed ${{ steps.vars.outputs.benchmarks }}
5770
5871
- name: Run candidate
5972
run: |
60-
BENCHMARKS=$(echo "${COMMENT_BODY}" | sed -nE 's/\/libcxx-bot benchmark (.+)/\1/p')
61-
./libcxx/utils/test-at-commit --commit ${PULL_REQUEST_SHA} -B build/candidate -- -sv -j1 --param optimization=speed ${BENCHMARKS}
73+
source .venv/bin/activate
74+
./repo/libcxx/utils/test-at-commit --git-repo repo --commit ${{ steps.vars.outputs.pr_head }} -B build/candidate -- -sv -j1 --param optimization=speed ${{ steps.vars.outputs.benchmarks }}
6275
6376
- name: Compare baseline and candidate runs
64-
run: ./libcxx/utils/compare-benchmarks <(./libcxx/utils/consolidate-benchmarks build/baseline) \
65-
<(./libcxx/utils/consolidate-benchmarks build/candidate)
77+
run: |
78+
source .venv/bin/activate
79+
./repo/libcxx/utils/compare-benchmarks <(./repo/libcxx/utils/consolidate-benchmarks build/baseline) \
80+
<(./repo/libcxx/utils/consolidate-benchmarks build/candidate)

0 commit comments

Comments
 (0)