-
Notifications
You must be signed in to change notification settings - Fork 12
266 lines (222 loc) · 10.6 KB
/
main-code-climate-coverage-aggregation.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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
name: Main-Generate/Upload all Coverage Reports
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
workflow_dispatch:
jobs:
frontend:
environment: Development
env:
FILE_COUNTER: 0
CC_TEST_REPORTER_ID: 8a4068fec71e2ce84714008f57ea6548614c380821df800ed611c2afc6a42d93
ACTION_DEBUG: true
name: Create, format and upload Javascript coverage artifact
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Get Code Climate binary
- name: Download Code Climate Binary
run: curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
# Permissions applied to the Code Climate Executable
- name: Apply executable perms to Code Climate Binary
run: chmod +x ./cc-test-reporter
# Before build
- name: Before build
run: ./cc-test-reporter before-build
# Set required Git env vars for either pull request
- name: Set ENV for codeclimate (pull_request)
run: |
echo "GIT_BRANCH=${{ github.event.pull_request.head.ref }}" >> $GITHUB_ENV
echo "GIT_COMMIT_SHA=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
#echo "::set-env name=GIT_BRANCH::${{ github.event.pull_request.head.ref }}"
#echo "::set-env name=GIT_COMMIT_SHA::${{ github.event.pull_request.head.sha }}"
if: github.event_name == 'pull_request'
# Set required Git env vars for a push to master
- name: Set ENV for codeclimate (push)
run: |
echo "GIT_BRANCH=$GITHUB_REF" >> GITHUB_ENV
echo "GIT_COMMIT_SHA=$GITHUB_SHA" >> GITHUB_ENV
#echo "::set-env name=GIT_BRANCH::$GITHUB_REF"
#echo "::set-env name=GIT_COMMIT_SHA::$GITHUB_SHA"
if: github.event_name == 'push'
# Trimming the ref to master in order to publish correct report (paambaati)
- name: Set ref/head/master to master
run: |
echo "GIT_BRANCH=main" >> $GITHUB_ENV
#echo "::set-env name=GIT_BRANCH::main"
if: env.GIT_BRANCH == 'refs/heads/main'
- uses: actions/setup-node@v4
- name: Install Yarn
run: npm install -g yarn
# Figure out where yarn is caching things
- name: Yarn Cache
run: yarn cache dir
# Implement Caching Action for Yarn Project
- name: Cache node modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# YARN cache files are stored in `/home/runner/.cache/yarn/v6` on git actions
path: /home/runner/.cache/yarn/v6
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
# Run Yarn Install - citizen Portal
- name: Run Yarn Install - citizen Portal
run: yarn --cwd src/frontend/citizen-portal install
# Run lint - citizen Portal
- name: Run lint - citizen Portal
run: yarn --cwd src/frontend/citizen-portal run lint
# Yarn Coverage - citizen Portal
- name: Run Yarn Coverage - citizen Portal and format lcov.info
run: |
yarn --cwd ${{github.workspace}}/src/frontend/citizen-portal coverage
sed -i "s+SF:src+SF:src\\/frontend\\/citizen-portal\\/src+g" ${{github.workspace}}/src/frontend/citizen-portal/coverage/citizen-portal/report-lcov/lcov.info
# Formatting the Frontend Citizen Portal Coverage Report
- name: Format the Frontend Citizen Portal coverage report
run: ./cc-test-reporter format-coverage -t lcov -o coverage/citizen-portal-codeclimate.json ${{github.workspace}}/src/frontend/citizen-portal/coverage/citizen-portal/report-lcov/lcov.info
# Upload JSON for debugging purposes
- name: Upload JSON for debugging purposes
uses: actions/upload-artifact@v4
with:
name: citizen-portal-coverage-report
path: coverage/citizen-portal-codeclimate.json
backend:
env:
FILE_COUNTER: 0
CC_TEST_REPORTER_ID: 8a4068fec71e2ce84714008f57ea6548614c380821df800ed611c2afc6a42d93
ACTION_DEBUG: true
name: Create, format and upload .NET Backend coverage artifact
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Get Code Climate binary
- name: Download Code Climate Binary
run: curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
# Permissions applied to the Code Climate Executable
- name: Apply executable perms to Code Climate Binary
run: chmod +x ./cc-test-reporter
# Before build
- name: Before build
run: ./cc-test-reporter before-build
# Set required Git env vars for either pull request
- name: Set ENV for codeclimate (pull_request)
run: |
echo "GIT_BRANCH=${{ github.event.pull_request.head.ref }}" >> $GITHUB_ENV
echo "GIT_COMMIT_SHA=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
#echo "::set-env name=GIT_BRANCH::${{ github.event.pull_request.head.ref }}"
#echo "::set-env name=GIT_COMMIT_SHA::${{ github.event.pull_request.head.sha }}"
if: github.event_name == 'pull_request'
# Set required Git env vars for a push to master
- name: Set ENV for codeclimate (push)
run: |
echo "GIT_BRANCH=$GITHUB_REF" >> GITHUB_ENV
echo "GIT_COMMIT_SHA=$GITHUB_SHA" >> GITHUB_ENV
#echo "::set-env name=GIT_BRANCH::$GITHUB_REF"
#echo "::set-env name=GIT_COMMIT_SHA::$GITHUB_SHA"
if: github.event_name == 'push'
# Trimming the ref to master in order to publish correct report (paambaati)
- name: Set ref/head/master to master
run: |
echo "GIT_BRANCH=main" >> $GITHUB_ENV
#echo "::set-env name=GIT_BRANCH::main"
if: env.GIT_BRANCH == 'refs/heads/main'
# Run the .NET Coverage report for Backend - DisputeAPI & TrafficCourts
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.x
- name: Generate .NET Code Coverage - CitizenAPI
run: dotnet test ${{github.workspace}}/src/backend/TrafficCourts /p:CollectCoverage=true /p:CoverletOutputFormat=lcov /p:ExcludeByFile=\"**/*.g.cs\"
# Formatting the Backend Coverage Report
- name: Format the CitizenAPI Coverage Report
run: ./cc-test-reporter format-coverage -t lcov -o coverage/backend-codeclimate.json ${{github.workspace}}/src/backend/TrafficCourts/TrafficCourts.Common.Test/coverage.info ${{github.workspace}}/src/backend/TrafficCourts/Test/coverage.info
# Upload JSON for debugging purposes
- name: Upload JSON for debugging purposes
uses: actions/upload-artifact@v4
with:
name: backend-coverage-report
path: coverage/backend-codeclimate.json
aggregation:
name: Aggregate Javascript and .NET Coverage reports
needs: [ frontend, backend ]
env:
CC_TEST_REPORTER_ID: 8a4068fec71e2ce84714008f57ea6548614c380821df800ed611c2afc6a42d93
runs-on: ubuntu-latest
steps:
# Get Code Climate binary
- name: Download Code Climate Binary
run: curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
# Permissions applied to the Code Climate Executable
- name: Apply executable perms to Code Climate Binary
run: chmod +x ./cc-test-reporter
# Before build
- name: Before build
run: ./cc-test-reporter before-build
# Set required Git env vars for either pull request
- name: Set ENV for codeclimate (pull_request)
run: |
echo "GIT_BRANCH=${{ github.event.pull_request.head.ref }}" >> $GITHUB_ENV
echo "GIT_COMMIT_SHA=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
#echo "::set-env name=GIT_BRANCH::${{ github.event.pull_request.head.ref }}"
#echo "::set-env name=GIT_COMMIT_SHA::${{ github.event.pull_request.head.sha }}"
if: github.event_name == 'pull_request'
# Set required Git env vars for a push to master
- name: Set ENV for codeclimate (push)
run: |
echo "GIT_BRANCH=$GITHUB_REF" >> $GITHUB_ENV
echo "GIT_COMMIT_SHA=$GITHUB_SHA" >> $GITHUB_ENV
#echo "::set-env name=GIT_BRANCH::$GITHUB_REF"
#echo "::set-env name=GIT_COMMIT_SHA::$GITHUB_SHA"
if: github.event_name == 'push'
# Trimming the ref to master in order to publish correct report (paambaati)
- name: Set ref/head/master to master
run: |
echo "GIT_BRANCH=main" >> $GITHUB_ENV
#echo "::set-env name=GIT_BRANCH::main"
if: env.GIT_BRANCH == 'refs/heads/main'
# Make Directory for downloaded files
- name: Make directory
run: mkdir coverage-reports
# Download Citizen Portal coverage report
- name: Download javascript coverage report
uses: actions/download-artifact@v4
with:
name: citizen-portal-coverage-report
path: citizen-portal-coverage-report
# See what is inside
- name: List items inside citizen portal coverage report object
run: |
ls citizen-portal-coverage-report
# Copy Citizen Portal Coverage to outside directory
- name: Copy Citizen Portal Coverage to directory
run: |
cp citizen-portal-coverage-report/citizen-portal-codeclimate.json coverage-reports/citizen-portal-codeclimate.json
# Download Backend coverage report
- name: Download Backend coverage report
uses: actions/download-artifact@v4
with:
name: backend-coverage-report
path: backend-coverage-report
# Copy total java to outside directory
- name: Copy .NET Coverage to directory
run: |
cp backend-coverage-report/backend-codeclimate.json coverage-reports/backend-codeclimate.json
# Sum the coverage reports
- name: Summing the coverage reports generated
run: |
./cc-test-reporter sum-coverage coverage-reports/*-codeclimate.json -p 2 -o coverage-reports/total-codeclimate.json
# Upload JSON for debugging purposes
- name: Upload JSON for debugging purposes
uses: actions/upload-artifact@v4
with:
name: summed-total-coverage-report
path: coverage-reports/total-codeclimate.json
# Upload total coverage report to Code Climate
- name: Upload coverage report to Code Climate
run: ./cc-test-reporter upload-coverage -i coverage-reports/total-codeclimate.json