-
-
Notifications
You must be signed in to change notification settings - Fork 8
58 lines (51 loc) · 1.48 KB
/
test-node.yml
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
name: test-nodejs
on:
# trigger deployment on every push to main branch
push:
paths:
- '**'
- '!LICENSE'
- '!*.md'
- '!.github/**'
- '!.vscode/**'
- '!docs/**'
# trigger deployment manually
workflow_dispatch:
jobs:
test-nodejs:
runs-on: ${{ matrix.os }}
name: Test NodeJS ${{ matrix.node_version }} on ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
node_version: ['18', '20', '21']
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
with:
# fetch all commits to get last updated time or other git log info
fetch-depth: 0
- name: Setup NodeJS ${{ matrix.node_version }}
uses: actions/setup-node@v4
with:
# choose node.js version to use
node-version: ${{ matrix.node_version }}
cache: npm
cache-dependency-path: '**/package-lock.json'
# cache node_modules
- name: Cache dependencies
uses: actions/cache@v4
id: npm-cache
with:
path: |
**/node_modules
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
# install dependencies if the cache did not hit
- name: Install dependencies
if: steps.npm-cache.outputs.cache-hit != 'true'
run: npm i
# run test
- name: Test module script
run: npm run test