-
Notifications
You must be signed in to change notification settings - Fork 11
170 lines (138 loc) · 5.24 KB
/
test-pr.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: CodeClimate-Checks
on:
pull_request:
types: [opened, reopened, synchronize, closed]
branches-ignore:
- 'test'
- 'master'
workflow_dispatch:
jobs:
collect-frontend-coverage:
defaults:
run:
working-directory: ./prime-angular-frontend
if: github.ref != 'develop' || (github.ref == 'develop' && github.event.pull_request.merged == true)
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
steps:
- uses: actions/checkout@v1
- name: set-date
run: |
echo "GIT_COMMITTED_AT=$(date +%s)" >> ${GITHUB_ENV}
# - name: Cache node modules.
# uses: actions/cache@v2
# with:
# path: ~/.npm
# key: ${{ runner.os }}-node-${{ hashFiles('**/prime-angular-frontend/yarn.lock') }}
# restore-keys: |
# ${{ runner.os }}-node-
- name: Node ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
cache-dependency-path: prime-angular-frontend/yarn.lock
- name: install yarn
run: npm install -g yarn
- uses: amancevice/setup-code-climate@v0
with:
cc_test_reporter_id: ${{ secrets.CC_TEST_REPORTER_ID }}
cc_test_reporter_version: latest # optional
- run: cc-test-reporter before-build
- name: yarn and yarn run test
run: |
yarn
yarn run test
- name: Collect Frontend Report
run: |
cc-test-reporter format-coverage -t lcov -o coverage/frontend.json coverage/lcov.info
- name: Create frontend coverage file artifact
uses: actions/upload-artifact@v4
with:
name: frontend
path: ./prime-angular-frontend/coverage/frontend.json
retention-days: 1
collect-backend-coverage:
defaults:
run:
working-directory: ./prime-dotnet-webapi-tests
if: github.ref != 'develop' || (github.ref == 'develop' && github.event.pull_request.merged == true)
runs-on: ubuntu-latest
strategy:
matrix:
dotnet-version: ['8.0']
steps:
- uses: actions/checkout@v2
- name: set-date
run: |
echo "GIT_COMMITTED_AT=$(date +%s)" >> ${GITHUB_ENV}
- name: Setup .NET Core 8.0
uses: actions/setup-dotnet@v1
with:
# Semantic version range syntax or exact version of a dotnet version
dotnet-version: '8.0'
- name: Install dependencies
run: |
cd ../
dotnet restore
- name: Install ReportGenerator
run: |
cd ../
dotnet tool install -g dotnet-reportgenerator-globaltool --version 5.3.6
- uses: amancevice/setup-code-climate@v0
with:
cc_test_reporter_id: ${{ secrets.CC_TEST_REPORTER_ID }}
cc_test_reporter_version: latest # optional
- run: cc-test-reporter before-build
- name: Generate coverage report
env:
EXCLUDE: "**/Migrations/**%2c**/Models/**%2c**/Views/**%2c**/ViewModels/**%2c**/Configuration/**%2c**/DTOs/**%2c**/Helpers/**%2c**/Resources/**%2c**/**Definitions.cs"
run: |
dotnet test /p:ExcludeByFile=$EXCLUDE /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:Exclude=[xunit.*]* --filter FullyQualifiedName\!~Integration
- name: Run report generator
run: |
reportgenerator "-reports:coverage.cobertura.xml" "-targetdir:coverage" -reporttype:lcov "-filefilters:-ApiDbContextModelSnapshot.cs;" -verbosity:Error
- name: Collect Backend Report
run: |
cd ../prime-dotnet-webapi
cc-test-reporter format-coverage -t lcov -o ../prime-dotnet-webapi-tests/coverage/backend.json ../prime-dotnet-webapi-tests/coverage/lcov.info -p /home/runner/work/moh-prime/moh-prime/prime-dotnet-webapi
- name: Create backend coverage file artifact
uses: actions/upload-artifact@v4
with:
name: backend
path: ./prime-dotnet-webapi-tests/coverage/backend.json
retention-days: 1
codeclimate-sum-coverage:
needs: [ collect-frontend-coverage, collect-backend-coverage ]
if: github.ref != 'develop' || (github.ref == 'develop' && github.event.pull_request.merged == true)
runs-on: ubuntu-latest
steps:
- name: set-date
run: |
echo "GIT_COMMITTED_AT=$(date +%s)" >> ${GITHUB_ENV}
- uses: amancevice/setup-code-climate@v0
with:
cc_test_reporter_id: ${{ secrets.CC_TEST_REPORTER_ID }}
cc_test_reporter_version: latest # optional
- name: Download frontend artifact
uses: actions/download-artifact@v4
with:
name: frontend
# path: frontend/
- name: Download backend artifact
uses: actions/download-artifact@v4
with:
name: backend
# path: backend/
- name: Sum files
run: |
cc-test-reporter sum-coverage -p 2 frontend.json backend.json
cc-test-reporter upload-coverage -i ./coverage/codeclimate.json
- name: Create summed report
uses: actions/upload-artifact@v4
with:
name: summed
path: ./coverage/codeclimate.json
retention-days: 1