Skip to content

Commit 6b80faa

Browse files
committed
chore(benchmarks): tidy up benchmark workflows
PR-URL: #4145 Credit: @nlf Close: #4145 Reviewed-by: @wraithgar
1 parent 1d8bec5 commit 6b80faa

File tree

2 files changed

+10
-31
lines changed

2 files changed

+10
-31
lines changed

.github/workflows/benchmark-comment.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,12 @@ jobs:
1717
DISPATCH_REPO: "benchmarks"
1818
DISPATCH_OWNER: "npm"
1919
EVENT_NAME: ${{ github.event_name }}
20-
EVENT_ACTION: ${{ github.event.action }}
2120
OWNER: ${{ github.event.repository.owner.login }}
2221
REPO: ${{ github.event.repository.name }}
2322
ISSUE_NUMBER: ${{ github.event.issue.number }}
24-
COMMENT_BODY: ${{ github.event.comment.body }}
25-
COMMENT_ID: ${{ github.event.comment.id }}
2623
COMMENT_NODE_ID: ${{ github.event.comment.node_id }}
2724
COMMENT_ACTIONABLE: ${{ startsWith(github.event.comment.body, 'test this please ✅') }}
28-
AUTH_TOKEN: ${{ secrets.NPM_DEPLOY_USER_PAT }}
25+
AUTH_TOKEN: ${{ secrets.NPM_BENCHMARKS_TOKEN }}
2926
run: |
3027
# Comment Handler
3128
@@ -46,24 +43,22 @@ jobs:
4643
PR_DATA=$(curl -s "${IS_PR}")
4744
PR_OWNER=$(echo "${PR_DATA}" | jq '.head.repo.owner.login')
4845
PR_REPO=$(echo "${PR_DATA}" | jq '.head.repo.name')
49-
PR_COMMIT_SHA=$(curl -s "${IS_PR}/commits" | jq -r '.[0].sha')
5046
5147
# dispatch request for benchmarks
5248
echo "Dispatching request..."
5349
curl \
5450
-s \
5551
-X POST https://github.com/api/repos/${DISPATCH_OWNER}/${DISPATCH_REPO}/dispatches \
56-
-H "Accept: application/vnd.github.everest-preview+json" \
52+
-H "Accept: application/vnd.github.v3+json" \
5753
-H "Authorization: token ${AUTH_TOKEN}" \
5854
-d \
5955
'
6056
{
61-
"event_type": "'"${EVENT_NAME}"'",
57+
"event_type": "'"${EVENT_NAME} ${PR_OWNER}/${PR_REPO}#${ISSUE_NUMBER}"'",
6258
"client_payload": {
6359
"pr_id": "'"${ISSUE_NUMBER}"'",
6460
"repo": "'"${PR_REPO}"'",
65-
"owner": "'"${PR_OWNER}"'",
66-
"commit_sha": "'"${PR_COMMIT_SHA}"'"
61+
"owner": "'"${PR_OWNER}"'"
6762
}
6863
}'
6964

.github/workflows/benchmark.yml

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
name: Benchmark Suite
33

44
on:
5-
push:
6-
branches:
7-
- "latest"
85
pull_request:
96
branches:
107
- "**"
@@ -21,48 +18,35 @@ jobs:
2118
DISPATCH_REPO: "benchmarks"
2219
DISPATCH_OWNER: "npm"
2320
EVENT_NAME: ${{ github.event_name }}
24-
EVENT_ACTION: ${{ github.event.action }}
2521
REPO: ${{ github.event.repository.name }}
2622
PR_NUMBER: ${{ github.event.pull_request.number }}
2723
PR_OWNER: ${{ github.event.pull_request.head.repo.owner.login }}
28-
PR_COMMITS_URL: ${{ github.event.pull_request.commits_url }}
29-
PR_COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
30-
AUTH_TOKEN: ${{ secrets.NPM_DEPLOY_USER_PAT }}
24+
AUTH_TOKEN: ${{ secrets.NPM_BENCHMARKS_TOKEN }}
3125
run: |
3226
# Dispatch Handler
3327
3428
dispatch_request () {
3529
echo "Dispatching request..."
36-
REF_SHA=$1
3730
curl \
3831
-s \
3932
-X POST https://github.com/api/repos/${DISPATCH_OWNER}/${DISPATCH_REPO}/dispatches \
40-
-H "Accept: application/vnd.github.everest-preview+json" \
33+
-H "Accept: application/vnd.github.v3+json" \
4134
-H "Authorization: token ${AUTH_TOKEN}" \
4235
-d \
4336
'
4437
{
45-
"event_type": "'"${EVENT_NAME}"'",
38+
"event_type": "'"${EVENT_NAME} ${PR_OWNER}/${REPO}#${PR_NUMBER}"'",
4639
"client_payload": {
4740
"pr_id": "'"${PR_NUMBER}"'",
4841
"repo": "'"${REPO}"'",
49-
"owner": "'"${PR_OWNER}"'",
50-
"commit_sha": "'"${REF_SHA}"'"
42+
"owner": "'"${PR_OWNER}"'"
5143
}
5244
}'
5345
}
5446
5547
if [ "${AUTH_TOKEN}" != "" ]; then
56-
if [ "${EVENT_ACTION}" == "opened" ]; then
57-
# Fetch the head commit sha, since it doesn't exist in the body of this event
58-
COMMIT_SHA=$(curl -s "${PR_COMMITS_URL}" | jq -r '.[0].sha')
59-
60-
# Dispatch request for benchmarks
61-
dispatch_request "${COMMIT_SHA}"
62-
else
63-
# Dispatch request for benchmarks
64-
dispatch_request "${PR_COMMIT_SHA}"
65-
fi
48+
# Dispatch request for benchmarks
49+
dispatch_request
6650
else
6751
echo "NO AUTH - FORK PULL REQUEST"
6852
fi

0 commit comments

Comments
 (0)