From b0c2f68be837c0779add54ba7382093b4fb34b5d Mon Sep 17 00:00:00 2001 From: David Benedeki Date: Mon, 24 Jun 2024 16:38:00 +0200 Subject: [PATCH 01/23] #126: Bring workflow actions up to date * unified actions names and filenames * added test filename check * streamlined job steps --- .github/workflows/assign_issue_to_project.yml | 2 +- .github/workflows/build.yml | 10 +++-- .github/workflows/dependent_items.yml | 5 ++- .../{jacoco.yml => jacoco_report.yml} | 6 +-- .github/workflows/license_check.yml | 3 +- .github/workflows/test_filenames_check.yml | 41 +++++++++++++++++++ 6 files changed, 56 insertions(+), 11 deletions(-) rename .github/workflows/{jacoco.yml => jacoco_report.yml} (98%) create mode 100644 .github/workflows/test_filenames_check.yml diff --git a/.github/workflows/assign_issue_to_project.yml b/.github/workflows/assign_issue_to_project.yml index 382b3b33..dc88101e 100644 --- a/.github/workflows/assign_issue_to_project.yml +++ b/.github/workflows/assign_issue_to_project.yml @@ -1,4 +1,4 @@ -name: Auto Assign Issue to Project +name: Assign Issue to Project on: issues: diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4ef8a539..3c54bb35 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,7 +23,8 @@ on: types: [ assigned, opened, synchronize, reopened, labeled ] jobs: - build: + build-test-and-doc: + name: Build, test and doc runs-on: ubuntu-latest services: postgres: @@ -42,7 +43,6 @@ jobs: fail-fast: false matrix: scala: [2.12.17, 2.13.12] - name: Build and test steps: - name: Checkout code uses: actions/checkout@v2 @@ -52,7 +52,9 @@ jobs: java-version: "adopt@1.8" - name: Build and run unit tests run: sbt ++${{matrix.scala}} test + - name: Generate documentation + run: sbt ++${{matrix.scala}} doc - name: Prepare testing database run: sbt flywayMigrate - - name: Build and run integration tests - run: sbt ++${{matrix.scala}} testIT doc + - name: Run integration tests + run: sbt ++${{matrix.scala}} testIT diff --git a/.github/workflows/dependent_items.yml b/.github/workflows/dependent_items.yml index fd0349ce..1ab7f5c1 100644 --- a/.github/workflows/dependent_items.yml +++ b/.github/workflows/dependent_items.yml @@ -1,4 +1,4 @@ -name: Dependent Issues +name: Dependent Items on: issues: @@ -24,7 +24,8 @@ on: - cron: '0 0 * * *' jobs: - check: + dependent-items-check: + name: Dependent Items Check runs-on: ubuntu-latest steps: - uses: z0al/dependent-issues@v1.5.2 diff --git a/.github/workflows/jacoco.yml b/.github/workflows/jacoco_report.yml similarity index 98% rename from .github/workflows/jacoco.yml rename to .github/workflows/jacoco_report.yml index 57517fb8..a2544366 100644 --- a/.github/workflows/jacoco.yml +++ b/.github/workflows/jacoco_report.yml @@ -14,7 +14,7 @@ # limitations under the License. # -name: Build +name: JaCoCo Report on: push: @@ -23,7 +23,8 @@ on: types: [ assigned, opened, synchronize, reopened, labeled ] jobs: - jacoco: + build-test-and-measure: + name: Build, Test and Measure runs-on: ubuntu-latest services: postgres: @@ -43,7 +44,6 @@ jobs: SCALA_SHORT_VERSION: "2.13" COVERAGE_OVERALL_EXPECTATION: 75.0 COVERAGE_CHANGED_EXPECTATION: 80.0 - name: Build and run JaCoCo steps: - name: Checkout code uses: actions/checkout@v2 diff --git a/.github/workflows/license_check.yml b/.github/workflows/license_check.yml index 9042b0e0..2ab787b0 100644 --- a/.github/workflows/license_check.yml +++ b/.github/workflows/license_check.yml @@ -24,7 +24,8 @@ on: types: [ assigned, opened, synchronize, reopened, labeled ] jobs: - license-test: + license-check: + name: License Check runs-on: ubuntu-latest steps: - name: Checkout code diff --git a/.github/workflows/test_filenames_check.yml b/.github/workflows/test_filenames_check.yml new file mode 100644 index 00000000..26410280 --- /dev/null +++ b/.github/workflows/test_filenames_check.yml @@ -0,0 +1,41 @@ +# +# Copyright 2022 ABSA Group Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +name: Test Filenames Check + +on: + pull_request: + branches: [ master ] + types: [ opened, synchronize, reopened ] + +jobs: + test_filenames_check: + name: Test Filenames Check + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Filename Inspector + id: scan-test-files + uses: AbsaOSS/filename-inspector@master + with: + name-patterns: '*UnitTests.*,*IntegrationTests.*' + paths: '**/src/test/scala/**' + report-format: 'console' + excludes: '' + verbose-logging: 'false' + fail-on-violation: 'true' From 11c8d83c883880cbf514d359f0fe734c081b3012 Mon Sep 17 00:00:00 2001 From: David Benedeki Date: Mon, 24 Jun 2024 16:56:36 +0200 Subject: [PATCH 02/23] * added check filename exceptions --- .github/workflows/test_filenames_check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_filenames_check.yml b/.github/workflows/test_filenames_check.yml index 26410280..148dbaa3 100644 --- a/.github/workflows/test_filenames_check.yml +++ b/.github/workflows/test_filenames_check.yml @@ -36,6 +36,6 @@ jobs: name-patterns: '*UnitTests.*,*IntegrationTests.*' paths: '**/src/test/scala/**' report-format: 'console' - excludes: '' + 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' verbose-logging: 'false' fail-on-violation: 'true' From 42e5bad2f53693a001a0f8573229ea5355c080ce Mon Sep 17 00:00:00 2001 From: David Benedeki Date: Mon, 24 Jun 2024 17:00:36 +0200 Subject: [PATCH 03/23] * decreased overall test coverage required --- .github/workflows/jacoco_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jacoco_report.yml b/.github/workflows/jacoco_report.yml index a2544366..385538d9 100644 --- a/.github/workflows/jacoco_report.yml +++ b/.github/workflows/jacoco_report.yml @@ -42,7 +42,7 @@ jobs: env: SCALA_VERSION: "2.13.12" SCALA_SHORT_VERSION: "2.13" - COVERAGE_OVERALL_EXPECTATION: 75.0 + COVERAGE_OVERALL_EXPECTATION: 61.0 COVERAGE_CHANGED_EXPECTATION: 80.0 steps: - name: Checkout code From 16e3ebd3f8621dcc92ae128c1b4d051bd3d3a802 Mon Sep 17 00:00:00 2001 From: David Benedeki Date: Tue, 25 Jun 2024 12:33:03 +0200 Subject: [PATCH 04/23] * Fixed Jacoco checks to use the constants --- .github/workflows/jacoco_report.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/jacoco_report.yml b/.github/workflows/jacoco_report.yml index 385538d9..e06f3e31 100644 --- a/.github/workflows/jacoco_report.yml +++ b/.github/workflows/jacoco_report.yml @@ -101,13 +101,13 @@ jobs: echo "Total doobie coverage ${{ steps.jacoco-doobie.outputs.coverage-overall }}" echo "Changed doobie Files coverage ${{ steps.jacoco-doobie.outputs.coverage-changed-files }}" - name: Fail PR if changed files coverage is less than ${{ env.COVERAGE_CHANGED_EXPECTATION }}% - if: ${{ steps.jacoco-core.outputs.coverage-changed-files < 80.0 || steps.jacoco-slick.outputs.coverage-changed-files < 80.0 || steps.jacoco-doobie.outputs.coverage-changed-files < 80.0 }} + if: ${{ steps.jacoco-core.outputs.coverage-changed-files < env.COVERAGE_CHANGED_EXPECTATION || steps.jacoco-slick.outputs.coverage-changed-files < env.COVERAGE_CHANGED_EXPECTATION || steps.jacoco-doobie.outputs.coverage-changed-files < env.COVERAGE_CHANGED_EXPECTATION }} uses: actions/github-script@v6 with: script: | core.setFailed('Changed files coverage is less than ${{ env.COVERAGE_CHANGED_EXPECTATION }}%!') - name: Fail PR if total files coverage is less than ${{ env.COVERAGE_OVERALL_EXPECTATION }}% - if: ${{ steps.jacoco-core.outputs.coverage-overall < 75.0 || steps.jacoco-slick.outputs.coverage-overall < 75.0 || steps.jacoco-doobie.outputs.coverage-overall < 75.0 }} + if: ${{ steps.jacoco-core.outputs.coverage-overall < env.COVERAGE_OVERALL_EXPECTATION || steps.jacoco-slick.outputs.coverage-overall < env.COVERAGE_OVERALL_EXPECTATION || steps.jacoco-doobie.outputs.coverage-overall < env.COVERAGE_OVERALL_EXPECTATION }} uses: actions/github-script@v6 with: script: | From 69e88bf923d3dffd9586b9b3c9fa43932ec73a93 Mon Sep 17 00:00:00 2001 From: David Benedeki Date: Tue, 25 Jun 2024 13:59:35 +0200 Subject: [PATCH 05/23] * better coverage report log --- .github/workflows/jacoco_report.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/jacoco_report.yml b/.github/workflows/jacoco_report.yml index e06f3e31..b7383944 100644 --- a/.github/workflows/jacoco_report.yml +++ b/.github/workflows/jacoco_report.yml @@ -105,10 +105,10 @@ jobs: uses: actions/github-script@v6 with: script: | - core.setFailed('Changed files coverage is less than ${{ env.COVERAGE_CHANGED_EXPECTATION }}%!') + core.setFailed('Changed files coverage is ${{ steps.jacoco-core.outputs.coverage-changed-files }}, less than ${{ env.COVERAGE_CHANGED_EXPECTATION }}%!') - name: Fail PR if total files coverage is less than ${{ env.COVERAGE_OVERALL_EXPECTATION }}% if: ${{ steps.jacoco-core.outputs.coverage-overall < env.COVERAGE_OVERALL_EXPECTATION || steps.jacoco-slick.outputs.coverage-overall < env.COVERAGE_OVERALL_EXPECTATION || steps.jacoco-doobie.outputs.coverage-overall < env.COVERAGE_OVERALL_EXPECTATION }} uses: actions/github-script@v6 with: script: | - core.setFailed('Total files coverage is less than ${{ env.COVERAGE_OVERALL_EXPECTATION }}%!') + core.setFailed('Total files coverage is ${{ steps.jacoco-core.outputs.coverage-overall }}, less than ${{ env.COVERAGE_OVERALL_EXPECTATION }}%!') From 150d23ef0ddada1f5a5f3b7fd45c90fa76ccb922 Mon Sep 17 00:00:00 2001 From: David Benedeki Date: Tue, 25 Jun 2024 15:53:45 +0200 Subject: [PATCH 06/23] * New test filename exception * Better JaCoco report logging --- .github/workflows/jacoco_report.yml | 39 ++++++++++++++++++---- .github/workflows/test_filenames_check.yml | 2 +- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/.github/workflows/jacoco_report.yml b/.github/workflows/jacoco_report.yml index b7383944..48a54ad1 100644 --- a/.github/workflows/jacoco_report.yml +++ b/.github/workflows/jacoco_report.yml @@ -100,15 +100,42 @@ jobs: run: | echo "Total doobie coverage ${{ steps.jacoco-doobie.outputs.coverage-overall }}" echo "Changed doobie Files coverage ${{ steps.jacoco-doobie.outputs.coverage-changed-files }}" - - name: Fail PR if changed files coverage is less than ${{ env.COVERAGE_CHANGED_EXPECTATION }}% - if: ${{ steps.jacoco-core.outputs.coverage-changed-files < env.COVERAGE_CHANGED_EXPECTATION || steps.jacoco-slick.outputs.coverage-changed-files < env.COVERAGE_CHANGED_EXPECTATION || steps.jacoco-doobie.outputs.coverage-changed-files < env.COVERAGE_CHANGED_EXPECTATION }} + - name: Fail PR if Core changed files coverage is less than ${{ env.COVERAGE_CHANGED_EXPECTATION }}% + if: ${{ steps.jacoco-core.outputs.coverage-changed-files < env.COVERAGE_CHANGED_EXPECTATION }} uses: actions/github-script@v6 with: script: | - core.setFailed('Changed files coverage is ${{ steps.jacoco-core.outputs.coverage-changed-files }}, less than ${{ env.COVERAGE_CHANGED_EXPECTATION }}%!') - - name: Fail PR if total files coverage is less than ${{ env.COVERAGE_OVERALL_EXPECTATION }}% - if: ${{ steps.jacoco-core.outputs.coverage-overall < env.COVERAGE_OVERALL_EXPECTATION || steps.jacoco-slick.outputs.coverage-overall < env.COVERAGE_OVERALL_EXPECTATION || steps.jacoco-doobie.outputs.coverage-overall < env.COVERAGE_OVERALL_EXPECTATION }} + core.setFailed('Core changed files coverage are ${{ steps.jacoco-core.outputs.coverage-changed-files }}%, less than ${{ env.COVERAGE_CHANGED_EXPECTATION }}%!') + - name: Fail PR if Slick changed files coverage is less than ${{ env.COVERAGE_CHANGED_EXPECTATION }}% + if: ${{ steps.jacoco-slick.outputs.coverage-changed-files < env.COVERAGE_CHANGED_EXPECTATION }} uses: actions/github-script@v6 with: script: | - core.setFailed('Total files coverage is ${{ steps.jacoco-core.outputs.coverage-overall }}, less than ${{ env.COVERAGE_OVERALL_EXPECTATION }}%!') + core.setFailed('Slick changed files coverage are ${{ steps.jacoco-slick.outputs.coverage-changed-files }}%, less than ${{ env.COVERAGE_CHANGED_EXPECTATION }}%!') + - name: Fail PR if Doobie changed files coverage is less than ${{ env.COVERAGE_CHANGED_EXPECTATION }}% + if: ${{ steps.jacoco-doobie.outputs.coverage-changed-files < env.COVERAGE_CHANGED_EXPECTATION }} + uses: actions/github-script@v6 + with: + script: | + core.setFailed('Doobie changed files coverage are ${{ steps.jacoco-core.outputs.coverage-changed-files }}%, less than ${{ env.COVERAGE_CHANGED_EXPECTATION }}%!') + + - name: Fail PR if total Core files coverage is less than ${{ env.COVERAGE_OVERALL_EXPECTATION }}% + if: ${{ steps.jacoco-core.outputs.coverage-overall < env.COVERAGE_OVERALL_EXPECTATION }} + uses: actions/github-script@v6 + with: + script: | + core.setFailed('Total files coverage is ${{ steps.jacoco-core.outputs.coverage-overall }}%, less than ${{ env.COVERAGE_OVERALL_EXPECTATION }}%!') + + - name: Fail PR if total Slick files coverage is less than ${{ env.COVERAGE_OVERALL_EXPECTATION }}% + if: ${{ steps.jacoco-slick.outputs.coverage-overall < env.COVERAGE_OVERALL_EXPECTATION }} + uses: actions/github-script@v6 + with: + script: | + core.setFailed('Total files coverage is ${{ steps.jacoco-slick.outputs.coverage-overall }}%, less than ${{ env.COVERAGE_OVERALL_EXPECTATION }}%!') + + - name: Fail PR if total Doobie files coverage is less than ${{ env.COVERAGE_OVERALL_EXPECTATION }}% + if: ${{ steps.jacoco-doobie.outputs.coverage-overall < env.COVERAGE_OVERALL_EXPECTATION }} + uses: actions/github-script@v6 + with: + script: | + core.setFailed('Total files coverage is ${{ steps.jacoco-doobie.outputs.coverage-overall }}%, less than ${{ env.COVERAGE_OVERALL_EXPECTATION }}%!') diff --git a/.github/workflows/test_filenames_check.yml b/.github/workflows/test_filenames_check.yml index 148dbaa3..a9ff5afd 100644 --- a/.github/workflows/test_filenames_check.yml +++ b/.github/workflows/test_filenames_check.yml @@ -36,6 +36,6 @@ jobs: name-patterns: '*UnitTests.*,*IntegrationTests.*' paths: '**/src/test/scala/**' report-format: 'console' - 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' + 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' verbose-logging: 'false' fail-on-violation: 'true' From 2338517f64b2a06af5c95f27d791b4417c73b73a Mon Sep 17 00:00:00 2001 From: David Benedeki Date: Tue, 25 Jun 2024 16:15:49 +0200 Subject: [PATCH 07/23] * experiment --- core/src/main/scala/za/co/absa/fadb/DBFunction.scala | 1 + 1 file changed, 1 insertion(+) diff --git a/core/src/main/scala/za/co/absa/fadb/DBFunction.scala b/core/src/main/scala/za/co/absa/fadb/DBFunction.scala index 03becddc..1236ea6d 100644 --- a/core/src/main/scala/za/co/absa/fadb/DBFunction.scala +++ b/core/src/main/scala/za/co/absa/fadb/DBFunction.scala @@ -186,6 +186,7 @@ object DBFunction { )(implicit schema: DBSchema, dBEngine: E) extends DBFunction[I, R, E, F](functionNameOverride) { + // A constructor that takes only the mandatory parameters and uses default values for the optional ones def this()(implicit schema: DBSchema, dBEngine: E) = this(None) From c9622aed0c55f28903723f233027891c7277cf49 Mon Sep 17 00:00:00 2001 From: David Benedeki Date: Tue, 25 Jun 2024 16:28:45 +0200 Subject: [PATCH 08/23] * rollback of experiment --- core/src/main/scala/za/co/absa/fadb/DBFunction.scala | 1 - 1 file changed, 1 deletion(-) diff --git a/core/src/main/scala/za/co/absa/fadb/DBFunction.scala b/core/src/main/scala/za/co/absa/fadb/DBFunction.scala index 1236ea6d..4458d08c 100644 --- a/core/src/main/scala/za/co/absa/fadb/DBFunction.scala +++ b/core/src/main/scala/za/co/absa/fadb/DBFunction.scala @@ -185,7 +185,6 @@ object DBFunction { functionNameOverride: Option[String] = None )(implicit schema: DBSchema, dBEngine: E) extends DBFunction[I, R, E, F](functionNameOverride) { - // A constructor that takes only the mandatory parameters and uses default values for the optional ones def this()(implicit schema: DBSchema, dBEngine: E) = this(None) From aef4699ba04b9ecfd5b09fa6960cbb6836769374 Mon Sep 17 00:00:00 2001 From: David Benedeki Date: Tue, 25 Jun 2024 16:33:21 +0200 Subject: [PATCH 09/23] * revert experiment II --- core/src/main/scala/za/co/absa/fadb/DBFunction.scala | 1 - 1 file changed, 1 deletion(-) diff --git a/core/src/main/scala/za/co/absa/fadb/DBFunction.scala b/core/src/main/scala/za/co/absa/fadb/DBFunction.scala index 4458d08c..4d6187a7 100644 --- a/core/src/main/scala/za/co/absa/fadb/DBFunction.scala +++ b/core/src/main/scala/za/co/absa/fadb/DBFunction.scala @@ -185,7 +185,6 @@ object DBFunction { functionNameOverride: Option[String] = None )(implicit schema: DBSchema, dBEngine: E) extends DBFunction[I, R, E, F](functionNameOverride) { - // A constructor that takes only the mandatory parameters and uses default values for the optional ones def this()(implicit schema: DBSchema, dBEngine: E) = this(None) From ae9b37fd83bdf0be6fb823b9c7bbb7bf7759c257 Mon Sep 17 00:00:00 2001 From: David Benedeki Date: Tue, 25 Jun 2024 16:36:12 +0200 Subject: [PATCH 10/23] * F --- core/src/main/scala/za/co/absa/fadb/DBFunction.scala | 1 + 1 file changed, 1 insertion(+) diff --git a/core/src/main/scala/za/co/absa/fadb/DBFunction.scala b/core/src/main/scala/za/co/absa/fadb/DBFunction.scala index 4d6187a7..03becddc 100644 --- a/core/src/main/scala/za/co/absa/fadb/DBFunction.scala +++ b/core/src/main/scala/za/co/absa/fadb/DBFunction.scala @@ -185,6 +185,7 @@ object DBFunction { functionNameOverride: Option[String] = None )(implicit schema: DBSchema, dBEngine: E) extends DBFunction[I, R, E, F](functionNameOverride) { + // A constructor that takes only the mandatory parameters and uses default values for the optional ones def this()(implicit schema: DBSchema, dBEngine: E) = this(None) From 3520658bc5b431d8a84f9fa7f859521e50793e9e Mon Sep 17 00:00:00 2001 From: David Benedeki Date: Tue, 25 Jun 2024 16:43:28 +0200 Subject: [PATCH 11/23] * using Number() --- .github/workflows/jacoco_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jacoco_report.yml b/.github/workflows/jacoco_report.yml index 48a54ad1..61084bd6 100644 --- a/.github/workflows/jacoco_report.yml +++ b/.github/workflows/jacoco_report.yml @@ -101,7 +101,7 @@ jobs: echo "Total doobie coverage ${{ steps.jacoco-doobie.outputs.coverage-overall }}" echo "Changed doobie Files coverage ${{ steps.jacoco-doobie.outputs.coverage-changed-files }}" - name: Fail PR if Core changed files coverage is less than ${{ env.COVERAGE_CHANGED_EXPECTATION }}% - if: ${{ steps.jacoco-core.outputs.coverage-changed-files < env.COVERAGE_CHANGED_EXPECTATION }} + if: ${{ Number(steps.jacoco-core.outputs.coverage-changed-files) < Number(env.COVERAGE_CHANGED_EXPECTATION) }} uses: actions/github-script@v6 with: script: | From 1bcf3e997e07da153a1113626706852a2c809ce2 Mon Sep 17 00:00:00 2001 From: David Benedeki Date: Tue, 25 Jun 2024 18:05:20 +0200 Subject: [PATCH 12/23] * return to first version but with values hardcoded --- .github/workflows/jacoco_report.yml | 57 +++++++++-------------------- 1 file changed, 17 insertions(+), 40 deletions(-) diff --git a/.github/workflows/jacoco_report.yml b/.github/workflows/jacoco_report.yml index 61084bd6..baa21310 100644 --- a/.github/workflows/jacoco_report.yml +++ b/.github/workflows/jacoco_report.yml @@ -14,15 +14,17 @@ # limitations under the License. # +name: Build name: JaCoCo Report on: push: branches: [master ] pull_request: - types: [ assigned, opened, synchronize, reopened, labeled ] + types: [ assigned, opened, synchronize, reopened, labeled ] jobs: + jacoco: build-test-and-measure: name: Build, Test and Measure runs-on: ubuntu-latest @@ -42,8 +44,9 @@ jobs: env: SCALA_VERSION: "2.13.12" SCALA_SHORT_VERSION: "2.13" - COVERAGE_OVERALL_EXPECTATION: 61.0 + COVERAGE_OVERALL_EXPECTATION: 75.0 COVERAGE_CHANGED_EXPECTATION: 80.0 + name: Build and run JaCoCo steps: - name: Checkout code uses: actions/checkout@v2 @@ -62,8 +65,8 @@ jobs: paths: > ${{ github.workspace }}/core/target/scala-${{ env.SCALA_SHORT_VERSION }}/jacoco/report/jacoco.xml token: ${{ secrets.GITHUB_TOKEN }} - min-coverage-overall: ${{ env.COVERAGE_OVERALL_EXPECTATION }} - min-coverage-changed-files: ${{ env.COVERAGE_CHANGED_EXPECTATION }} + min-coverage-overall: ${{ 61.0 }} + min-coverage-changed-files: ${{ 80.0 }} title: JaCoCo core code coverage report - scala ${{ env.SCALA_VERSION }} update-comment: true - name: Get the Coverage info @@ -77,8 +80,8 @@ jobs: paths: > ${{ github.workspace }}/slick/target/scala-${{ env.SCALA_SHORT_VERSION }}/jacoco/report/jacoco.xml token: ${{ secrets.GITHUB_TOKEN }} - min-coverage-overall: ${{ env.COVERAGE_OVERALL_EXPECTATION }} - min-coverage-changed-files: ${{ env.COVERAGE_CHANGED_EXPECTATION }} + min-coverage-overall: ${{ 61.0 }} + min-coverage-changed-files: ${{ 80.0 }} title: JaCoCo slick code coverage report - scala ${{ env.SCALA_VERSION }} update-comment: true - name: Get the Coverage info @@ -92,50 +95,24 @@ jobs: paths: > ${{ github.workspace }}/doobie/target/scala-${{ env.SCALA_SHORT_VERSION }}/jacoco/report/jacoco.xml token: ${{ secrets.GITHUB_TOKEN }} - min-coverage-overall: ${{ env.COVERAGE_OVERALL_EXPECTATION }} - min-coverage-changed-files: ${{ env.COVERAGE_CHANGED_EXPECTATION }} + min-coverage-overall: ${{ 61.0 }} + min-coverage-changed-files: ${{ 80.0 }} title: JaCoCo doobie code coverage report - scala ${{ env.SCALA_VERSION }} update-comment: true - name: Get the Coverage info run: | echo "Total doobie coverage ${{ steps.jacoco-doobie.outputs.coverage-overall }}" echo "Changed doobie Files coverage ${{ steps.jacoco-doobie.outputs.coverage-changed-files }}" - - name: Fail PR if Core changed files coverage is less than ${{ env.COVERAGE_CHANGED_EXPECTATION }}% - if: ${{ Number(steps.jacoco-core.outputs.coverage-changed-files) < Number(env.COVERAGE_CHANGED_EXPECTATION) }} + - name: Fail PR if changed files coverage is less than ${{ 80.0 }}% + if: ${{ steps.jacoco-core.outputs.coverage-changed-files < 80.0 || steps.jacoco-slick.outputs.coverage-changed-files < 80.0 || steps.jacoco-doobie.outputs.coverage-changed-files < 80.0 }} uses: actions/github-script@v6 with: script: | - core.setFailed('Core changed files coverage are ${{ steps.jacoco-core.outputs.coverage-changed-files }}%, less than ${{ env.COVERAGE_CHANGED_EXPECTATION }}%!') - - name: Fail PR if Slick changed files coverage is less than ${{ env.COVERAGE_CHANGED_EXPECTATION }}% - if: ${{ steps.jacoco-slick.outputs.coverage-changed-files < env.COVERAGE_CHANGED_EXPECTATION }} + core.setFailed('Changed files coverage is less than ${{ 80.0 }}%!') + - name: Fail PR if total files coverage is less than ${{ 61.0 }}% + if: ${{ steps.jacoco-core.outputs.coverage-overall < 75.0 || steps.jacoco-slick.outputs.coverage-overall < 75.0 || steps.jacoco-doobie.outputs.coverage-overall < 75.0 }} uses: actions/github-script@v6 with: script: | - core.setFailed('Slick changed files coverage are ${{ steps.jacoco-slick.outputs.coverage-changed-files }}%, less than ${{ env.COVERAGE_CHANGED_EXPECTATION }}%!') - - name: Fail PR if Doobie changed files coverage is less than ${{ env.COVERAGE_CHANGED_EXPECTATION }}% - if: ${{ steps.jacoco-doobie.outputs.coverage-changed-files < env.COVERAGE_CHANGED_EXPECTATION }} - uses: actions/github-script@v6 - with: - script: | - core.setFailed('Doobie changed files coverage are ${{ steps.jacoco-core.outputs.coverage-changed-files }}%, less than ${{ env.COVERAGE_CHANGED_EXPECTATION }}%!') - - - name: Fail PR if total Core files coverage is less than ${{ env.COVERAGE_OVERALL_EXPECTATION }}% - if: ${{ steps.jacoco-core.outputs.coverage-overall < env.COVERAGE_OVERALL_EXPECTATION }} - uses: actions/github-script@v6 - with: - script: | - core.setFailed('Total files coverage is ${{ steps.jacoco-core.outputs.coverage-overall }}%, less than ${{ env.COVERAGE_OVERALL_EXPECTATION }}%!') + core.setFailed('Total files coverage is less than ${{ 61.0 }}%!') - - name: Fail PR if total Slick files coverage is less than ${{ env.COVERAGE_OVERALL_EXPECTATION }}% - if: ${{ steps.jacoco-slick.outputs.coverage-overall < env.COVERAGE_OVERALL_EXPECTATION }} - uses: actions/github-script@v6 - with: - script: | - core.setFailed('Total files coverage is ${{ steps.jacoco-slick.outputs.coverage-overall }}%, less than ${{ env.COVERAGE_OVERALL_EXPECTATION }}%!') - - - name: Fail PR if total Doobie files coverage is less than ${{ env.COVERAGE_OVERALL_EXPECTATION }}% - if: ${{ steps.jacoco-doobie.outputs.coverage-overall < env.COVERAGE_OVERALL_EXPECTATION }} - uses: actions/github-script@v6 - with: - script: | - core.setFailed('Total files coverage is ${{ steps.jacoco-doobie.outputs.coverage-overall }}%, less than ${{ env.COVERAGE_OVERALL_EXPECTATION }}%!') From eb41e8dec50dbd28cf4f99660b60ddba6731eb6b Mon Sep 17 00:00:00 2001 From: David Benedeki Date: Tue, 25 Jun 2024 18:18:59 +0200 Subject: [PATCH 13/23] * JaCoCo report last touches (hopefully) * added developers * extended codeowners --- .github/codeowners | 2 +- .github/workflows/jacoco_report.yml | 8 ++------ publish.sbt | 25 +++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/.github/codeowners b/.github/codeowners index c68c45f7..a5451247 100644 --- a/.github/codeowners +++ b/.github/codeowners @@ -1 +1 @@ -* @benedeki @dk1844 @jakipatryk @lsulak @Zejnilovic +* @benedeki @dk1844 @jakipatryk @lsulak @Zejnilovic @salamonpavel @miroslavpojer diff --git a/.github/workflows/jacoco_report.yml b/.github/workflows/jacoco_report.yml index baa21310..ac6514da 100644 --- a/.github/workflows/jacoco_report.yml +++ b/.github/workflows/jacoco_report.yml @@ -24,9 +24,8 @@ on: types: [ assigned, opened, synchronize, reopened, labeled ] jobs: - jacoco: - build-test-and-measure: - name: Build, Test and Measure + jacoco-build-test-and-measure: + name: "JaCoCo: Build, Test and Measure" runs-on: ubuntu-latest services: postgres: @@ -44,9 +43,6 @@ jobs: env: SCALA_VERSION: "2.13.12" SCALA_SHORT_VERSION: "2.13" - COVERAGE_OVERALL_EXPECTATION: 75.0 - COVERAGE_CHANGED_EXPECTATION: 80.0 - name: Build and run JaCoCo steps: - name: Checkout code uses: actions/checkout@v2 diff --git a/publish.sbt b/publish.sbt index 8c558323..6f11edb4 100644 --- a/publish.sbt +++ b/publish.sbt @@ -32,9 +32,34 @@ ThisBuild / developers := List( name = "David Benedeki", email = "david.benedeki@absa.africa", url = url("https://github.com/benedeki") + ), + Developer( + id = "lsulak", + name = "Ladislav Sulak", + email = "ladislav.sulak@absa.africa", + url = url("https://github.com/lsulak") + ), + Developer( + id = "salamonpavel", + name = "Pavel Salamon", + email = "pavel.salamon@absa.africa", + url = url("https://github.com/salamonpavel") + ), + Developer( + id = "miroslavpojer", + name = "Miroslav Pojer", + email = "miroslav.pojer@absa.africa", + url = url("https://github.com/miroslavpojer") + ), + Developer( + id = "Zejnilovic", + name = "Saša Zejnilović", + email = "sasa.zejnilovic@absa.africa", + url = url("https://github.com/Zejnilovic") ) ) + ThisBuild / homepage := Some(url("https://github.com/AbsaOSS/fa-DB")) ThisBuild / description := "DB data access via DB functions" From 878db7fe9cdc98348273a306e15257062746630d Mon Sep 17 00:00:00 2001 From: David Benedeki Date: Tue, 25 Jun 2024 18:22:37 +0200 Subject: [PATCH 14/23] * one more --- .github/workflows/jacoco_report.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/jacoco_report.yml b/.github/workflows/jacoco_report.yml index ac6514da..4d026c94 100644 --- a/.github/workflows/jacoco_report.yml +++ b/.github/workflows/jacoco_report.yml @@ -14,12 +14,11 @@ # limitations under the License. # -name: Build name: JaCoCo Report on: push: - branches: [master ] + branches: [master] pull_request: types: [ assigned, opened, synchronize, reopened, labeled ] From 7b5758eb68179fa4c85befa64ca9c53e00205fa2 Mon Sep 17 00:00:00 2001 From: David Benedeki Date: Tue, 25 Jun 2024 18:24:27 +0200 Subject: [PATCH 15/23] * ..! --- .github/workflows/jacoco_report.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/jacoco_report.yml b/.github/workflows/jacoco_report.yml index 4d026c94..b33ae721 100644 --- a/.github/workflows/jacoco_report.yml +++ b/.github/workflows/jacoco_report.yml @@ -23,8 +23,8 @@ on: types: [ assigned, opened, synchronize, reopened, labeled ] jobs: - jacoco-build-test-and-measure: - name: "JaCoCo: Build, Test and Measure" + build-test-and-measure: + name: "Build, Test and Measure" runs-on: ubuntu-latest services: postgres: From 1a66392dd8b4949f3a7ab65dfa7fabe2dcd58d34 Mon Sep 17 00:00:00 2001 From: David Benedeki Date: Tue, 25 Jun 2024 18:26:10 +0200 Subject: [PATCH 16/23] * 57 --- .github/workflows/jacoco_report.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/jacoco_report.yml b/.github/workflows/jacoco_report.yml index b33ae721..fbdd3e90 100644 --- a/.github/workflows/jacoco_report.yml +++ b/.github/workflows/jacoco_report.yml @@ -60,7 +60,7 @@ jobs: paths: > ${{ github.workspace }}/core/target/scala-${{ env.SCALA_SHORT_VERSION }}/jacoco/report/jacoco.xml token: ${{ secrets.GITHUB_TOKEN }} - min-coverage-overall: ${{ 61.0 }} + min-coverage-overall: ${{ 57.0 }} min-coverage-changed-files: ${{ 80.0 }} title: JaCoCo core code coverage report - scala ${{ env.SCALA_VERSION }} update-comment: true @@ -75,7 +75,7 @@ jobs: paths: > ${{ github.workspace }}/slick/target/scala-${{ env.SCALA_SHORT_VERSION }}/jacoco/report/jacoco.xml token: ${{ secrets.GITHUB_TOKEN }} - min-coverage-overall: ${{ 61.0 }} + min-coverage-overall: ${{ 57.0 }} min-coverage-changed-files: ${{ 80.0 }} title: JaCoCo slick code coverage report - scala ${{ env.SCALA_VERSION }} update-comment: true @@ -90,7 +90,7 @@ jobs: paths: > ${{ github.workspace }}/doobie/target/scala-${{ env.SCALA_SHORT_VERSION }}/jacoco/report/jacoco.xml token: ${{ secrets.GITHUB_TOKEN }} - min-coverage-overall: ${{ 61.0 }} + min-coverage-overall: ${{ 57.0 }} min-coverage-changed-files: ${{ 80.0 }} title: JaCoCo doobie code coverage report - scala ${{ env.SCALA_VERSION }} update-comment: true @@ -104,10 +104,10 @@ jobs: with: script: | core.setFailed('Changed files coverage is less than ${{ 80.0 }}%!') - - name: Fail PR if total files coverage is less than ${{ 61.0 }}% + - name: Fail PR if total files coverage is less than ${{ 57.0 }}% if: ${{ steps.jacoco-core.outputs.coverage-overall < 75.0 || steps.jacoco-slick.outputs.coverage-overall < 75.0 || steps.jacoco-doobie.outputs.coverage-overall < 75.0 }} uses: actions/github-script@v6 with: script: | - core.setFailed('Total files coverage is less than ${{ 61.0 }}%!') + core.setFailed('Total files coverage is less than ${{ 57.0 }}%!') From 8dc06877942a2e320b38a848ab7498f1dcab77bd Mon Sep 17 00:00:00 2001 From: David Benedeki Date: Tue, 25 Jun 2024 18:28:08 +0200 Subject: [PATCH 17/23] * title --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3c54bb35..64673324 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,7 +24,7 @@ on: jobs: build-test-and-doc: - name: Build, test and doc + name: Build, Test and Doc runs-on: ubuntu-latest services: postgres: From c153690c94b0d3663eddacacb8389deb744c13a5 Mon Sep 17 00:00:00 2001 From: David Benedeki Date: Tue, 25 Jun 2024 18:37:16 +0200 Subject: [PATCH 18/23] * 57 second time --- .github/workflows/jacoco_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jacoco_report.yml b/.github/workflows/jacoco_report.yml index fbdd3e90..e2bc37c3 100644 --- a/.github/workflows/jacoco_report.yml +++ b/.github/workflows/jacoco_report.yml @@ -105,7 +105,7 @@ jobs: script: | core.setFailed('Changed files coverage is less than ${{ 80.0 }}%!') - name: Fail PR if total files coverage is less than ${{ 57.0 }}% - if: ${{ steps.jacoco-core.outputs.coverage-overall < 75.0 || steps.jacoco-slick.outputs.coverage-overall < 75.0 || steps.jacoco-doobie.outputs.coverage-overall < 75.0 }} + if: ${{ steps.jacoco-core.outputs.coverage-overall < 57.0 || steps.jacoco-slick.outputs.coverage-overall < 57.0 || steps.jacoco-doobie.outputs.coverage-overall < 57.0 }} uses: actions/github-script@v6 with: script: | From ff55b0d8ad6ac58c7ddcbf15a0efe535f2534445 Mon Sep 17 00:00:00 2001 From: David Benedeki <14905969+benedeki@users.noreply.github.com> Date: Wed, 26 Jun 2024 09:42:24 +0200 Subject: [PATCH 19/23] Update jacoco_report.yml - PR comments --- .github/workflows/jacoco_report.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/jacoco_report.yml b/.github/workflows/jacoco_report.yml index e2bc37c3..c079d545 100644 --- a/.github/workflows/jacoco_report.yml +++ b/.github/workflows/jacoco_report.yml @@ -60,8 +60,8 @@ jobs: paths: > ${{ github.workspace }}/core/target/scala-${{ env.SCALA_SHORT_VERSION }}/jacoco/report/jacoco.xml token: ${{ secrets.GITHUB_TOKEN }} - min-coverage-overall: ${{ 57.0 }} - min-coverage-changed-files: ${{ 80.0 }} + min-coverage-overall: 57.0 + min-coverage-changed-files: 80.0 title: JaCoCo core code coverage report - scala ${{ env.SCALA_VERSION }} update-comment: true - name: Get the Coverage info @@ -110,4 +110,3 @@ jobs: with: script: | core.setFailed('Total files coverage is less than ${{ 57.0 }}%!') - From 824e160a19ac3b8263a1f12d6d9691257c4ff78a Mon Sep 17 00:00:00 2001 From: David Benedeki Date: Wed, 26 Jun 2024 17:07:00 +0200 Subject: [PATCH 20/23] * JaCoCo action rewritten --- .github/workflows/jacoco_report.yml | 139 ++++++++++++++++++---------- 1 file changed, 92 insertions(+), 47 deletions(-) diff --git a/.github/workflows/jacoco_report.yml b/.github/workflows/jacoco_report.yml index c079d545..3f71a6a1 100644 --- a/.github/workflows/jacoco_report.yml +++ b/.github/workflows/jacoco_report.yml @@ -17,21 +17,28 @@ name: JaCoCo Report on: - push: - branches: [master] pull_request: - types: [ assigned, opened, synchronize, reopened, labeled ] + branches: [ master ] + types: [ opened, edited, synchronize, reopened ] + +env: + scalaLong: 2.13.11 + scalaShort: 2.13 + coverage-overall: 80.0 + coverage-changed-files: 80.0 + check-overall-coverages: true jobs: build-test-and-measure: - name: "Build, Test and Measure" + name: Build, Test and Measure runs-on: ubuntu-latest + services: postgres: image: postgres:15 env: POSTGRES_PASSWORD: postgres - POSTGRES_DB: movies + POSTGRES_DB: atum_db options: >- --health-cmd pg_isready --health-interval 10s @@ -39,74 +46,112 @@ jobs: --health-retries 5 ports: - 5432:5432 - env: - SCALA_VERSION: "2.13.12" - SCALA_SHORT_VERSION: "2.13" + steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup Scala uses: olafurpg/setup-scala@v14 with: java-version: "adopt@1.8" - name: Prepare testing database run: sbt flywayMigrate - - name: Build and run all tests for code coverage - run: sbt ++${{env.SCALA_VERSION}} jacoco # We will need JaCoCo report in second job - - name: Add coverage to PR + - name: Build and run tests + continue-on-error: true + id: jacocorun + run: sbt ++${{env.scalaLong}} jacoco + - name: Add coverage to PR (core) + if: steps.jacocorun.outcome == 'success' id: jacoco-core uses: madrapps/jacoco-report@v1.6.1 with: - paths: > - ${{ github.workspace }}/core/target/scala-${{ env.SCALA_SHORT_VERSION }}/jacoco/report/jacoco.xml + paths: ${{ github.workspace }}/core/target/scala-${{ env.scalaShort }}/jacoco/report/jacoco.xml token: ${{ secrets.GITHUB_TOKEN }} - min-coverage-overall: 57.0 - min-coverage-changed-files: 80.0 - title: JaCoCo core code coverage report - scala ${{ env.SCALA_VERSION }} + min-coverage-overall: ${{ env.coverage-overall }} + min-coverage-changed-files: ${{ env.coverage-changed-files }} + title: JaCoCo `model` module code coverage report - scala ${{ env.scalaLong }} update-comment: true - - name: Get the Coverage info - run: | - echo "Total core core coverage ${{ steps.jacoco-core.outputs.coverage-overall }}" - echo "Changed core Files coverage ${{ steps.jacoco-core.outputs.coverage-changed-files }}" - - name: Add coverage to PR - id: jacoco-slick + - name: Add coverage to PR (doobie) + if: steps.jacocorun.outcome == 'success' + id: jacoco-doobie uses: madrapps/jacoco-report@v1.6.1 with: - paths: > - ${{ github.workspace }}/slick/target/scala-${{ env.SCALA_SHORT_VERSION }}/jacoco/report/jacoco.xml + paths: ${{ github.workspace }}/doobie/target/scala-${{ env.scalaShort }}/jacoco/report/jacoco.xml token: ${{ secrets.GITHUB_TOKEN }} - min-coverage-overall: ${{ 57.0 }} - min-coverage-changed-files: ${{ 80.0 }} - title: JaCoCo slick code coverage report - scala ${{ env.SCALA_VERSION }} + min-coverage-overall: ${{ env.coverage-overall }} + min-coverage-changed-files: ${{ env.coverage-changed-files }} + title: JaCoCo `agent` module code coverage report - scala ${{ env.scalaLong }} update-comment: true - - name: Get the Coverage info - run: | - echo "Total slick coverage ${{ steps.jacoco-slick.outputs.coverage-overall }}" - echo "Changed slick Files coverage ${{ steps.jacoco-slick.outputs.coverage-changed-files }}" - - name: Add coverage to PR - id: jacoco-doobie + - name: Add coverage to PR (slick) + if: steps.jacocorun.outcome == 'success' + id: jacoco-slick uses: madrapps/jacoco-report@v1.6.1 with: - paths: > - ${{ github.workspace }}/doobie/target/scala-${{ env.SCALA_SHORT_VERSION }}/jacoco/report/jacoco.xml + paths: ${{ github.workspace }}/slick/target/scala-${{ env.scalaShort }}/jacoco/report/jacoco.xml token: ${{ secrets.GITHUB_TOKEN }} - min-coverage-overall: ${{ 57.0 }} - min-coverage-changed-files: ${{ 80.0 }} - title: JaCoCo doobie code coverage report - scala ${{ env.SCALA_VERSION }} + min-coverage-overall: ${{env.coverage-overall }} + min-coverage-changed-files: ${{ env.coverage-changed-files }} + title: JaCoCo `slick` module code coverage report - scala ${{ env.scalaLong }} update-comment: true - name: Get the Coverage info + if: steps.jacocorun.outcome == 'success' run: | - echo "Total doobie coverage ${{ steps.jacoco-doobie.outputs.coverage-overall }}" - echo "Changed doobie Files coverage ${{ steps.jacoco-doobie.outputs.coverage-changed-files }}" - - name: Fail PR if changed files coverage is less than ${{ 80.0 }}% - if: ${{ steps.jacoco-core.outputs.coverage-changed-files < 80.0 || steps.jacoco-slick.outputs.coverage-changed-files < 80.0 || steps.jacoco-doobie.outputs.coverage-changed-files < 80.0 }} + echo "Total `core` module coverage ${{ steps.jacoco-core.outputs.coverage-overall }}" + echo "Changed Files coverage ${{ steps.jacoco-core.outputs.coverage-changed-files }}" + echo "Total `doobie` module coverage ${{ steps.jacoco-doobie.outputs.coverage-overall }}" + echo "Changed Files coverage ${{ steps.jacoco-doobie.outputs.coverage-changed-files }}" + echo "Total `slick` module coverage ${{ steps.jacoco-slick.outputs.coverage-overall }}" + echo "Changed Files coverage ${{ steps.jacoco-slick.outputs.coverage-changed-files }}" + - name: Fail PR if changed files coverage is less than ${{ env.coverage-changed-files }}% + if: steps.jacocorun.outcome == 'success' + uses: actions/github-script@v6 + with: + script: | + const coverageCheckFailed = + Number('${{ steps.jacoco-core.outputs.coverage-changed-files }}') < Number('${{ env.coverage-changed-files }}') || + Number('${{ steps.jacoco-doobie.outputs.coverage-changed-files }}') < Number('${{ env.coverage-changed-files }}') || + Number('${{ steps.jacoco-slick.outputs.coverage-changed-files }}') < Number('${{ env.coverage-changed-files }}'); + if (coverageCheckFailed) { + core.setFailed('Changed files coverage is less than ${{ env.coverage-changed-files }}%!'); + } + - name: Fail PR if overall files coverage is less than ${{ env.coverage-overall }}% + if: ${{ (steps.jacocorun.outcome == 'success') && (env.check-overall-coverages == 'true') }} uses: actions/github-script@v6 with: script: | - core.setFailed('Changed files coverage is less than ${{ 80.0 }}%!') - - name: Fail PR if total files coverage is less than ${{ 57.0 }}% - if: ${{ steps.jacoco-core.outputs.coverage-overall < 57.0 || steps.jacoco-slick.outputs.coverage-overall < 57.0 || steps.jacoco-doobie.outputs.coverage-overall < 57.0 }} + const coverageCheckFailed = + Number('${{ steps.jacoco-core.outputs.coverage-overall }}') < Number('${{ env.coverage-overall }}') || + Number('${{ steps.jacoco-doobie.outputs.coverage-overall }}') < Number('${{ env.coverage-overall }}') || + Number('${{ steps.jacoco-slick.outputs.coverage-overall }}') < Number('${{ env.coverage-overall }}'); + if (coverageCheckFailed) { + core.setFailed('Overall coverage is less than ${{ env.coverage-overall }}%!'); + } + - name: Edit JaCoCo comments on build failure + if: steps.jacocorun.outcome != 'success' uses: actions/github-script@v6 with: script: | - core.setFailed('Total files coverage is less than ${{ 57.0 }}%!') + 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.'); From d64c169172d284cec32819b4381266dc03170376 Mon Sep 17 00:00:00 2001 From: David Benedeki Date: Wed, 26 Jun 2024 17:12:48 +0200 Subject: [PATCH 21/23] * fixed test db name --- .github/workflows/jacoco_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jacoco_report.yml b/.github/workflows/jacoco_report.yml index 3f71a6a1..bf9025c6 100644 --- a/.github/workflows/jacoco_report.yml +++ b/.github/workflows/jacoco_report.yml @@ -38,7 +38,7 @@ jobs: image: postgres:15 env: POSTGRES_PASSWORD: postgres - POSTGRES_DB: atum_db + POSTGRES_DB: movies options: >- --health-cmd pg_isready --health-interval 10s From 32fc497f889488893da3b3e146214b026b088459 Mon Sep 17 00:00:00 2001 From: David Benedeki Date: Wed, 26 Jun 2024 17:38:22 +0200 Subject: [PATCH 22/23] * testing --- .github/workflows/jacoco_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jacoco_report.yml b/.github/workflows/jacoco_report.yml index bf9025c6..e5ec5b49 100644 --- a/.github/workflows/jacoco_report.yml +++ b/.github/workflows/jacoco_report.yml @@ -26,7 +26,7 @@ env: scalaShort: 2.13 coverage-overall: 80.0 coverage-changed-files: 80.0 - check-overall-coverages: true + check-overall-coverages: false jobs: build-test-and-measure: From afeee7cf8178e3363616bab1a26fb41691a2d614 Mon Sep 17 00:00:00 2001 From: David Benedeki Date: Wed, 26 Jun 2024 17:59:07 +0200 Subject: [PATCH 23/23] * testing finished --- .github/workflows/jacoco_report.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/jacoco_report.yml b/.github/workflows/jacoco_report.yml index e5ec5b49..bc629100 100644 --- a/.github/workflows/jacoco_report.yml +++ b/.github/workflows/jacoco_report.yml @@ -24,9 +24,9 @@ on: env: scalaLong: 2.13.11 scalaShort: 2.13 - coverage-overall: 80.0 + coverage-overall: 57.0 coverage-changed-files: 80.0 - check-overall-coverages: false + check-overall-coverages: true jobs: build-test-and-measure: