Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Karrys <luke@lukekarrys.com>2022-06-01 22:41:43 +0300
committerGitHub <noreply@github.com>2022-06-01 22:41:43 +0300
commit0c2d2e084fa7119147957b09f7e7a06a05b70781 (patch)
tree1a0731187d700768ef4be88ef12c29c0513d4769 /.github
parentd60cfbcb43745705fd418fc2a7b8b427c6611911 (diff)
chore: merge benchmark action to single job (#4970)
Diffstat (limited to '.github')
-rw-r--r--.github/workflows/benchmark.yml73
1 files changed, 26 insertions, 47 deletions
diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml
index 7dcba88d9..018eeae7e 100644
--- a/.github/workflows/benchmark.yml
+++ b/.github/workflows/benchmark.yml
@@ -12,7 +12,7 @@ on:
- edited
jobs:
- pull-request:
+ trigger-benchmark:
runs-on: ubuntu-latest
steps:
- name: Incoming Pull Request
@@ -21,33 +21,51 @@ jobs:
github.event_name == 'issue_comment' &&
github.event.issue.pull_request &&
github.event.issue.state == 'open' &&
- startsWith(github.event.comment.body, '@npm-robot benchmark this')
+ startsWith(github.event.comment.body, '@npm-cli-bot benchmark this')
)
env:
# gh cli uses these env vars for owner/repo/token
GH_REPO: "npm/benchmarks"
GITHUB_TOKEN: ${{ secrets.BENCHMARK_DISPATCH_TOKEN }}
run: |
- if [[ "$GITHUB_TOKEN" == "" ]]; then
- echo "No auth - from fork pull request, exiting"
- exit 0
- fi
-
EVENT_NAME="${{ github.event_name }}"
OWNER="${{ github.event.repository.owner.login }}"
REPO="${{ github.event.repository.name }}"
PR=""
if [[ "$EVENT_NAME" == "pull_request" ]]; then
+ if [[ "$GITHUB_TOKEN" == "" ]]; then
+ echo "No auth - from fork pull request, exiting"
+ exit 0
+ fi
PR="${{ github.event.pull_request.number }}"
else
PR="${{ github.event.issue.number }}"
- SENDER="${{ github.event.issue.sender.login }}"
+ SENDER="${{ github.event.comment.user.login }}"
ROLE=$(gh api repos/${OWNER}/${REPO}/collaborators/${SENDER}/permission -q '.permission')
+
if [[ "$ROLE" != "admin" ]]; then
echo "${SENDER} is ${ROLE}, not an admin, exiting"
exit 0
fi
+
+ # add emoji to comment if user is an admin to signal
+ # benchmark is running
+ COMMENT_NODE_ID="${{ github.event.comment.node_id }}"
+ QUERY='mutation ($inputData:AddReactionInput!) {
+ addReaction (input:$inputData) {
+ reaction { content }
+ }
+ }'
+ echo '{
+ "query": "'${QUERY}'",
+ "variables": {
+ "inputData": {
+ "subjectId": "'"${COMMENT_NODE_ID}"'",
+ "content": "ROCKET"
+ }
+ }
+ }' | gh api graphql --input -
fi
EVENT="${EVENT_NAME} ${OWNER}/${REPO}#${PR}"
@@ -59,42 +77,3 @@ jobs:
"owner": "'"$OWNER"'"
}
}' | gh api repos/{owner}/{repo}/dispatches --input -
-
- comment:
- runs-on: ubuntu-latest
- steps:
- - name: Incoming Comment
- if: |
- github.event_name == 'issue_comment' &&
- github.event.issue.pull_request &&
- github.event.issue.state == 'open' &&
- startsWith(github.event.comment.body, '@npm-cli-bot benchmark this')
- env:
- # gh cli uses this env var as the token
- GITHUB_TOKEN: ${{ secrets.BENCHMARK_DISPATCH_TOKEN }}
- run: |
- OWNER="${{ github.event.repository.owner.login }}"
- REPO="${{ github.event.repository.name }}"
- SENDER="${{ github.event.issue.sender.login }}"
- ROLE=$(gh api repos/${OWNER}/${REPO}/collaborators/${SENDER}/permission -q '.permission')
- if [[ "$ROLE" != "admin"]]; then
- echo "${SENDER} is ${ROLE}, not an admin, exiting"
- exit 0
- fi
-
- COMMENT_NODE_ID="${{ github.event.comment.node_id }}"
- QUERY='mutation ($inputData:AddReactionInput!) {
- addReaction (input:$inputData) {
- reaction { content }
- }
- }'
- echo '{
- "query": "'${QUERY}'",
- "variables": {
- "inputData": {
- "subjectId": "'"${COMMENT_NODE_ID}"'",
- "content": "ROCKET"
- }
- }
- }' | gh api graphql --input -
-