diff options
author | nlf <quitlahok@gmail.com> | 2021-12-09 03:02:34 +0300 |
---|---|---|
committer | nlf <quitlahok@gmail.com> | 2021-12-09 21:09:02 +0300 |
commit | 6b80faa694d9a42c588921fa5a0664671172c2dc (patch) | |
tree | 367f71d360496c03cde6039cea9f49c7e01c34a2 /.github | |
parent | 1d8bec566cb08ff5ff220f53083323fa8c3fb72e (diff) |
chore(benchmarks): tidy up benchmark workflows
PR-URL: https://github.com/npm/cli/pull/4145
Credit: @nlf
Close: #4145
Reviewed-by: @wraithgar
Diffstat (limited to '.github')
-rw-r--r-- | .github/workflows/benchmark-comment.yml | 13 | ||||
-rw-r--r-- | .github/workflows/benchmark.yml | 28 |
2 files changed, 10 insertions, 31 deletions
diff --git a/.github/workflows/benchmark-comment.yml b/.github/workflows/benchmark-comment.yml index de86c3c13..285b29384 100644 --- a/.github/workflows/benchmark-comment.yml +++ b/.github/workflows/benchmark-comment.yml @@ -17,15 +17,12 @@ jobs: DISPATCH_REPO: "benchmarks" DISPATCH_OWNER: "npm" EVENT_NAME: ${{ github.event_name }} - EVENT_ACTION: ${{ github.event.action }} OWNER: ${{ github.event.repository.owner.login }} REPO: ${{ github.event.repository.name }} ISSUE_NUMBER: ${{ github.event.issue.number }} - COMMENT_BODY: ${{ github.event.comment.body }} - COMMENT_ID: ${{ github.event.comment.id }} COMMENT_NODE_ID: ${{ github.event.comment.node_id }} COMMENT_ACTIONABLE: ${{ startsWith(github.event.comment.body, 'test this please ✅') }} - AUTH_TOKEN: ${{ secrets.NPM_DEPLOY_USER_PAT }} + AUTH_TOKEN: ${{ secrets.NPM_BENCHMARKS_TOKEN }} run: | # Comment Handler @@ -46,24 +43,22 @@ jobs: PR_DATA=$(curl -s "${IS_PR}") PR_OWNER=$(echo "${PR_DATA}" | jq '.head.repo.owner.login') PR_REPO=$(echo "${PR_DATA}" | jq '.head.repo.name') - PR_COMMIT_SHA=$(curl -s "${IS_PR}/commits" | jq -r '.[0].sha') # dispatch request for benchmarks echo "Dispatching request..." curl \ -s \ -X POST https://api.github.com/repos/${DISPATCH_OWNER}/${DISPATCH_REPO}/dispatches \ - -H "Accept: application/vnd.github.everest-preview+json" \ + -H "Accept: application/vnd.github.v3+json" \ -H "Authorization: token ${AUTH_TOKEN}" \ -d \ ' { - "event_type": "'"${EVENT_NAME}"'", + "event_type": "'"${EVENT_NAME} ${PR_OWNER}/${PR_REPO}#${ISSUE_NUMBER}"'", "client_payload": { "pr_id": "'"${ISSUE_NUMBER}"'", "repo": "'"${PR_REPO}"'", - "owner": "'"${PR_OWNER}"'", - "commit_sha": "'"${PR_COMMIT_SHA}"'" + "owner": "'"${PR_OWNER}"'" } }' diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 0920f711c..b9da2ddfd 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -2,9 +2,6 @@ name: Benchmark Suite on: - push: - branches: - - "latest" pull_request: branches: - "**" @@ -21,48 +18,35 @@ jobs: DISPATCH_REPO: "benchmarks" DISPATCH_OWNER: "npm" EVENT_NAME: ${{ github.event_name }} - EVENT_ACTION: ${{ github.event.action }} REPO: ${{ github.event.repository.name }} PR_NUMBER: ${{ github.event.pull_request.number }} PR_OWNER: ${{ github.event.pull_request.head.repo.owner.login }} - PR_COMMITS_URL: ${{ github.event.pull_request.commits_url }} - PR_COMMIT_SHA: ${{ github.event.pull_request.head.sha }} - AUTH_TOKEN: ${{ secrets.NPM_DEPLOY_USER_PAT }} + AUTH_TOKEN: ${{ secrets.NPM_BENCHMARKS_TOKEN }} run: | # Dispatch Handler dispatch_request () { echo "Dispatching request..." - REF_SHA=$1 curl \ -s \ -X POST https://api.github.com/repos/${DISPATCH_OWNER}/${DISPATCH_REPO}/dispatches \ - -H "Accept: application/vnd.github.everest-preview+json" \ + -H "Accept: application/vnd.github.v3+json" \ -H "Authorization: token ${AUTH_TOKEN}" \ -d \ ' { - "event_type": "'"${EVENT_NAME}"'", + "event_type": "'"${EVENT_NAME} ${PR_OWNER}/${REPO}#${PR_NUMBER}"'", "client_payload": { "pr_id": "'"${PR_NUMBER}"'", "repo": "'"${REPO}"'", - "owner": "'"${PR_OWNER}"'", - "commit_sha": "'"${REF_SHA}"'" + "owner": "'"${PR_OWNER}"'" } }' } if [ "${AUTH_TOKEN}" != "" ]; then - if [ "${EVENT_ACTION}" == "opened" ]; then - # Fetch the head commit sha, since it doesn't exist in the body of this event - COMMIT_SHA=$(curl -s "${PR_COMMITS_URL}" | jq -r '.[0].sha') - - # Dispatch request for benchmarks - dispatch_request "${COMMIT_SHA}" - else - # Dispatch request for benchmarks - dispatch_request "${PR_COMMIT_SHA}" - fi + # Dispatch request for benchmarks + dispatch_request else echo "NO AUTH - FORK PULL REQUEST" fi |