Skip to content

chore: backport benchmark, node PR, and smoke tests chores #6877

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 61 additions & 53 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- '*'
paths:
- lib/**
- workspaces/**/lib/**
issue_comment:
types:
- created
Expand All @@ -17,63 +18,70 @@ jobs:
steps:
- name: Incoming Pull Request
if: |
github.event_name == 'pull_request' || (
(
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == 'npm/cli'
) || (
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 these env vars for owner/repo/token
GH_REPO: "npm/benchmarks"
GITHUB_TOKEN: ${{ secrets.BENCHMARK_DISPATCH_TOKEN }}
run: |
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.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"
}
uses: actions/github-script@v6
with:
github-token: ${{ secrets.BENCHMARK_DISPATCH_TOKEN }}
script: |
const {
payload,
eventName,
repo: { owner, repo },
issue: { number },
} = context

if (eventName === 'issue_comment') {
const res = await github.rest.repos.getCollaboratorPermissionLevel({
owner,
repo,
username: payload.comment.user.login,
})
if (res.data.permission !== 'admin') {
core.info(`Commenter is not an admin, exiting`)
return
}
}' | gh api graphql --input -
fi

EVENT="${EVENT_NAME} ${OWNER}/${REPO}#${PR}"
echo '{
"event_type": "'"$EVENT"'",
"client_payload": {
"pr_id": "'"$PR"'",
"repo": "'"$REPO"'",
"owner": "'"$OWNER"'"

// add emoji to comment if user is an admin to signal benchmark is running
await github.rest.reactions.createForIssueComment({
owner,
repo,
comment_id: payload.comment.node_id,
content: 'rocket',
})
}
}' | gh api repos/{owner}/{repo}/dispatches --input -

const pullRequest = payload.pull_request || await github.rest.pulls.get({
owner,
repo,
pull_number: number,
}).then(r => r.data)

core.info(`Pull request: ${pullRequest.number}`)
core.info(`Base ref: ${pullRequest.base.ref}`)

const matchesRelease = pullRequest.base.ref.match(/^release\/v(\d+)$/)
const targetSpec = matchesRelease ? matchesRelease[1] : 'latest'
core.info(`Target spec: ${targetSpec}`)

const eventType = `"${eventName} ${owner}/${repo}#${pullRequest.number}"`
core.info(`Event type: ${eventType}`)

await github.rest.repos.createDispatchEvent({
owner: 'npm',
repo: 'benchmarks',
event_type: eventType,
client_payload: {
owner,
repo,
pr_id: number,
target_spec: targetSpec,
},
})
2 changes: 1 addition & 1 deletion DEPENDENCIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -714,11 +714,11 @@ graph LR;
npmcli-run-script-->npmcli-promise-spawn["@npmcli/promise-spawn"];
npmcli-run-script-->read-package-json-fast;
npmcli-run-script-->which;
npmcli-smoke-tests-->http-proxy;
npmcli-smoke-tests-->npmcli-eslint-config["@npmcli/eslint-config"];
npmcli-smoke-tests-->npmcli-mock-registry["@npmcli/mock-registry"];
npmcli-smoke-tests-->npmcli-promise-spawn["@npmcli/promise-spawn"];
npmcli-smoke-tests-->npmcli-template-oss["@npmcli/template-oss"];
npmcli-smoke-tests-->proxy;
npmcli-smoke-tests-->tap;
npmcli-smoke-tests-->which;
npmlog-->are-we-there-yet;
Expand Down
6 changes: 3 additions & 3 deletions node_modules/is-core-module/core.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
"sys": [">= 0.4 && < 0.7", ">= 0.8"],
"node:sys": [">= 14.18 && < 15", ">= 16"],
"test/reporters": ">= 19.9 && < 20.2",
"node:test/reporters": [">= 19.9", ">= 20"],
"node:test/reporters": [">= 18.17 && < 19", ">= 19.9", ">= 20"],
"node:test": [">= 16.17 && < 17", ">= 18"],
"timers": true,
"node:timers": [">= 14.18 && < 15", ">= 16"],
Expand Down Expand Up @@ -149,8 +149,8 @@
"node:v8": [">= 14.18 && < 15", ">= 16"],
"vm": true,
"node:vm": [">= 14.18 && < 15", ">= 16"],
"wasi": [">= 13.4 && < 13.5", ">= 20"],
"node:wasi": ">= 20",
"wasi": [">= 13.4 && < 13.5", ">= 18.17 && < 19", ">= 20"],
"node:wasi": [">= 18.17 && < 19", ">= 20"],
"worker_threads": ">= 11.7",
"node:worker_threads": [">= 14.18 && < 15", ">= 16"],
"zlib": ">= 0.5",
Expand Down
10 changes: 5 additions & 5 deletions node_modules/is-core-module/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "is-core-module",
"version": "2.12.1",
"version": "2.13.0",
"description": "Is this specifier a node.js core module?",
"main": "index.js",
"sideEffects": false,
Expand Down Expand Up @@ -45,17 +45,17 @@
"has": "^1.0.3"
},
"devDependencies": {
"@ljharb/eslint-config": "^21.0.1",
"aud": "^2.0.2",
"@ljharb/eslint-config": "^21.1.0",
"aud": "^2.0.3",
"auto-changelog": "^2.4.0",
"eslint": "=8.8.0",
"in-publish": "^2.0.1",
"mock-property": "^1.0.0",
"npmignore": "^0.3.0",
"nyc": "^10.3.2",
"safe-publish-latest": "^2.0.0",
"semver": "^6.3.0",
"tape": "^5.6.3"
"semver": "^6.3.1",
"tape": "^5.6.6"
},
"auto-changelog": {
"output": "CHANGELOG.md",
Expand Down
Loading