Skip to content

Commit d459a60

Browse files
authored
#126: Bring workflow actions up to date
* unified actions names and filenames * added test filenames check * rewritten JaCoCo report to be more informative * streamlined job steps
2 parents 2e0631a + afeee7c commit d459a60

File tree

9 files changed

+236
-123
lines changed

9 files changed

+236
-123
lines changed

.github/codeowners

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @benedeki @dk1844 @jakipatryk @lsulak @Zejnilovic
1+
* @benedeki @dk1844 @jakipatryk @lsulak @Zejnilovic @salamonpavel @miroslavpojer

.github/workflows/assign_issue_to_project.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Auto Assign Issue to Project
1+
name: Assign Issue to Project
22

33
on:
44
issues:

.github/workflows/build.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ on:
2323
types: [ assigned, opened, synchronize, reopened, labeled ]
2424

2525
jobs:
26-
build:
26+
build-test-and-doc:
27+
name: Build, Test and Doc
2728
runs-on: ubuntu-latest
2829
services:
2930
postgres:
@@ -42,7 +43,6 @@ jobs:
4243
fail-fast: false
4344
matrix:
4445
scala: [2.12.17, 2.13.12]
45-
name: Build and test
4646
steps:
4747
- name: Checkout code
4848
uses: actions/checkout@v2
@@ -52,7 +52,9 @@ jobs:
5252
java-version: "[email protected]"
5353
- name: Build and run unit tests
5454
run: sbt ++${{matrix.scala}} test
55+
- name: Generate documentation
56+
run: sbt ++${{matrix.scala}} doc
5557
- name: Prepare testing database
5658
run: sbt flywayMigrate
57-
- name: Build and run integration tests
58-
run: sbt ++${{matrix.scala}} testIT doc
59+
- name: Run integration tests
60+
run: sbt ++${{matrix.scala}} testIT

.github/workflows/dependent_items.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Dependent Issues
1+
name: Dependent Items
22

33
on:
44
issues:
@@ -24,7 +24,8 @@ on:
2424
- cron: '0 0 * * *'
2525

2626
jobs:
27-
check:
27+
dependent-items-check:
28+
name: Dependent Items Check
2829
runs-on: ubuntu-latest
2930
steps:
3031
- uses: z0al/[email protected]

.github/workflows/jacoco.yml

Lines changed: 0 additions & 114 deletions
This file was deleted.
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
#
2+
# Copyright 2022 ABSA Group Limited
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
name: JaCoCo Report
18+
19+
on:
20+
pull_request:
21+
branches: [ master ]
22+
types: [ opened, edited, synchronize, reopened ]
23+
24+
env:
25+
scalaLong: 2.13.11
26+
scalaShort: 2.13
27+
coverage-overall: 57.0
28+
coverage-changed-files: 80.0
29+
check-overall-coverages: true
30+
31+
jobs:
32+
build-test-and-measure:
33+
name: Build, Test and Measure
34+
runs-on: ubuntu-latest
35+
36+
services:
37+
postgres:
38+
image: postgres:15
39+
env:
40+
POSTGRES_PASSWORD: postgres
41+
POSTGRES_DB: movies
42+
options: >-
43+
--health-cmd pg_isready
44+
--health-interval 10s
45+
--health-timeout 5s
46+
--health-retries 5
47+
ports:
48+
- 5432:5432
49+
50+
steps:
51+
- name: Checkout code
52+
uses: actions/checkout@v4
53+
- name: Setup Scala
54+
uses: olafurpg/setup-scala@v14
55+
with:
56+
java-version: "[email protected]"
57+
- name: Prepare testing database
58+
run: sbt flywayMigrate
59+
- name: Build and run tests
60+
continue-on-error: true
61+
id: jacocorun
62+
run: sbt ++${{env.scalaLong}} jacoco
63+
- name: Add coverage to PR (core)
64+
if: steps.jacocorun.outcome == 'success'
65+
id: jacoco-core
66+
uses: madrapps/[email protected]
67+
with:
68+
paths: ${{ github.workspace }}/core/target/scala-${{ env.scalaShort }}/jacoco/report/jacoco.xml
69+
token: ${{ secrets.GITHUB_TOKEN }}
70+
min-coverage-overall: ${{ env.coverage-overall }}
71+
min-coverage-changed-files: ${{ env.coverage-changed-files }}
72+
title: JaCoCo `model` module code coverage report - scala ${{ env.scalaLong }}
73+
update-comment: true
74+
- name: Add coverage to PR (doobie)
75+
if: steps.jacocorun.outcome == 'success'
76+
id: jacoco-doobie
77+
uses: madrapps/[email protected]
78+
with:
79+
paths: ${{ github.workspace }}/doobie/target/scala-${{ env.scalaShort }}/jacoco/report/jacoco.xml
80+
token: ${{ secrets.GITHUB_TOKEN }}
81+
min-coverage-overall: ${{ env.coverage-overall }}
82+
min-coverage-changed-files: ${{ env.coverage-changed-files }}
83+
title: JaCoCo `agent` module code coverage report - scala ${{ env.scalaLong }}
84+
update-comment: true
85+
- name: Add coverage to PR (slick)
86+
if: steps.jacocorun.outcome == 'success'
87+
id: jacoco-slick
88+
uses: madrapps/[email protected]
89+
with:
90+
paths: ${{ github.workspace }}/slick/target/scala-${{ env.scalaShort }}/jacoco/report/jacoco.xml
91+
token: ${{ secrets.GITHUB_TOKEN }}
92+
min-coverage-overall: ${{env.coverage-overall }}
93+
min-coverage-changed-files: ${{ env.coverage-changed-files }}
94+
title: JaCoCo `slick` module code coverage report - scala ${{ env.scalaLong }}
95+
update-comment: true
96+
- name: Get the Coverage info
97+
if: steps.jacocorun.outcome == 'success'
98+
run: |
99+
echo "Total `core` module coverage ${{ steps.jacoco-core.outputs.coverage-overall }}"
100+
echo "Changed Files coverage ${{ steps.jacoco-core.outputs.coverage-changed-files }}"
101+
echo "Total `doobie` module coverage ${{ steps.jacoco-doobie.outputs.coverage-overall }}"
102+
echo "Changed Files coverage ${{ steps.jacoco-doobie.outputs.coverage-changed-files }}"
103+
echo "Total `slick` module coverage ${{ steps.jacoco-slick.outputs.coverage-overall }}"
104+
echo "Changed Files coverage ${{ steps.jacoco-slick.outputs.coverage-changed-files }}"
105+
- name: Fail PR if changed files coverage is less than ${{ env.coverage-changed-files }}%
106+
if: steps.jacocorun.outcome == 'success'
107+
uses: actions/github-script@v6
108+
with:
109+
script: |
110+
const coverageCheckFailed =
111+
Number('${{ steps.jacoco-core.outputs.coverage-changed-files }}') < Number('${{ env.coverage-changed-files }}') ||
112+
Number('${{ steps.jacoco-doobie.outputs.coverage-changed-files }}') < Number('${{ env.coverage-changed-files }}') ||
113+
Number('${{ steps.jacoco-slick.outputs.coverage-changed-files }}') < Number('${{ env.coverage-changed-files }}');
114+
if (coverageCheckFailed) {
115+
core.setFailed('Changed files coverage is less than ${{ env.coverage-changed-files }}%!');
116+
}
117+
- name: Fail PR if overall files coverage is less than ${{ env.coverage-overall }}%
118+
if: ${{ (steps.jacocorun.outcome == 'success') && (env.check-overall-coverages == 'true') }}
119+
uses: actions/github-script@v6
120+
with:
121+
script: |
122+
const coverageCheckFailed =
123+
Number('${{ steps.jacoco-core.outputs.coverage-overall }}') < Number('${{ env.coverage-overall }}') ||
124+
Number('${{ steps.jacoco-doobie.outputs.coverage-overall }}') < Number('${{ env.coverage-overall }}') ||
125+
Number('${{ steps.jacoco-slick.outputs.coverage-overall }}') < Number('${{ env.coverage-overall }}');
126+
if (coverageCheckFailed) {
127+
core.setFailed('Overall coverage is less than ${{ env.coverage-overall }}%!');
128+
}
129+
- name: Edit JaCoCo comments on build failure
130+
if: steps.jacocorun.outcome != 'success'
131+
uses: actions/github-script@v6
132+
with:
133+
script: |
134+
const issue_number = context.issue.number;
135+
const owner = context.repo.owner;
136+
const repo = context.repo.repo;
137+
const jacocoReportRegExp = /^### JaCoCo .* code coverage report .*/;
138+
139+
const comments = await github.rest.issues.listComments({
140+
owner,
141+
repo,
142+
issue_number,
143+
});
144+
145+
for (const comment of comments.data) {
146+
const lines = comment.body.split('\n');
147+
if (lines.length > 0 && jacocoReportRegExp.test(lines[0])) {
148+
await github.rest.issues.updateComment({
149+
owner,
150+
repo,
151+
comment_id: comment.id,
152+
body: lines[0] + "\n\n### Build Failed",
153+
});
154+
}
155+
}
156+
157+
core.setFailed('JaCoCo test coverage report generation failed, and related PR comments were updated.');

.github/workflows/license_check.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ on:
2424
types: [ assigned, opened, synchronize, reopened, labeled ]
2525

2626
jobs:
27-
license-test:
27+
license-check:
28+
name: License Check
2829
runs-on: ubuntu-latest
2930
steps:
3031
- name: Checkout code
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#
2+
# Copyright 2022 ABSA Group Limited
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
name: Test Filenames Check
18+
19+
on:
20+
pull_request:
21+
branches: [ master ]
22+
types: [ opened, synchronize, reopened ]
23+
24+
jobs:
25+
test_filenames_check:
26+
name: Test Filenames Check
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Checkout code
30+
uses: actions/checkout@v2
31+
32+
- name: Filename Inspector
33+
id: scan-test-files
34+
uses: AbsaOSS/filename-inspector@master
35+
with:
36+
name-patterns: '*UnitTests.*,*IntegrationTests.*'
37+
paths: '**/src/test/scala/**'
38+
report-format: 'console'
39+
excludes: 'slick/src/test/scala/za/co/absa/fadb/slick/Actor.scala,slick/src/test/scala/za/co/absa/fadb/slick/ActorSlickConverter.scala,slick/src/test/scala/za/co/absa/fadb/slick/SlickTest.scala,doobie/src/test/scala/za/co/absa/fadb/doobie/DoobieTest.scala,slick/src/test/scala/za/co/absa/fadb/slick/OptionalActorSlickConverter.scala'
40+
verbose-logging: 'false'
41+
fail-on-violation: 'true'

0 commit comments

Comments
 (0)