-
Notifications
You must be signed in to change notification settings - Fork 45
75 lines (72 loc) · 2.52 KB
/
jest.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
# This workflow runs jest unit tests with coverage and uploads the coverage
# report to codecov. The coverage report is also archived in the workflow.
name: 'Jest: Unit Tests'
on:
workflow_dispatch:
inputs:
coverage:
description: 'Enable code coverage'
required: false
type: boolean
default: false
workflow_call:
inputs:
ref:
description: 'Github branch ref to checkout and run tests on.'
required: false
type: string
coverage:
description: 'Enable code coverage'
required: false
type: boolean
default: false
jobs:
run:
name: Run Jest
runs-on: ubuntu-latest
timeout-minutes: 30
defaults:
run:
shell: bash
env:
COVERAGE: ${{ inputs.coverage }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.ref }}
- uses: actions/setup-node@v4
with:
node-version: 22.11.0 # See package.json for the stable node version that works with our testing. Do not change this unless you know what you are doing as some node versions do not play nicely with our testing server.
- name: Install project dependencies
run: npm ci
- name: Run unit tests
run: npm run test -- --coverage
- name: Find pull request
id: pull-request-target
if: ${{ inputs.coverage }}
uses: ./.github/actions/find-pull-request
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload pr code coverage
if: ${{ inputs.coverage && steps.pull-request-target.outputs.results }}
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
override_commit: ${{ fromJSON(steps.pull-request-target.outputs.results).head_sha }}
override_branch: refs/pull/${{ fromJSON(steps.pull-request-target.outputs.results).pr_number }}/merge
override_pr: ${{ fromJSON(steps.pull-request-target.outputs.results).pr_number }}
flags: unit-tests
verbose: true
- name: Upload branch code coverage
if: ${{ inputs.coverage && !steps.pull-request-target.outputs.results }}
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: unit-tests
verbose: true
- name: Archive code coverage results
if: ${{ inputs.coverage }}
uses: actions/upload-artifact@v4
with:
name: jest-code-coverage-report
path: coverage/