Skip to content
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

feat: support node v22 #662

Merged
merged 1 commit into from
Nov 12, 2024
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
69 changes: 69 additions & 0 deletions .github/actions/setup-node/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: 'Setup Node.js'
description: 'Setup Node and install dependencies using cache'
inputs:
node-version:
description: Set a specific node version instead of the default from `.node-version` file.
required: false
save-cache:
description: 'Save cache when needed'
required: false
default: 'false'

runs:
using: 'composite'

steps:
- name: ⚙️ Calculate `CACHE_KEY`
shell: bash
run: |
if [[ -z '${{ inputs.node-version }}' ]]; then
node_major=$(grep -E -o '^[0-9]+' .node-version)
else
node_major=$(echo '${{ inputs.node-version }}' | grep -E -o '^[0-9]+')
fi
echo "CACHE_KEY=node_modules-v${node_major}-${{
hashFiles('.node-version', 'pnpm-lock.yaml')
}}" >> "$GITHUB_ENV"

- name: ♻️ Restore `node_modules`
uses: actions/cache/restore@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
id: node-modules-restore
with:
path: node_modules
key: ${{ env.CACHE_KEY }}
enableCrossOsArchive: true

- name: Calculate `CACHE_HIT`
shell: bash
run: |
echo 'CACHE_HIT=${{
(steps.node-modules-restore.outputs.cache-hit == 'true') && 'true' || ''
}}' >> "$GITHUB_ENV"

- name: ⚙️ Setup pnpm
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
with:
standalone: true

- name: ⚙️ Setup Node.js ${{ inputs.node-version }}
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version-file: ${{ inputs.node-version == '' && '.node-version' || inputs.node-version }}
node-version: ${{ inputs.node-version }}
cache: ${{ env.CACHE_HIT != 'true' && 'pnpm' || '' }}

- name: 📥 Install dependencies
if: env.CACHE_HIT != 'true'
shell: bash
run: pnpm install --frozen-lockfile
env:
# Other environment variables
HUSKY: '0' # By default do not run HUSKY install

- name: ♻️ Write `node_modules` cache
if: inputs.save-cache == 'true' && env.CACHE_HIT != 'true'
uses: actions/cache/save@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
with:
path: node_modules
key: ${{ env.CACHE_KEY }}
enableCrossOsArchive: true
71 changes: 34 additions & 37 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,29 @@ concurrency:
cancel-in-progress: ${{ github.ref_name != 'main' }}

env:
GIT_EMAIL: bot+pep440@renovateapp.com
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
NODE_VERSION: 20 # needs to be in sync with other versions below
DRY_RUN: true

permissions:
contents: read

jobs:
prepare:
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
show-progress: false

- name: 📥 Setup Node.js
uses: ./.github/actions/setup-node
with:
save-cache: true
test:
needs:
- prepare
name: ${{ matrix.node-version == 20 && format('test ({0})', matrix.os) || format('test ({0}, node-{1})', matrix.os, matrix.node-version) }}
runs-on: ubuntu-latest

Expand All @@ -37,30 +50,26 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node-version: [18, 20]
node-version: [18, 20, 22]
# exclude:
# - os: windows-latest
# node-version: 12

env:
coverage: ${{ matrix.os == 'ubuntu-latest' && matrix.node-version == 20 }}
NODE_VERSION: ${{ matrix.node-version }}
coverage: ${{ matrix.os == 'ubuntu-latest' && matrix.node-version == 22 }}

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 2
fetch-depth: 10 # required for coverage
show-progress: false
filter: blob:none # we don't need all blobs

- name: Enable corepack
run: corepack enable

- name: Set up Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
- name: 📥 Setup Node.js
uses: ./.github/actions/setup-node
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
node-version: ${{ matrix.node-version }}
save-cache: true

- name: Init platform
shell: bash
Expand All @@ -70,9 +79,6 @@ jobs:
echo 'Node $(node --version)'
echo 'pnpm $(pnpm --version)'

- name: Installing dependencies
run: pnpm install

- name: Run tests
run: pnpm jest --maxWorkers=2 --ci --coverage ${{ env.coverage }} --logHeapUsage

Expand All @@ -90,6 +96,8 @@ jobs:
if: env.coverage == 'true'

lint:
needs:
- prepare
runs-on: ubuntu-latest

# lint shouldn't need more than 10 min
Expand All @@ -98,18 +106,10 @@ jobs:
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 2
show-progress: false
filter: blob:none # we don't need all blobs

- name: Enable corepack
run: corepack enable

- name: Set up Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
- name: 📥 Setup Node.js
uses: ./.github/actions/setup-node

- name: Init platform
run: |
Expand All @@ -131,7 +131,9 @@ jobs:
# run: pnpm type-check

release:
needs: [lint, test]
needs:
- lint
- test
runs-on: ubuntu-latest

# tests shouldn't need more time
Expand All @@ -149,21 +151,16 @@ jobs:
show-progress: false
filter: blob:none # we don't need all blobs

- name: Enable corepack
run: corepack enable

- name: Set up Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
- name: 📥 Setup Node.js
uses: ./.github/actions/setup-node

- name: Init platform
run: |
git config --global core.autocrlf false
git config --global core.symlinks true
git config --global user.email ${GIT_EMAIL}
git config --global user.name 'Renovate Bot'
# Use github action user for the commit
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"

- name: Check dry run
run: |
Expand Down
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
22.11.0
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
},
"packageManager": "pnpm@8.15.9",
"engines": {
"node": "^18.12.0 || >= 20.0.0",
"node": "^18.12.0 || ^20.0.0 || ^22.11.0",
"pnpm": "^8.6.11"
}
}
Loading