-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
81 lines (74 loc) · 2.93 KB
/
action.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
name: Run jest through yarn and upload report
description: |
Run a yarn task expecting jest reports and coverage data to be produced. The reports will follow naming conventions
detailed by our ADRs (https://confluence.equisoft.com/display/HRMI/ADR).
Report named `build/jest/junit.xml` with `build/jest/coverage/clover.xml` are expected under all circumstances.
Errors will be annotated on pull requests.
inputs:
enable-annotations:
description: |
Annotate files with jest errors, in which case a `build/jest/junit.xml` file is expected.
This is the default behavior for projects that branched off webapp-boilerplate.
Defaults to `true`.
required: true
default: "true"
report-name:
description: The name of the result report. It must follow the convention detailed by our ADRs.
required: true
default: typescript-test-results.junit.xml
coverage-report-name:
description: The name of the coverage report. It must follow the convention detailed by our ADRs.
required: true
default: typescript-test-coverage.clover.xml
report-retention-days:
description: Duration in days to preserve reports. Defaults to 5.
required: true
default: "5"
task-name:
description: The task name. Defaults to "eslint:ci".
required: true
default: test:ci
working-directory:
description: Relative path under $GITHUB_WORKSPACE where the project is located.
required: false
default: "."
max-memory:
description: Max old space size (in megabytes)
required: false
default: 4096
runs:
using: composite
steps:
- name: Action context
shell: bash
id: context
run: |
JUNIT_REPORT=false
if [ -f ${{ inputs.working-directory }}/build/jest/junit.xml ]; then
JUNIT_REPORT=true
fi
echo "has-junit-report=${JUNIT_REPORT}" >> $GITHUB_OUTPUT
echo "working-directory=$(realpath ${{ inputs.working-directory }})" >> $GITHUB_OUTPUT
- name: Run Jest
shell: bash
working-directory: ${{ steps.context.outputs.working-directory }}
env:
NODE_OPTIONS: "--max-old-space-size=${{ inputs.max-memory }}"
JEST_ENABLE_ANNOTATIONS: ${{ inputs.enable-annotations }}
run: yarn ${{ inputs.task-name }}
- name: Upload report
uses: actions/upload-artifact@v4
if: "!cancelled() && steps.context.outputs.has-junit-report == 'true'"
with:
name: ${{ inputs.report-name }}
retention-days: ${{ inputs.report-retention-days }}
if-no-files-found: error
path: ${{ steps.context.outputs.working-directory }}/build/jest/junit.xml
- name: Upload coverage report
uses: actions/upload-artifact@v4
if: "!cancelled()"
with:
name: ${{ inputs.coverage-report-name }}
retention-days: ${{ inputs.report-retention-days }}
if-no-files-found: error
path: ${{ steps.context.outputs.working-directory }}/build/jest/coverage/clover.xml