-
Notifications
You must be signed in to change notification settings - Fork 3
46 lines (36 loc) · 1.21 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
name: Run Tests
env:
NPMRC: ${{ secrets.NPMRC }}
on:
pull_request_target:
types: [opened, synchronize, reopened]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Change directory to Angular app
run: cd client/wfprev-war/src/main/angular
# Use the NPMRC secret to set up npm authentication
- name: Add .npmrc file
run: echo -e $NPMRC > ~/.npmrc
# Install dependencies
- run: npm install
working-directory: client/wfprev-war/src/main/angular
# Run unit tests and generate code coverage
- run: npm run test -- --watch=false --code-coverage
# Ensure coverage meets the required threshold
- name: Check code coverage
run: |
if grep -q '"statements": 8[0-9]' ../../client/wfprev-war/src/main/angular/coverage/wfprev/coverage-summary.json; then
echo "Test passed";
else
echo "Code coverage is less than 80%! Exiting...";
exit 1;