-
Notifications
You must be signed in to change notification settings - Fork 47
126 lines (124 loc) · 4.09 KB
/
Copy pathunit-tests.yaml
File metadata and controls
126 lines (124 loc) · 4.09 KB
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
---
name: Tests
on:
push:
pull_request:
jobs:
test-app:
name: Unit Tests (App)
runs-on: ubuntu-latest
defaults:
run:
working-directory: app
outputs:
HAS_CC_SECRETS: ${{ steps.check-secrets.outputs.HAS_CC_SECRETS }}
timeout-minutes: 10
steps:
- name: Checkout Repository
uses: actions/checkout@v5
- name: Check CodeClimate Secrets
id: check-secrets
run: echo "HAS_CC_SECRETS=${{ secrets.CC_TEST_REPORTER_ID != '' }}" >> $GITHUB_OUTPUT
- name: Use Node.js 24
uses: actions/setup-node@v5
with:
node-version: 24
- name: Cache node modules
uses: actions/cache@v5
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
uses: actions/upload-artifact@v6
with:
name: coverage-app
path: ${{ github.workspace }}/app/coverage
- name: Monitor Coverage
if: "! github.event.pull_request.head.repo.fork"
uses: MishaKav/jest-coverage-comment@642ef024cc554a34b7082cea12c7bf63575ae151 # v1.0.36
with:
title: Coverage Report (Application)
unique-id-for-comment: app
coverage-summary-path: app/coverage/coverage-summary.json
test-frontend:
name: Unit Tests (Frontend)
runs-on: ubuntu-latest
defaults:
run:
working-directory: app/frontend
outputs:
HAS_CC_SECRETS: ${{ steps.check-secrets.outputs.HAS_CC_SECRETS }}
timeout-minutes: 10
steps:
- name: Checkout Repository
uses: actions/checkout@v5
- name: Use Node.js 24
uses: actions/setup-node@v5
with:
node-version: 24
- name: Cache node modules
uses: actions/cache@v5
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
uses: actions/upload-artifact@v6
with:
name: coverage-frontend
path: ${{ github.workspace }}/app/frontend/coverage
- name: Monitor Coverage
if: "! github.event.pull_request.head.repo.fork"
uses: MishaKav/jest-coverage-comment@642ef024cc554a34b7082cea12c7bf63575ae151 # v1.0.36
with:
title: Coverage Report (Frontend)
unique-id-for-comment: frontend
coverage-summary-path: app/frontend/coverage/coverage-summary.json
# test-coverage:
# name: Publish to Code Climate
# needs:
# - test-app
# - test-frontend
# if: needs.test-app.outputs.HAS_CC_SECRETS == 'true'
# runs-on: ubuntu-latest
# timeout-minutes: 10
# steps:
# - name: Checkout Repository
# uses: actions/checkout@v5
# - name: Restore Coverage Results
# uses: actions/download-artifact@v4
# - name: Publish code coverage
# uses: paambaati/codeclimate-action@v8
# env:
# CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
# with:
# coverageLocations: |
# ${{ github.workspace }}/**/clover.xml:clover
# prefix: ${{ github.workspace }}