-
-
Notifications
You must be signed in to change notification settings - Fork 3k
85 lines (81 loc) · 3.11 KB
/
npm-script.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
85
name: Reusable npm script runner
on:
workflow_call:
inputs:
npm-script:
description: 'npm script'
required: true
type: string
browsers:
description: 'A comma separated list of browser names to test with.'
required: false
type: string
node-versions:
description: 'A comma separated list of Node versions to test with.'
required: false
type: string
os:
description: 'A comma separated list of operating systems to test on.'
required: false
type: string
coverage:
description: 'Whether to set up coverage reporting or not'
required: false
type: boolean
permissions:
contents: read
jobs:
resolve-inputs:
runs-on: ubuntu-latest
outputs:
browsers: ${{ steps.split-browsers.outputs.splitted }}
nodeVersions: ${{ steps.split-node-versions.outputs.splitted }}
os: ${{ steps.split-os.outputs.splitted }}
steps:
- id: split-browsers
if: inputs.browsers
run: echo "splitted=$(echo '${{ inputs.browsers }}' | jq -R -c 'split(",")')" >> $GITHUB_OUTPUT
- id: split-node-versions
if: inputs.node-versions
run: echo "splitted=$(echo '${{ inputs.node-versions }}' | jq -R -c 'split(",")')" >> $GITHUB_OUTPUT
- id: split-os
if: inputs.os
run: echo "splitted=$(echo '${{ inputs.os }}' | jq -R -c 'split(",")')" >> $GITHUB_OUTPUT
script:
name: ${{ inputs.npm-script }}${{ needs.resolve-inputs.outputs.browsers && format('[{0}]', matrix.browser) }}${{ needs.resolve-inputs.outputs.nodeVersions && format(' with node.js {0}', matrix.node_version) }}${{ needs.resolve-inputs.outputs.os && format(' on {0}', matrix.os) }}
runs-on: ${{ matrix.os }}
timeout-minutes: 20
needs:
- resolve-inputs
strategy:
fail-fast: false
matrix:
# The 22.11.0 is instead of "lts/*" per https://github.com/mochajs/mocha/issues/5278
node_version: ${{ fromJson(needs.resolve-inputs.outputs.nodeVersions || '["22.11.0"]') }}
os: ${{ fromJson(needs.resolve-inputs.outputs.os || '["ubuntu-latest"]') }}
browser: ${{ fromJson(needs.resolve-inputs.outputs.browsers || '[""]') }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node_version }}
cache: 'npm'
- run: npm ci --ignore-scripts
- run: npm run ${{ inputs.npm-script }}
env:
BROWSER: ${{ matrix.browser }}
COVERAGE: ${{ inputs.coverage && '1'}}
NODE_OPTIONS: '--trace-warnings'
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
- name: Generate coverage report
if: always() && inputs.coverage
run: npm run test-coverage-generate
- name: Coveralls Parallel
if: always() && inputs.coverage
uses: coverallsapp/github-action@v2
with:
flag-name: run-${{ inputs.npm-script }}-${{ join(matrix.*, '-') }}
parallel: true