From 75a80e4182384e83d093b14fe6f6a458ebedf5db Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 15 Nov 2024 14:05:06 -0800 Subject: [PATCH] Meta: ensure the IPR check runs on the PR head, not main (#3480) --- .github/workflows/build.yml | 2 +- .github/workflows/deploy.yml | 2 +- .github/workflows/enforce-format.yml | 2 +- .github/workflows/ipr.yml | 4 ++-- .github/workflows/preview-build.yml | 2 +- .github/workflows/preview.yml | 2 +- .github/workflows/spellcheck.yml | 2 +- package.json | 2 +- scripts/check-form.js | 23 ++++++++++++++++------- 9 files changed, 25 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d6d4fc5843..6341055172 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,7 +9,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: ljharb/actions/node/install@6bc39109c48f74895ad72ec03ca0bb4e4da2fa3f + - uses: ljharb/actions/node/install@dfd9796898850cf07630d1bd4053a7c9a379e90f name: 'nvm install lts/* && npm ci --no-audit' env: NPM_CONFIG_AUDIT: false diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 6a251d600f..218a0752a2 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -13,7 +13,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: ljharb/actions/node/install@6bc39109c48f74895ad72ec03ca0bb4e4da2fa3f + - uses: ljharb/actions/node/install@dfd9796898850cf07630d1bd4053a7c9a379e90f name: 'nvm install lts/* && npm ci --no-audit' env: NPM_CONFIG_AUDIT: false diff --git a/.github/workflows/enforce-format.yml b/.github/workflows/enforce-format.yml index 3ddce21e6a..c148d487b2 100644 --- a/.github/workflows/enforce-format.yml +++ b/.github/workflows/enforce-format.yml @@ -9,7 +9,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: ljharb/actions/node/install@6bc39109c48f74895ad72ec03ca0bb4e4da2fa3f + - uses: ljharb/actions/node/install@dfd9796898850cf07630d1bd4053a7c9a379e90f name: 'nvm install lts/* && npm ci --no-audit' env: NPM_CONFIG_AUDIT: false diff --git a/.github/workflows/ipr.yml b/.github/workflows/ipr.yml index 4844b2ddd8..3e8197335b 100644 --- a/.github/workflows/ipr.yml +++ b/.github/workflows/ipr.yml @@ -15,14 +15,14 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: ljharb/actions/node/install@6bc39109c48f74895ad72ec03ca0bb4e4da2fa3f + - uses: ljharb/actions/node/install@dfd9796898850cf07630d1bd4053a7c9a379e90f name: 'nvm install lts/* && npm ci --no-audit' env: NPM_CONFIG_AUDIT: false with: node-version: lts/* use-npm-ci: true - - run: 'npm run ipr-check' + - run: npm run ipr-check ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || 'HEAD' }} env: GH_TOKEN: ${{ secrets.GH_IPR_TOKEN }} GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }} diff --git a/.github/workflows/preview-build.yml b/.github/workflows/preview-build.yml index 6af134a8b5..98138eb4e0 100644 --- a/.github/workflows/preview-build.yml +++ b/.github/workflows/preview-build.yml @@ -9,7 +9,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: ljharb/actions/node/install@6bc39109c48f74895ad72ec03ca0bb4e4da2fa3f + - uses: ljharb/actions/node/install@dfd9796898850cf07630d1bd4053a7c9a379e90f name: 'nvm install lts/* && npm ci --no-audit' env: NPM_CONFIG_AUDIT: false diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 893d91cf29..40321d2e59 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -19,7 +19,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: ljharb/actions/node/install@6bc39109c48f74895ad72ec03ca0bb4e4da2fa3f + - uses: ljharb/actions/node/install@dfd9796898850cf07630d1bd4053a7c9a379e90f name: 'nvm install lts/* && npm ci --no-audit' env: NPM_CONFIG_AUDIT: false diff --git a/.github/workflows/spellcheck.yml b/.github/workflows/spellcheck.yml index 98ad93d03c..8f31ee653a 100644 --- a/.github/workflows/spellcheck.yml +++ b/.github/workflows/spellcheck.yml @@ -14,7 +14,7 @@ jobs: # Number of commits to fetch. 0 indicates all history for all branches and tags. # Default: 1 fetch-depth: 0 - - uses: ljharb/actions/node/install@6bc39109c48f74895ad72ec03ca0bb4e4da2fa3f + - uses: ljharb/actions/node/install@dfd9796898850cf07630d1bd4053a7c9a379e90f name: 'nvm install lts/* && npm ci --no-audit' env: NPM_CONFIG_AUDIT: false diff --git a/package.json b/package.json index a2f5de6703..81d70c2851 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "version": "1.0.0", "description": "The ECMAScript specification", "scripts": { - "ipr-check": "node scripts/check-form tc39/ecma262 HEAD --all", + "ipr-check": "node scripts/check-form tc39/ecma262 --all", "build-head": "npm run build-only -- --lint-spec --strict", "prebuild-only": "npm run clean && mkdir out && cp -R img out", "build-only": "ecmarkup --verbose spec.html --multipage out", diff --git a/scripts/check-form.js b/scripts/check-form.js index 45647ae2cb..1ee2b6957c 100644 --- a/scripts/check-form.js +++ b/scripts/check-form.js @@ -19,16 +19,25 @@ if (!key) { const sheetData = `https://sheets.googleapis.com/v4/spreadsheets/${sheetID}/values/Sheet1!A2:A?key=${key}`; -const [,, slug, branch, all] = process.argv; - -if (!slug || !branch) { - throw 'args required: slug, branch'; +const { values, positionals } = require('util').parseArgs({ + options: { all: { type: 'boolean', default: false } }, + allowPositionals: true, + allowNegative: true, + strict: true, +}); +if (positionals.length < 1 || positionals.length > 2) { + throw 'usage: node check-form.js [--all] [ref]'; } -if (typeof all !== 'undefined' && all !== '--all') { - throw '`all` arg, if provided, must be `--all`' +const [slug, ref = 'HEAD'] = positionals; +const { all } = values; + +console.debug({ slug, ref, all }); + +if (!slug || !ref) { + throw 'args required: slug, ref'; } -const sha = String(execSync(`git rev-parse ${branch}`)).trim(); +const sha = String(execSync(`git rev-parse ${ref}`)).trim(); const request = async (url, method = 'GET', postData) => { // adapted from https://medium.com/@gevorggalstyan/how-to-promisify-node-js-http-https-requests-76a5a58ed90c