This repository has been archived by the owner on Feb 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
134 lines (134 loc) · 3.94 KB
/
unit-tests.yaml
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
124
125
126
127
128
129
130
131
132
133
134
---
name: Tests
on:
- push
- pull_request
jobs:
test-app:
runs-on: ubuntu-latest
defaults:
run:
working-directory: app
timeout-minutes: 10
strategy:
fail-fast: true
matrix:
node-version:
- '12.x'
- '14.x'
- '16.x'
steps:
- name: Checkout Repository
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Cache node modules
uses: actions/cache@v2
id: cache-app
env:
cache-name: cache-node-modules
with:
path: ${{ github.workspace }}/app/node_modules
key: ${{ runner.os }}-app-${{ env.cache-name }}-${{ hashFiles('**/app/package-lock.json') }}
restore-keys: |
${{ runner.os }}-app-${{ env.cache-name }}-
${{ runner.os }}-app-
${{ runner.os }}-
- name: Install dependencies
if: steps.cache-app.outputs.cache-hit != 'true'
run: npm ci
- name: Test
run: npm run test
env:
CI: true
- name: Save Coverage Results
if: matrix.node-version == '16.x'
uses: actions/upload-artifact@v2
with:
name: coverage-app
path: ${{ github.workspace }}/app/coverage
retention-days: 1
test-frontend:
runs-on: ubuntu-latest
defaults:
run:
working-directory: app/frontend
timeout-minutes: 10
strategy:
fail-fast: true
matrix:
node-version:
- '12.x'
- '14.x'
- '16.x'
steps:
- name: Checkout Repository
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Cache node modules
uses: actions/cache@v2
id: cache-frontend
env:
cache-name: cache-node-modules
with:
path: ${{ github.workspace }}/app/frontend/node_modules
key: ${{ runner.os }}-frontend-${{ env.cache-name }}-${{ hashFiles('**/frontend/package-lock.json') }}
restore-keys: |
${{ runner.os }}-frontend-${{ env.cache-name }}-
${{ runner.os }}-frontend-
${{ runner.os }}-
- name: Install dependencies
if: steps.cache-frontend.outputs.cache-hit != 'true'
run: npm ci
- name: Test
run: npm run test
env:
CI: true
- name: Save Coverage Results
if: matrix.node-version == '16.x'
uses: actions/upload-artifact@v2
with:
name: coverage-frontend
path: ${{ github.workspace }}/app/frontend/coverage
retention-days: 1
test-coverage:
needs:
- test-app
- test-frontend
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Check Workflow Secrets
id: check-secrets
run: |
unset HAS_SECRETS
if [ -n "$CC_TEST_REPORTER_ID" ]; then HAS_SECRETS='true'; fi
echo ::set-output name=HAS_SECRETS::${HAS_SECRETS}
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
- name: Checkout Repository
if: steps.check-secrets.outputs.HAS_SECRETS
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Restore Coverage Results
if: steps.check-secrets.outputs.HAS_SECRETS
uses: actions/download-artifact@v2
- name: Publish code coverage
if: steps.check-secrets.outputs.HAS_SECRETS
uses: paambaati/[email protected]
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
coverageLocations: |
${{ github.workspace }}/**/lcov.info:lcov
prefix: ${{ github.workplace }}