Repository navigation
101 lines (84 loc) · 3.64 KB
/
Copy pathnodejs.yml
File metadata and controls
101 lines (84 loc) · 3.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: Node.js ⬢ CI
run-name: Node.js ⬢ CI
on:
push:
branches: [master]
pull_request:
branches: [master]
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
matrix:
node-version: [24.x, 26.x]
name: Node.js ${{ matrix.node-version }} 🚀
steps:
- name: Checkout 📖 ## clone out source code in the action
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Install infra build dependencies 🛠️
run: sh .etc/bin/ci_install
# Not needed: corepack is no longer bundled with Node.js 25+, so this step
# depended on the runner's default Node instead of the matrix version.
# - name: Enable corepack and pnpm ⚙️
# run: |
# corepack enable
# # `corepack prepare pnpm@latest` overrode the pinned `packageManager`
# # in package.json (pnpm@12.15.0), so CI used a different pnpm than local.
# pnpm config set store-dir ~/.pnpm-store
- name: Install pnpm ⚙️ # version read from packageManager in package.json
uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
# Not needed: the store path now comes from `pnpm store path` below, so
# pinning it with `pnpm config set store-dir` duplicates that value.
# - name: Set pnpm store dir ⚙️
# run: pnpm config set store-dir ~/.pnpm-store
- name: Setup Node.js ⚙️ ${{ matrix.node-version }} # setup node
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: ${{ matrix.node-version }}
# node-version-file: ".nvmrc"
# Not needed: the "Cache dependencies" step below caches the same
# ~/.pnpm-store path. Keeping both doubles restore/save work.
# cache: "pnpm"
# Needed, not just print: the step writes `path` to $GITHUB_OUTPUT, and the
# cache step reads it from `steps.pnpm-store.outputs.path`.
- name: Resolve pnpm store path ⚙️
id: pnpm-store
run: echo "path=$(pnpm store path --silent)" >> "$GITHUB_OUTPUT"
- name: Cache dependencies 🔒
id: cache-pnpm-store
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ steps.pnpm-store.outputs.path }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('package.json', 'pnpm-workspace.yaml') }}-${{ hashFiles('pnpm-lock.yaml') }}-${{ hashFiles('.github/workflows/nodejs.yml') }} #dynamic cache
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies 📦
# Keep: the cache restores only the pnpm store, not node_modules, so install must always run.
# if: steps.cache-pnpm-store.outputs.cache-hit != 'true'
run: |
pnpm install --frozen-lockfile
# Lint does not depend on the Node version, so it runs once (26.x), like typecheck.
- name: Lint code 🧹
if: matrix.node-version == '26.x'
run: |
node --run lint
# build and ensure file exists
- name: Build
run: |
node --run build && find ./bin/index.js
# Typecheck does not depend on the Node version, so it runs once (26.x).
- name: Typecheck code 🔎
if: matrix.node-version == '26.x'
run: |
node --run typecheck
- name: Run tests 🧪
run: |
node --run test