-
-
Notifications
You must be signed in to change notification settings - Fork 1
84 lines (77 loc) · 2.73 KB
/
lint.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
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
name: "Reusable: Linting"
on:
workflow_call:
inputs:
os:
description: 'A comma separated list of operating systems to test on.'
required: false
default: 'ubuntu-latest'
type: string
node-versions:
description: 'A comma separated list of Node versions to test with.'
required: false
default: 'lts/*'
type: string
lockfile:
description: 'Whether to expect a lockfile or not'
required: false
default: false
type: boolean
permissions:
contents: read
jobs:
resolve_inputs:
name: Resolving inputs
runs-on: ubuntu-latest
outputs:
os: ${{ steps.split-os.outputs.splitted }}
nodeVersions: ${{ steps.split-node-versions.outputs.splitted }}
steps:
- id: split-os
run: echo "splitted=$(echo '${{ inputs.os }}' | jq -R -c 'split(",")')" >> $GITHUB_OUTPUT
- id: split-node-versions
run: echo "splitted=$(echo '${{ inputs.node-versions }}' | jq -R -c 'split(",")')" >> $GITHUB_OUTPUT
lint:
name: Node ${{ matrix.node_version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs:
- resolve_inputs
strategy:
fail-fast: false
matrix:
node_version: ${{ fromJson(needs.resolve_inputs.outputs.nodeVersions) }}
os: ${{ fromJson(needs.resolve_inputs.outputs.os) }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
show-progress: false
- name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node_version }}
registry-url: 'https://registry.npmjs.org'
- name: Determine npm cache directory windows
id: npm-cache-dir-windows
if: runner.os == 'Windows'
run: echo "dir=$(npm config get cache)" >> $env:GITHUB_OUTPUT
- name: Determine npm cache directory non-windows
id: npm-cache-dir
if: runner.os != 'Windows'
run: echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
with:
path: ${{ steps.npm-cache-dir-windows.outputs.dir || steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json', '**/package.json') }}
restore-keys: |
${{ runner.os }}-node-
- if: inputs.lockfile == false
run: npm install --ignore-scripts --no-fund --no-audit
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- if: inputs.lockfile == true
run: npm ci --ignore-scripts --no-fund --no-audit
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: npm rebuild && npm run prepare --if-present
- run: npm run check