-
Notifications
You must be signed in to change notification settings - Fork 1
138 lines (132 loc) · 4.03 KB
/
test_unit.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# SPDX-FileCopyrightText: 2024 Marcellino Palerme <marcellino.palerme@inrae.fr>
#
# SPDX-License-Identifier: MIT
name: Tests Unit
on:
push:
branches: '*'
permissions:
contents: write
pull-requests: write
checks: write
env:
PGPASSWORD: ep2m2
PGUSER: ep2m2
PGPORT: 5432
PGDATABASE: ep2m2db
jobs:
test:
runs-on: ubuntu-latest
services:
service-p2m2tool-api:
image: inraep2m2/service-p2m2tools-api
ports:
- 8080:8080
db:
image: postgres:latest
# Provide the password for postgres
env:
POSTGRES_PASSWORD: ep2m2
POSTGRES_DB: ep2m2db
POSTGRES_USER: ep2m2
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Get repository
uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: latest
cache: 'npm'
- name: Installation project s packages
run: npm ci
- name: Configure database
run: node ./db/init.js
- name: Test and Coverage
run: npm run test
- name: Report coverage
if: always()
uses: davelosert/vitest-coverage-report-action@v2
with:
file-coverage-mode: all
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: ⚙️ Generating coverage badges
uses: jpb06/coverage-badges-action@latest
with:
branches: '*'
badges-icon: vitest
- name: Summary Tests
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: |
./test/results/*.xml
- name: Complet report tests
uses: dorny/test-reporter@v1
if: always()
with:
reporter: "java-junit"
name: Test Unit
path: ./test/results/*.xml
- name: Extract test results
id: extract_results
run: |
node .github/workflows/extractResultsTest.js
- name: Generate Badges fail result global tests
if: steps.extract_results.outputs.successTests == 'false'
uses: jaywcjlove/generated-badges@main
with:
label: Tests
status: Fail
color: 'red'
output: badges/tests-result.svg
- name: Generate Badges pass result global tests
if: steps.extract_results.outputs.successTests == 'true'
uses: jaywcjlove/generated-badges@main
with:
label: Tests
status: Pass
color: 'green'
output: badges/tests-result.svg
- name: Generate Badges number tests
uses: jaywcjlove/generated-badges@main
with:
label: Number of tests
status: ${{ steps.extract_results.outputs.totalTests }}
color: 'black'
output: badges/tests-total.svg
- name: Generate Badges number passed tests
uses: jaywcjlove/generated-badges@main
with:
label: Passed tests
status: ${{ steps.extract_results.outputs.passedTests }}
color: 'green'
output: badges/tests-passed.svg
- name: Generate Badges number failed tests
uses: jaywcjlove/generated-badges@main
with:
label: Failed tests
status: ${{ steps.extract_results.outputs.failedTests }}
color: 'red'
output: badges/tests-failed.svg
- name: Generate Badges number todo tests
uses: jaywcjlove/generated-badges@main
with:
label: Todo tests
status: ${{ steps.extract_results.outputs.todoTests }}
color: 'yellow'
output: badges/tests-todo.svg
- name: Commit test badges
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add badges/*
git commit -m "Update test badges"
git push