-
Notifications
You must be signed in to change notification settings - Fork 13
369 lines (309 loc) · 14.1 KB
/
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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
name: Generate/Upload all Coverage Reports
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
yarn:
env:
FILE_COUNTER: 0
CC_TEST_REPORTER_ID: 9ada3133fe9babf91a222009998b3545b7eae897a05900930bfa8a27fd82f385
ACTION_DEBUG: true
name: Create, format and upload Javascript coverage artifact
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# 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=master" >> $GITHUB_ENV
#echo "::set-env name=GIT_BRANCH::master"
if: env.GIT_BRANCH == 'refs/heads/master'
- name: Printing node and yarn versions
run: node --version && yarn --version
# 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@v2
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 - eFiling Frontend
- name: Run Yarn Install - eFiling Frontend
run: yarn --cwd src/frontend/efiling-frontend install
# Check lint version
- name: Check lint - eFiling Frontend
run: yarn --cwd src/frontend/efiling-frontend run lint -v
# Run lint - eFiling Frontend
- name: Run lint - eFiling Frontend
run: yarn --cwd src/frontend/efiling-frontend run lint
# Yarn Coverage - eFiling Frontend
- name: Run Yarn Coverage - eFiling Frontend
run: yarn --cwd /home/runner/work/jag-file-submission/jag-file-submission/src/frontend/efiling-frontend coverage
# Run Yarn Install - eFiling Demo
- name: Run Yarn Install - eFiling Demo
run: yarn --cwd src/frontend/efiling-demo install
# Run lint - eFiling Demo
- name: Run lint - eFiling Demo
run: yarn --cwd src/frontend/efiling-demo run lint
# Yarn Coverage - eFiling Demo
- name: Run Yarn Coverage - eFiling Demo
run: yarn --cwd /home/runner/work/jag-file-submission/jag-file-submission/src/frontend/efiling-demo coverage
# Formatting the FRONTEND DEMO coverage report
#- name: Format the FRONTEND DEMO coverage report
# run: |
# pushd .
# cd ${{github.workspace}}/src/frontend/efiling-demo/
# ${{github.workspace}}/cc-test-reporter format-coverage -t lcov -o ${{github.workspace}}/coverage/frontend-demo-codeclimate.json coverage/lcov.info
# popd
# Formatting the FRONTEND coverage report
- name: Format the FRONTEND coverage report
run: |
pushd .
cd ${{github.workspace}}/src/frontend/efiling-frontend/
${{github.workspace}}/cc-test-reporter format-coverage -t lcov -o ${{github.workspace}}/coverage/frontend-codeclimate.json coverage/lcov.info
popd
# List all formatted files in coverage directory
- name: WHERE AM I - FORMATTED?
run: |
ls ${{ github.workspace }}/coverage
if: ${{ env.ACTION_DEBUG }}
# Count of all total coverage files available
- name: Count files present
run: |
echo "FILE_COUNTER=$(ls -1q ./coverage | wc -l )" >> $GITHUB_ENV
#echo "::set-env name=FILE_COUNTER::$(ls -1q ./coverage | wc -l )"
# Sum the coverage reports
- name: Summing the coverage reports generated
run: ./cc-test-reporter sum-coverage coverage/*-codeclimate.json -p ${{ env.FILE_COUNTER }} -o coverage/total-codeclimate.json
# Upload JSON for debugging purposes
- name: Upload JSON for debugging purposes
uses: actions/upload-artifact@v4
with:
name: summed-yarn-coverage-report
path: coverage/total-codeclimate.json
spring-boot:
name: Create, format and upload Java coverage artifact
runs-on: ubuntu-latest
env:
FILE_COUNTER: 0
CC_TEST_REPORTER_ID: 9ada3133fe9babf91a222009998b3545b7eae897a05900930bfa8a27fd82f385
ACTION_DEBUG: true
steps:
- name: Checkout Spring Starters Repository
uses: actions/checkout@v2
with:
repository: bcgov/spring-boot-starters
path: spring-boot-starters
ref: v1.0.2
# Setup Java Environment
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
# TODO REMOVE AFTER SFTP IS IN MAVEN CENTRAL
- name: Build Spring Starters
run: mvn install -P all --file ./spring-boot-starters/src/pom.xml
- name: Checkout File Submission Repository
uses: actions/checkout@v2
# 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=master" >> $GITHUB_ENV
#echo "::set-env name=GIT_BRANCH::master"
if: env.GIT_BRANCH == 'refs/heads/master'
#- uses: actions/cache@v1
# with:
# path: ~/.m2/repository
# key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
# restore-keys: |
# ${{ runner.os }}-maven-
#Set env again??
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
# Run Maven Verify to generate all jacoco reports
- name: Build with Maven
run: mvn -B verify -P all --file src/backend/pom.xml
# Formatting the BACKEND coverage reports generated (dynamically)
- name: Format BACKEND coverage reports
run: |
projectRelRegex="^\.\/src\/backend\/(.*)\/target\/site\/jacoco\/jacoco\.xml$"
for file in $(find . -name "jacoco.xml")
do
echo $file
echo $projectRelRegex
if [[ $file =~ $projectRelRegex ]]
then
projectRel="${BASH_REMATCH[1]}"
echo "analyzing project: " $projectRel
projectName="${projectRel//\//-}"
JACOCO_SOURCE_PATH=${{ github.workspace }}/src/backend/$projectRel/src/main/java ./cc-test-reporter format-coverage ${{github.workspace}}/src/backend/$projectRel/target/site/jacoco/jacoco.xml --input-type jacoco --output coverage/$projectName-codeclimate.json;
echo "coverage generated: coverage/$projectName-codeclimate.json;"
else
echo $file does not match
fi
done
# List all formatted files in coverage directory
- name: WHERE AM I - FORMATTED?
run: |
ls ${{ github.workspace }}/coverage
if: ${{ env.ACTION_DEBUG }}
# Count of all total coverage files available
- name: Count files present
run: |
echo "FILE_COUNTER=$(ls -1q ./coverage | wc -l )" >> $GITHUB_ENV
#echo "::set-env name=FILE_COUNTER::$(ls -1q ./coverage | wc -l )"
# Sum the coverage reports
- name: Summing the coverage reports generated
run: ./cc-test-reporter sum-coverage coverage/*-codeclimate.json -p ${{ env.FILE_COUNTER }} -o coverage/total-codeclimate.json
# Upload JSON for debugging purposes
- name: Upload JSON for debugging purposes
uses: actions/upload-artifact@v4
with:
name: summed-java-coverage-report
path: coverage/total-codeclimate.json
aggregation:
name: Aggregate Spring Boot and Javascript reports
needs: [yarn, spring-boot]
env:
CC_TEST_REPORTER_ID: 9ada3133fe9babf91a222009998b3545b7eae897a05900930bfa8a27fd82f385
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=master" >> $GITHUB_ENV
#echo "::set-env name=GIT_BRANCH::master"
if: env.GIT_BRANCH == 'refs/heads/master'
# Make Directory for downloaded files
- name: Make directory
run: mkdir coverage-reports
# Download Spring-boot coverage report
- name: Download spring-boot coverage report
uses: actions/download-artifact@v4
with:
name: summed-java-coverage-report
# See what is inside
- name: List items inside java coverage report object
run: |
ls
# Copy total java to outside directory
- name: Copy Java Coverage to directory
run: |
cp total-codeclimate.json coverage-reports/total-java-codeclimate.json
# Download Yarn coverage report
- name: Download javascript coverage report
uses: actions/download-artifact@v4
with:
name: summed-yarn-coverage-report
# See what is inside
- name: List items inside javascript coverage report object
run: |
ls
# Copy total Yarn to outside directory
- name: Copy Yarn Coverage to directory
run: |
cp total-codeclimate.json coverage-reports/total-yarn-codeclimate.json
# See what is inside coverage
- name: List items inside java coverage report object
run: |
ls coverage-reports
# 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 -d -i coverage-reports/total-codeclimate.json