Skip to content

Commit

Permalink
ci: use node v20 for most jobs (#29959)
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice authored Jul 1, 2024
1 parent c5eee75 commit 6d01a1d
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 37 deletions.
77 changes: 53 additions & 24 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ concurrency:

env:
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
NODE_VERSION: 18
NODE_VERSION_TEST: 18
NODE_VERSION_BUILD: 20
DRY_RUN: true
TEST_LEGACY_DECRYPTION: true
SPARSE_CHECKOUT: |-
Expand Down Expand Up @@ -105,13 +106,13 @@ jobs:
with:
repo: ${{ github.event.repository.full_name }}
token: ${{ github.token }}
node-version: ${{ env.NODE_VERSION }}
node-version: ${{ env.NODE_VERSION_TEST }}

- name: Prefetch modules for `ubuntu-latest`
- name: Prefetch test modules for `ubuntu-latest`
id: setup-node
uses: ./.github/actions/setup-node
with:
node-version: ${{ env.NODE_VERSION }}
node-version: ${{ env.NODE_VERSION_TEST }}
os: ${{ runner.os }}
save-cache: true

Expand All @@ -124,6 +125,27 @@ jobs:
run: |
echo "$(pnpm -s schedule-test-shards)" >> "$GITHUB_OUTPUT"
setup-build:
runs-on: ubuntu-latest

outputs:
node-version: ${{ env.NODE_VERSION_BUILD }}

steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
filter: blob:none # we don't need all blobs
sparse-checkout: ${{ env.SPARSE_CHECKOUT }}
show-progress: false

- name: Prefetch build modules for `ubuntu-latest`
uses: ./.github/actions/setup-node
with:
node-version: ${{ env.NODE_VERSION_BUILD }}
os: ${{ runner.os }}
save-cache: true

prefetch:
needs: [setup]

Expand All @@ -142,7 +164,6 @@ jobs:
strategy:
matrix:
os: ${{ fromJSON(needs.setup.outputs.os-matrix-prefetch) }}
node-version: [18]

runs-on: ${{ matrix.os }}

Expand All @@ -161,12 +182,13 @@ jobs:
if: needs.setup.outputs.os-matrix-is-full && runner.os != 'Linux'
uses: ./.github/actions/setup-node
with:
node-version: ${{ env.NODE_VERSION }}
node-version: ${{ env.NODE_VERSION_TEST }}
os: ${{ runner.os }}
save-cache: true

lint-eslint:
needs: [setup]
needs:
- setup-build
runs-on: ubuntu-latest
timeout-minutes: 15

Expand All @@ -182,7 +204,7 @@ jobs:
- name: Setup Node.js
uses: ./.github/actions/setup-node
with:
node-version: ${{ env.NODE_VERSION }}
node-version: ${{ needs.setup-build.outputs.node-version }}
os: ${{ runner.os }}

- name: Restore eslint cache
Expand Down Expand Up @@ -211,7 +233,8 @@ jobs:
key: eslint-main-cache

lint-prettier:
needs: [setup]
needs:
- setup-build
runs-on: ubuntu-latest
timeout-minutes: 7

Expand All @@ -227,7 +250,7 @@ jobs:
- name: Setup Node.js
uses: ./.github/actions/setup-node
with:
node-version: ${{ env.NODE_VERSION }}
node-version: ${{ needs.setup-build.outputs.node-version }}
os: ${{ runner.os }}

- name: Restore prettier cache
Expand Down Expand Up @@ -256,7 +279,8 @@ jobs:
key: prettier-main-cache

lint-docs:
needs: [setup]
needs:
- setup-build
runs-on: ubuntu-latest
timeout-minutes: 7

Expand All @@ -269,7 +293,7 @@ jobs:
- name: Setup Node.js
uses: ./.github/actions/setup-node
with:
node-version: ${{ env.NODE_VERSION }}
node-version: ${{ needs.setup-build.outputs.node-version }}
os: ${{ runner.os }}

- name: Lint markdown
Expand All @@ -285,7 +309,8 @@ jobs:
run: pnpm markdown-lint

lint-other:
needs: [setup]
needs:
- setup-build
runs-on: ubuntu-latest
timeout-minutes: 7

Expand All @@ -298,7 +323,7 @@ jobs:
- name: Setup Node.js
uses: ./.github/actions/setup-node
with:
node-version: ${{ env.NODE_VERSION }}
node-version: ${{ needs.setup-build.outputs.node-version }}
os: ${{ runner.os }}

- name: Type check
Expand Down Expand Up @@ -337,7 +362,7 @@ jobs:
- name: Setup Node.js
uses: ./.github/actions/setup-node
with:
node-version: ${{ env.NODE_VERSION }}
node-version: ${{ env.NODE_VERSION_TEST }}
os: ${{ runner.os }}

- name: Cache jest
Expand All @@ -348,7 +373,7 @@ jobs:
jest-cache-${{
runner.os
}}-${{
env.NODE_VERSION
env.NODE_VERSION_TEST
}}-${{
hashFiles('pnpm-lock.yaml')
}}-${{
Expand Down Expand Up @@ -416,6 +441,7 @@ jobs:
coverage-threshold:
needs:
- test
- setup-build
runs-on: ubuntu-latest
timeout-minutes: 3
if: (success() || failure()) && github.event.pull_request.draft != true
Expand All @@ -430,7 +456,7 @@ jobs:
- name: Setup Node.js
uses: ./.github/actions/setup-node
with:
node-version: ${{ env.NODE_VERSION }}
node-version: ${{ needs.setup-build.outputs.node-version }}
os: ${{ runner.os }}

- name: Download coverage reports
Expand Down Expand Up @@ -505,7 +531,8 @@ jobs:
run: exit 1

build:
needs: setup
needs:
- setup-build
runs-on: ubuntu-latest
timeout-minutes: 15
if: github.event.pull_request.draft != true
Expand All @@ -518,7 +545,7 @@ jobs:
- name: Setup Node.js
uses: ./.github/actions/setup-node
with:
node-version: ${{ env.NODE_VERSION }}
node-version: ${{ needs.setup-build.outputs.node-version }}
os: ${{ runner.os }}

- name: Build
Expand All @@ -539,7 +566,9 @@ jobs:
path: renovate-0.0.0-semantic-release.tgz

build-docs:
needs: [lint-docs]
needs:
- lint-docs
- setup-build
runs-on: ubuntu-latest
timeout-minutes: 5
if: github.event.pull_request.draft != true
Expand All @@ -552,7 +581,7 @@ jobs:
- name: Setup Node.js
uses: ./.github/actions/setup-node
with:
node-version: ${{ env.NODE_VERSION }}
node-version: ${{ needs.setup-build.outputs.node-version }}
os: ${{ runner.os }}

- name: Build
Expand Down Expand Up @@ -588,7 +617,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: ${{ env.NODE_VERSION }}
node-version: ${{ env.NODE_VERSION_TEST }}

- name: Download package
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
Expand All @@ -603,7 +632,7 @@ jobs:

release:
needs:
- setup
- setup-build
- lint-eslint
- lint-prettier
- lint-docs
Expand Down Expand Up @@ -639,7 +668,7 @@ jobs:
- name: Setup Node.js
uses: ./.github/actions/setup-node
with:
node-version: ${{ env.NODE_VERSION }}
node-version: ${{ needs.setup-build.outputs.node-version }}
os: ${{ runner.os }}

- uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 # v3.5.0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
workflow_dispatch:

env:
NODE_VERSION: 18
NODE_VERSION: 20

permissions:
contents: read
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"prepare": "run-s 'prepare:*'",
"prepare:husky": "husky",
"prepare:generate": "run-s 'generate:*'",
"prepare:re2": "node tools/check-re2.mjs",
"prepare:deps": "node tools/prepare-deps.mjs",
"prestart": "run-s 'generate:*'",
"pretest": "run-s 'generate:*'",
"prettier": "prettier --cache --check '**/*.{ts,js,mjs,json,md,yml}'",
Expand Down
11 changes: 0 additions & 11 deletions tools/check-re2.mjs

This file was deleted.

65 changes: 65 additions & 0 deletions tools/prepare-deps.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { execSync } from 'child_process';

function testRe2() {
execSync(
`node -e "try{require('re2')('.*').exec('test')}catch(e){console.error(e);if(e.code === 'ERR_DLOPEN_FAILED' && e.message.includes('NODE_MODULE_VERSION')) process.exit(1); else process.exit(-1)}"`,
{ stdio: 'inherit' },
);
console.log(`Ok.`);
}

function testSqlite() {
execSync(
`node -e "try{new require('better-sqlite3')(':memory:')}catch(e){console.error(e);if(e.code === 'ERR_DLOPEN_FAILED' && e.message.includes('NODE_MODULE_VERSION')) process.exit(1); else process.exit(-1)}"`,
{ stdio: 'inherit' },
);
console.log(`Ok.`);
}

(() => {
console.log('Checking re2 ... ');
try {
testRe2();
} catch (e) {
console.error(`Failed.\n${e}`);
try {
if (e.status === 1) {
console.log(`Retry re2 install ...`);
execSync('pnpm run install', {
stdio: 'inherit',
cwd: `${process.cwd()}/node_modules/re2`,
});
testRe2();
return;
}
} catch (e1) {
console.error(`Retry failed.\n${e1}`);
}

process.exit(1);
}
})();

(() => {
console.log('Checking better-sqlite3 ... ');
try {
testSqlite();
} catch (e) {
console.error(`Failed.\n${e}`);
try {
if (e.status === 1) {
console.log(`Retry better-sqlite3 install ...`);
execSync('pnpm run install', {
stdio: 'inherit',
cwd: `${process.cwd()}/node_modules/better-sqlite3`,
});
testSqlite();
return;
}
} catch (e1) {
console.error(`Retry failed.\n${e1}`);
}

process.exit(1);
}
})();

0 comments on commit 6d01a1d

Please sign in to comment.