-
Notifications
You must be signed in to change notification settings - Fork 2
58 lines (48 loc) · 1.44 KB
/
run-tests.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: Run Tests
on:
workflow_call:
push:
paths:
- '**.js'
- '**.json'
- '.github/workflows/run-tests.yml'
pull_request:
paths:
- '**.js'
- '**.json'
- '.github/workflows/run-tests.yml'
jobs:
tests:
name: Run Tests with Node.js ${{ matrix.node }}
runs-on: ubuntu-latest
strategy:
matrix:
node: [ lts/*, latest, 16, 18, 20 ]
steps:
# https://github.com/actions/cache/blob/main/examples.md#node---npm
- name: Get npm cache directory
id: npm-cache-dir
shell: bash
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
# https://github.com/actions/cache/releases
- name: Use cache for npm
uses: actions/[email protected]
id: npm-cache
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: npm-${{ hashFiles('package.json') }}
restore-keys: npm-
# https://github.com/actions/checkout/releases
- name: Checkout
uses: actions/[email protected]
- name: Build package-lock
run: npm i --package-lock-only
# https://github.com/actions/setup-node/releases
- name: Setup Node.js
uses: actions/[email protected]
with:
node-version: ${{ matrix.node }}
- name: Clean & Install Deps
run: npm ci
- name: Run Tests
run: npm test