-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (81 loc) · 2.98 KB
/
npm-node-qa-testing.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
---
"on":
workflow_call:
inputs:
node_versions:
description: Node versions matrix to test on
default: "['16.x', '17.x', '18.x']"
required: false
type: string
package_manager:
default: npm
description: Package manager to use. Can be 'npm' or 'bun'
type: string
format_command:
description: Format command to run. Disabled by default
default:
required: false
type: string
lint_command:
description: Lint command to run. To disable set to ''
default: npm run lint
required: false
type: string
build_command:
description: Build command to run
default: npm run build
required: false
type: string
test_command:
description: Base test command to run. To disable set to ''
default: npm run test
required: false
type: string
run_jest_coverage:
description: Run and report the coverage with jest. Uses test_command as base.
default: true
required: false
type: boolean
skip_coverage_report:
description: Skip coverage reporting for resources that can not accept comments
default: false
required: false
type: boolean
jobs:
testing:
runs-on: ubuntu-latest
strategy:
matrix:
node_version: ${{ fromJson(inputs.node_versions) }}
steps:
- uses: Beuterei/reusable-workflows/.github/workflows/environment-setup.yml@main
with:
package_manager: npm
node_version: ${{ matrix.node_version }}
dependencies_type: dev
- name: Extract the last matrix job index
env:
LAST_JOB_INDEX_OFFSET: ${{ strategy.job-total}}
run: echo LAST_JOB_INDEX="$((LAST_JOB_INDEX_OFFSET-1))" >> "$GITHUB_ENV"
- name: Check formatting
# Use strategy.job-index == env.LAST_JOB_INDEX to run this step only on the last matrix value
if: inputs.format_command != '' && strategy.job-index == env.LAST_JOB_INDEX
run: ${{ inputs.format_command }}
- name: Check linting
if: inputs.lint_command != '' && strategy.job-index == env.LAST_JOB_INDEX
run: ${{ inputs.lint_command }}
- name: Run test build
run: ${{ inputs.build_command }}
- name: Run tests
if: inputs.test_command != '' && !inputs.run_jest_coverage
run: ${{ inputs.test_command }}
- name: Run tests with coverage
if: inputs.test_command != '' && inputs.run_jest_coverage
run: ${{ inputs.test_command }} --- --ci --json --coverage --testLocationInResults --outputFile=report.json
- name: Report coverage
if: inputs.skip_coverage_report == false && inputs.test_command != '' && inputs.run_jest_coverage && strategy.job-index == env.LAST_JOB_INDEX
uses: ArtiomTr/jest-coverage-report-action@v2
with:
coverage-file: report.json
base-coverage-file: report.json
skip-step: all