-
Notifications
You must be signed in to change notification settings - Fork 5
123 lines (105 loc) · 3.26 KB
/
test.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#####################################
## Reusable workflow tests ##
#####################################
name: Tests
# Make the workflow reusable
on:
workflow_call:
inputs:
registryUrl:
default: 'https://registry.npmjs.org'
description: 'The npm token if needed'
required: false
type: string
codecov:
default: false
description: 'Run the test with codecov or not'
required: false
type: boolean
build:
default: true
description: 'Run the build step'
required: false
type: boolean
lint:
default: true
description: 'Run the lint step'
required: false
type: boolean
NODE_OPTIONS:
default: ''
description: 'Node options to add to the env'
required: false
type: string
secrets:
NPM_TOKEN:
description: 'The npm token if needed'
required: false
CODECOV_TOKEN:
description: 'The codecov token if needed'
required: false
NX_CLOUD_ACCESS_TOKEN:
description: 'A Nx cloud access token'
required: false
jobs:
tests:
name: Build, Lint and Tests
# Our code will run on node 16 and Linux
strategy:
matrix:
node: [16.x]
os: [ubuntu-20.04]
runs-on: ['${{ matrix.os }}']
steps:
# First we checkout the code
- uses: actions/checkout@v2
with:
fetch-depth: 0
persist-credentials: false
- name: Install dependencies and generate files
uses: tractr/traxion/.github/actions/setup@main
with:
registryUrl: ${{ inputs.registryUrl }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# Run the build
- name: Run Affected Build
if: ${{ inputs.build }}
shell: bash
run: npx nx affected:build --base=remotes/origin/main
env:
NODE_OPTIONS: ${{ inputs.NODE_OPTIONS }}
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
# Run the lint
- name: Run Affected Lint
if: ${{ inputs.lint }}
shell: bash
run: npx nx affected:lint --base=remotes/origin/main
env:
NODE_OPTIONS: ${{ inputs.NODE_OPTIONS }}
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
# We only run the affected test
- name: Run Affected Tests
if: ${{ !inputs.codecov }}
shell: bash
run: npx nx affected:test --base=remotes/origin/main
env:
NODE_OPTIONS: ${{ inputs.NODE_OPTIONS }}
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
# Run the tests and the coverage
- name: Run Tests with Coverage
shell: bash
if: ${{ inputs.codecov }}
run: npx nx run-many --target test --all --codeCoverage
env:
NODE_OPTIONS: ${{ inputs.NODE_OPTIONS }}
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
if: ${{ inputs.codecov }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ./coverage/
fail_ci_if_error: true
flags: unittests
name: codecov-umbrella
verbose: true