Skip to content

Commit

Permalink
minors in pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
salamonpavel committed Feb 13, 2024
1 parent 624eb9f commit e0b4506
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 68 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docker_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ jobs:
- uses: actions/checkout@v2

- name: Setup Scala environment
uses: olafurpg/setup-scala@v10
uses: olafurpg/setup-scala@v14
with:
java-version: [email protected]
java-version: "[email protected].0-11"

- name: Run sbt assembly
run: sbt server/assembly
Expand Down
33 changes: 1 addition & 32 deletions .github/workflows/jacoco_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.
#

name: JaCoCo report
name: JaCoCo report agent and module

on:
pull_request:
Expand All @@ -24,8 +24,6 @@ on:
env:
scalaLong12: 2.12.18
scalaShort12: "2.12"
scalaLong13: 2.13.11
scalaShort13: "2.13"
overall: 80.0
changed: 80.0

Expand All @@ -34,20 +32,6 @@ jobs:
name: Build and test
runs-on: ubuntu-latest

services:
postgres:
image: postgres:15
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: atum_db
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -61,18 +45,6 @@ jobs:
continue-on-error: true
id: jacocorun
run: sbt jacoco
# server module code coverage
- name: Add coverage to PR
if: steps.jacocorun.outcome == 'success'
id: jacoco-server
uses: madrapps/[email protected]
with:
paths: ${{ github.workspace }}/server/target/jvm-${{ env.scalaShort13 }}/jacoco/report/jacoco.xml
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: ${{env.overall }}
min-coverage-changed-files: ${{ env.changed }}
title: JaCoCo server module code coverage report - scala ${{ env.scalaLong13 }}
update-comment: true
# agent module code coverage
- name: Add coverage to PR
if: steps.jacocorun.outcome == 'success'
Expand Down Expand Up @@ -102,8 +74,6 @@ jobs:
- name: Get the Coverage info
if: steps.jacocorun.outcome == 'success'
run: |
echo "Total sever module coverage ${{ steps.jacoco-server.outputs.coverage-overall }}"
echo "Changed Files coverage ${{ steps.jacoco-server.outputs.coverage-changed-files }}"
echo "Total agent module coverage ${{ steps.jacoco-agent.outputs.coverage-overall }}"
echo "Changed Files coverage ${{ steps.jacoco-agent.outputs.coverage-changed-files }}"
echo "Total model module coverage ${{ steps.jacoco-model.outputs.coverage-overall }}"
Expand All @@ -114,7 +84,6 @@ jobs:
with:
script: |
const coverageCheckFailed =
Number('${{ steps.jacoco-server.outputs.coverage-changed-files }}') < Number('${{ env.changed }}') ||
Number('${{ steps.jacoco-agent.outputs.coverage-changed-files }}') < Number('${{ env.changed }}') ||
Number('${{ steps.jacoco-model.outputs.coverage-changed-files }}') < Number('${{ env.changed }}');
if (coverageCheckFailed) {
Expand Down
69 changes: 51 additions & 18 deletions .github/workflows/jacoco_check_server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ on:
branches: [ master ]
types: [ opened, edited, synchronize, reopened ]

env:
scalaLong13: 2.13.11
scalaShort13: "2.13"
overall: 80.0
changed: 80.0

jobs:
test:
name: Build and test
Expand All @@ -40,45 +46,72 @@ jobs:
ports:
- 5432:5432

strategy:
matrix:
include:
- scala: 2.13.11
scalaShort: "2.13"
overall: 80.0
changed: 80.0
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Setup Scala
uses: olafurpg/setup-scala@v10
uses: olafurpg/setup-scala@v14
with:
java-version: "[email protected]"
- name: Prepare testing database
run: sbt flywayMigrate
- name: Build and run tests
run: sbt "++${{matrix.scala}}; project server; jacoco"
continue-on-error: true
id: jacocorun
run: sbt "project server; jacoco"
# server module code coverage
- name: Add coverage to PR
if: steps.jacocorun.outcome == 'success'
id: jacoco-server
uses: madrapps/[email protected]
with:
paths: ${{ github.workspace }}/server/target/jvm-${{ matrix.scalaShort }}/jacoco/report/jacoco.xml
paths: ${{ github.workspace }}/server/target/jvm-${{ env.scalaShort13 }}/jacoco/report/jacoco.xml
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: ${{matrix.overall }}
min-coverage-changed-files: ${{ matrix.changed }}
title: JaCoCo server module code coverage report - scala ${{ matrix.scala }}
min-coverage-overall: ${{env.overall }}
min-coverage-changed-files: ${{ env.changed }}
title: JaCoCo server module code coverage report - scala ${{ env.scalaLong13 }}
update-comment: true
- name: Get the Coverage info
if: steps.jacocorun.outcome == 'success'
run: |
echo "Total sever module coverage ${{ steps.jacoco-server.outputs.coverage-overall }}"
echo "Changed Files coverage ${{ steps.jacoco-server.outputs.coverage-changed-files }}"
- name: Fail PR if changed files coverage is less than ${{ matrix.changed }}%
if: |
${{ steps.jacoco-server.outputs.coverage-changed-files < 80.0 }}
- name: Fail PR if changed files coverage is less than ${{ env.changed }}%
if: steps.jacocorun.outcome == 'success'
uses: actions/github-script@v6
with:
script: |
core.setFailed('Changed files coverage is less than ${{ matrix.changed }}%!')
const coverageCheckFailed =
Number('${{ steps.jacoco-server.outputs.coverage-changed-files }}') < Number('${{ env.changed }}');
if (coverageCheckFailed) {
core.setFailed('Changed files coverage is less than ${{ env.changed }}%!');
}
- name: Edit JaCoCo comments on build failure
if: steps.jacocorun.outcome != 'success'
uses: actions/github-script@v6
with:
script: |
const issue_number = context.issue.number;
const owner = context.repo.owner;
const repo = context.repo.repo;
const jacocoReportRegExp = /^### JaCoCo .* code coverage report .*/;
const comments = await github.rest.issues.listComments({
owner,
repo,
issue_number,
});
for (const comment of comments.data) {
const lines = comment.body.split('\n');
if (lines.length > 0 && jacocoReportRegExp.test(lines[0])) {
await github.rest.issues.updateComment({
owner,
repo,
comment_id: comment.id,
body: lines[0] + "\n\n### Build Failed",
});
}
}
core.setFailed('JaCoCo test coverage report generation failed, and related PR comments were updated.');
9 changes: 0 additions & 9 deletions .github/workflows/release_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,3 @@ jobs:
PGP_SECRET: ${{ secrets.PGP_SECRET }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}

- name: Find WAR file
id: find_war
run: echo "WAR_PATH=$(find . -name '*.war' | head -n 1)" >> $GITHUB_ENV

- name: Upload WAR file to GitHub Release
run: gh release upload ${{ github.event.release.tag_name }} ${{ env.WAR_PATH }} --repo ${{ github.repository }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12 changes: 6 additions & 6 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ lazy val commonSettings = Seq(
jacocoExcludes := jacocoProjectExcludes()
)

val mergeStrategy = assembly / assemblyMergeStrategy := {
case PathList("META-INF", _) => MergeStrategy.discard
case "application.conf" => MergeStrategy.concat
case "reference.conf" => MergeStrategy.concat
case _ => MergeStrategy.first
}
//val mergeStrategy = assembly / assemblyMergeStrategy := {
// case PathList("META-INF", _) => MergeStrategy.discard
// case "application.conf" => MergeStrategy.concat
// case "reference.conf" => MergeStrategy.concat
// case _ => MergeStrategy.first
//}

val serverMergeStrategy = assembly / assemblyMergeStrategy := {
case PathList("META-INF", "services", xs @ _*) => MergeStrategy.filterDistinctLines
Expand Down
2 changes: 1 addition & 1 deletion server/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
postgres {
# The JDBC driver class
dataSourceClass=org.postgresql.Driver
serverName=localhost // host.docker.internal for local run in docker against db on its host machine
serverName=localhost // host.docker.internal for local run in docker against db on its host machine; localhost otherwise for testing and for the gh pipeline
# set to non-default port, to avoid local collision
portNumber=5432
databaseName=atum_db
Expand Down

0 comments on commit e0b4506

Please sign in to comment.