generated from bcgov/quickstart-openshift
-
Notifications
You must be signed in to change notification settings - Fork 2
67 lines (60 loc) · 1.82 KB
/
_code-cov.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
name: Code Coverage
on:
workflow_call:
inputs:
component:
type: string
required: true
description: Component (backend, frontend), also used as path
lcov_file:
type: string
required: true
description: Relative path to lcov.info
test_cmd:
type: string
required: true
description: Command to run unit tests
secrets:
gh_token:
required: true
description: Default github token (secrets.GITHUB_TOKEN)
jobs:
test:
name: ${{ inputs.component }}
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Add Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'
- name: Get npm cache directory
id: npm-cache-dir
run: |
echo "::set-output name=dir::$(npm config get cache)"
- name: Cache npm cache directory
uses: actions/cache@v3
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Cache coverage for static analysis
uses: actions/cache@v3
with:
path: ${{ inputs.component }}/coverage
key: coverage-${{ inputs.component }}-${{ github.run_number }}
restore-keys: |
coverage-${{ inputs.component }}-
- name: Tests
run: |
cd ${{ inputs.component }}
npm ci
${{ inputs.test_cmd }}
- name: Report code coverage
uses: romeovs/[email protected]
with:
title: ${{ inputs.component }} coverage report
delete-old-comments: true
github-token: ${{ secrets.gh_token }}
lcov-file: /${{ inputs.lcov_file }}