From 2a86ad369fd0087bdcd7513f6e048a1f662ac023 Mon Sep 17 00:00:00 2001 From: Nicolas Delsaux Date: Wed, 7 Dec 2022 13:42:13 +0100 Subject: [PATCH 01/11] Run tests in PR to have some infos --- ...n_pull_request_push_run_test_and_coverage.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .github/workflows/on_pull_request_push_run_test_and_coverage.yml diff --git a/.github/workflows/on_pull_request_push_run_test_and_coverage.yml b/.github/workflows/on_pull_request_push_run_test_and_coverage.yml new file mode 100644 index 00000000..bd3b923b --- /dev/null +++ b/.github/workflows/on_pull_request_push_run_test_and_coverage.yml @@ -0,0 +1,16 @@ +name: On pull request push, perform a build with test reports shown and coverage evaluated (and compared with master) +on: + pull_request: + +jobs: + build: + name: Build and Run Tests + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v1 + - name: Build and Run Tests + run: mvn test --batch-mode --fail-at-end + - name: Publish Test Report + if: ${{ always() }} + uses: scacap/action-surefire-report@v1 \ No newline at end of file From 5ccf5d6e6b78267cf0c5724090e6ff952adc12d9 Mon Sep 17 00:00:00 2001 From: Nicolas Delsaux Date: Wed, 7 Dec 2022 14:03:06 +0100 Subject: [PATCH 02/11] Better branch selection for both pull request and deploy --- .../workflows/on_pull_request_push_run_test_and_coverage.yml | 1 + .github/workflows/on_push_on_master_deploy_build.yml | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/on_pull_request_push_run_test_and_coverage.yml b/.github/workflows/on_pull_request_push_run_test_and_coverage.yml index bd3b923b..26a59c19 100644 --- a/.github/workflows/on_pull_request_push_run_test_and_coverage.yml +++ b/.github/workflows/on_pull_request_push_run_test_and_coverage.yml @@ -1,6 +1,7 @@ name: On pull request push, perform a build with test reports shown and coverage evaluated (and compared with master) on: pull_request: + branches_ignore: [ master ] jobs: build: diff --git a/.github/workflows/on_push_on_master_deploy_build.yml b/.github/workflows/on_push_on_master_deploy_build.yml index 2cd50778..137e1169 100644 --- a/.github/workflows/on_push_on_master_deploy_build.yml +++ b/.github/workflows/on_push_on_master_deploy_build.yml @@ -6,8 +6,6 @@ name: On master push perform build on: push: branches: [ master ] - pull_request: - branches: [ master ] # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages permissions: From ea55c9d27891f749175462c84344882126304cfa Mon Sep 17 00:00:00 2001 From: Nicolas Delsaux Date: Wed, 7 Dec 2022 14:15:35 +0100 Subject: [PATCH 03/11] This should be the best way to improve quality --- ...ull_request_push_run_test_and_coverage.yml | 28 +++++++++---- pom.xml | 42 +++++++++++++++++++ 2 files changed, 62 insertions(+), 8 deletions(-) diff --git a/.github/workflows/on_pull_request_push_run_test_and_coverage.yml b/.github/workflows/on_pull_request_push_run_test_and_coverage.yml index 26a59c19..5f98400c 100644 --- a/.github/workflows/on_pull_request_push_run_test_and_coverage.yml +++ b/.github/workflows/on_pull_request_push_run_test_and_coverage.yml @@ -5,13 +5,25 @@ on: jobs: build: - name: Build and Run Tests runs-on: ubuntu-latest steps: - - name: Checkout Code - uses: actions/checkout@v1 - - name: Build and Run Tests - run: mvn test --batch-mode --fail-at-end - - name: Publish Test Report - if: ${{ always() }} - uses: scacap/action-surefire-report@v1 \ No newline at end of file + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + distribution: adopt + java-version: 11 + cache: 'maven' + - name: Build with Maven + run: mvn -B test --file pom.xml -Pcoverage + env: + TOKEN_FOR_GITHUB: ${{ secrets.TOKEN_FOR_GITHUB }} + + - name: Add coverage to PR + id: jacoco + uses: madrapps/jacoco-report@v1.3 + with: + paths: ${{ github.workspace }}/build/reports/jacoco/testCoverage/testCoverage.xml + token: ${{ secrets.GITHUB_TOKEN }} + min-coverage-overall: 10 + min-coverage-changed-files: 50 \ No newline at end of file diff --git a/pom.xml b/pom.xml index bceb71bc..f6ad845a 100644 --- a/pom.xml +++ b/pom.xml @@ -284,6 +284,48 @@ + + coverage + + org.jacoco + jacoco-maven-plugin + 0.8.8 + + + default-prepare-agent + + prepare-agent + + + + default-report + + report + + + + default-check + + check + + + + + BUNDLE + + + COMPLEXITY + COVEREDRATIO + 0.0 + + + + + + + + + release From 8190351fa8045b30fe289021ddbfaae49c2d474f Mon Sep 17 00:00:00 2001 From: Nicolas Delsaux Date: Wed, 7 Dec 2022 14:19:26 +0100 Subject: [PATCH 04/11] Updated jacoco xml file path --- .../workflows/on_pull_request_push_run_test_and_coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on_pull_request_push_run_test_and_coverage.yml b/.github/workflows/on_pull_request_push_run_test_and_coverage.yml index 5f98400c..c51d89bb 100644 --- a/.github/workflows/on_pull_request_push_run_test_and_coverage.yml +++ b/.github/workflows/on_pull_request_push_run_test_and_coverage.yml @@ -23,7 +23,7 @@ jobs: id: jacoco uses: madrapps/jacoco-report@v1.3 with: - paths: ${{ github.workspace }}/build/reports/jacoco/testCoverage/testCoverage.xml + paths: ${{ github.workspace }}/**/target/site/jacoco/jacoco.xml token: ${{ secrets.GITHUB_TOKEN }} min-coverage-overall: 10 min-coverage-changed-files: 50 \ No newline at end of file From 7225534c73ef80c8b61f3c229e58f03acaa8dc5b Mon Sep 17 00:00:00 2001 From: Nicolas Delsaux Date: Wed, 7 Dec 2022 14:24:21 +0100 Subject: [PATCH 05/11] Damn ! POM was bad ! --- pom.xml | 82 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 43 insertions(+), 39 deletions(-) diff --git a/pom.xml b/pom.xml index f6ad845a..77de6a6a 100644 --- a/pom.xml +++ b/pom.xml @@ -286,45 +286,49 @@ coverage - - org.jacoco - jacoco-maven-plugin - 0.8.8 - - - default-prepare-agent - - prepare-agent - - - - default-report - - report - - - - default-check - - check - - - - - BUNDLE - - - COMPLEXITY - COVEREDRATIO - 0.0 - - - - - - - - + + + + org.jacoco + jacoco-maven-plugin + 0.8.8 + + + default-prepare-agent + + prepare-agent + + + + default-report + + report + + + + default-check + + check + + + + + BUNDLE + + + COMPLEXITY + COVEREDRATIO + 0.0 + + + + + + + + + + release From 378b692c69ad57328974e507e91edcc7795bd47f Mon Sep 17 00:00:00 2001 From: Nicolas Delsaux Date: Wed, 7 Dec 2022 14:29:30 +0100 Subject: [PATCH 06/11] Let's trigger a rebuild! --- .github/workflows/on_pull_request_push_run_test_and_coverage.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/on_pull_request_push_run_test_and_coverage.yml b/.github/workflows/on_pull_request_push_run_test_and_coverage.yml index c51d89bb..9aa37cb6 100644 --- a/.github/workflows/on_pull_request_push_run_test_and_coverage.yml +++ b/.github/workflows/on_pull_request_push_run_test_and_coverage.yml @@ -18,7 +18,6 @@ jobs: run: mvn -B test --file pom.xml -Pcoverage env: TOKEN_FOR_GITHUB: ${{ secrets.TOKEN_FOR_GITHUB }} - - name: Add coverage to PR id: jacoco uses: madrapps/jacoco-report@v1.3 From b57a3e1a5f3ff0378cb3c407e9084fb60ce566ff Mon Sep 17 00:00:00 2001 From: Nicolas Delsaux Date: Wed, 7 Dec 2022 14:35:09 +0100 Subject: [PATCH 07/11] Let's try this way! --- .../on_pull_request_push_run_test_and_coverage.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/on_pull_request_push_run_test_and_coverage.yml b/.github/workflows/on_pull_request_push_run_test_and_coverage.yml index 9aa37cb6..a224bd56 100644 --- a/.github/workflows/on_pull_request_push_run_test_and_coverage.yml +++ b/.github/workflows/on_pull_request_push_run_test_and_coverage.yml @@ -22,7 +22,19 @@ jobs: id: jacoco uses: madrapps/jacoco-report@v1.3 with: - paths: ${{ github.workspace }}/**/target/site/jacoco/jacoco.xml + paths: + - ${{ github.workspace }}/aadarchi-maven-plugin/target/site/jacoco/jacoco.xml + - ${{ github.workspace }}/adr-tickets-extractor/target/site/jacoco/jacoco.xml + - ${{ github.workspace }}/base/target/site/jacoco/jacoco.xml + - ${{ github.workspace }}/cdi-config-extension/target/site/jacoco/jacoco.xml + - ${{ github.workspace }}/cdi-in-maven-plugin-helper/target/site/jacoco/jacoco.xml + - ${{ github.workspace }}/github-scm-handler/target/site/jacoco/jacoco.xml + - ${{ github.workspace }}/gitlab-scm-handler/target/site/jacoco/jacoco.xml + - ${{ github.workspace }}/markdown-to-asciidoc/target/site/jacoco/jacoco.xml + - ${{ github.workspace }}/maven-metadata-inferer/target/site/jacoco/jacoco.xml + - ${{ github.workspace }}/sequence-diagram-generator/target/site/jacoco/jacoco.xml + - ${{ github.workspace }}/spring-components-detector/target/site/jacoco/jacoco.xml + - ${{ github.workspace }}/structurizr-components-detector/target/site/jacoco/jacoco.xml token: ${{ secrets.GITHUB_TOKEN }} min-coverage-overall: 10 min-coverage-changed-files: 50 \ No newline at end of file From d4a0975d074b9767d8d87060b95d8e4ec6cd1676 Mon Sep 17 00:00:00 2001 From: Nicolas Delsaux Date: Wed, 7 Dec 2022 14:37:25 +0100 Subject: [PATCH 08/11] oh crap, yaml syntax is such a hell! --- ...ull_request_push_run_test_and_coverage.yml | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/on_pull_request_push_run_test_and_coverage.yml b/.github/workflows/on_pull_request_push_run_test_and_coverage.yml index a224bd56..bd1ec123 100644 --- a/.github/workflows/on_pull_request_push_run_test_and_coverage.yml +++ b/.github/workflows/on_pull_request_push_run_test_and_coverage.yml @@ -22,19 +22,19 @@ jobs: id: jacoco uses: madrapps/jacoco-report@v1.3 with: - paths: - - ${{ github.workspace }}/aadarchi-maven-plugin/target/site/jacoco/jacoco.xml - - ${{ github.workspace }}/adr-tickets-extractor/target/site/jacoco/jacoco.xml - - ${{ github.workspace }}/base/target/site/jacoco/jacoco.xml - - ${{ github.workspace }}/cdi-config-extension/target/site/jacoco/jacoco.xml - - ${{ github.workspace }}/cdi-in-maven-plugin-helper/target/site/jacoco/jacoco.xml - - ${{ github.workspace }}/github-scm-handler/target/site/jacoco/jacoco.xml - - ${{ github.workspace }}/gitlab-scm-handler/target/site/jacoco/jacoco.xml - - ${{ github.workspace }}/markdown-to-asciidoc/target/site/jacoco/jacoco.xml - - ${{ github.workspace }}/maven-metadata-inferer/target/site/jacoco/jacoco.xml - - ${{ github.workspace }}/sequence-diagram-generator/target/site/jacoco/jacoco.xml - - ${{ github.workspace }}/spring-components-detector/target/site/jacoco/jacoco.xml - - ${{ github.workspace }}/structurizr-components-detector/target/site/jacoco/jacoco.xml + paths: | + ${{ github.workspace }}/aadarchi-maven-plugin/target/site/jacoco/jacoco.xml, + ${{ github.workspace }}/adr-tickets-extractor/target/site/jacoco/jacoco.xml, + ${{ github.workspace }}/base/target/site/jacoco/jacoco.xml, + ${{ github.workspace }}/cdi-config-extension/target/site/jacoco/jacoco.xml, + ${{ github.workspace }}/cdi-in-maven-plugin-helper/target/site/jacoco/jacoco.xml, + ${{ github.workspace }}/github-scm-handler/target/site/jacoco/jacoco.xml, + ${{ github.workspace }}/gitlab-scm-handler/target/site/jacoco/jacoco.xml, + ${{ github.workspace }}/markdown-to-asciidoc/target/site/jacoco/jacoco.xml, + ${{ github.workspace }}/maven-metadata-inferer/target/site/jacoco/jacoco.xml, + ${{ github.workspace }}/sequence-diagram-generator/target/site/jacoco/jacoco.xml, + ${{ github.workspace }}/spring-components-detector/target/site/jacoco/jacoco.xml, + ${{ github.workspace }}/structurizr-components-detector/target/site/jacoco/jacoco.xml token: ${{ secrets.GITHUB_TOKEN }} min-coverage-overall: 10 min-coverage-changed-files: 50 \ No newline at end of file From 7ad54253dc24e5a234280c883e925485af70c73f Mon Sep 17 00:00:00 2001 From: Nicolas Delsaux Date: Wed, 7 Dec 2022 14:40:20 +0100 Subject: [PATCH 09/11] Can you believe it fails when the file is missing? Me neither --- .../on_pull_request_push_run_test_and_coverage.yml | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/.github/workflows/on_pull_request_push_run_test_and_coverage.yml b/.github/workflows/on_pull_request_push_run_test_and_coverage.yml index bd1ec123..2ce191bd 100644 --- a/.github/workflows/on_pull_request_push_run_test_and_coverage.yml +++ b/.github/workflows/on_pull_request_push_run_test_and_coverage.yml @@ -23,18 +23,11 @@ jobs: uses: madrapps/jacoco-report@v1.3 with: paths: | - ${{ github.workspace }}/aadarchi-maven-plugin/target/site/jacoco/jacoco.xml, - ${{ github.workspace }}/adr-tickets-extractor/target/site/jacoco/jacoco.xml, ${{ github.workspace }}/base/target/site/jacoco/jacoco.xml, - ${{ github.workspace }}/cdi-config-extension/target/site/jacoco/jacoco.xml, - ${{ github.workspace }}/cdi-in-maven-plugin-helper/target/site/jacoco/jacoco.xml, - ${{ github.workspace }}/github-scm-handler/target/site/jacoco/jacoco.xml, - ${{ github.workspace }}/gitlab-scm-handler/target/site/jacoco/jacoco.xml, + ${{ github.workspace }}/architecture-documentation/target/site/jacoco/jacoco.xml, ${{ github.workspace }}/markdown-to-asciidoc/target/site/jacoco/jacoco.xml, ${{ github.workspace }}/maven-metadata-inferer/target/site/jacoco/jacoco.xml, - ${{ github.workspace }}/sequence-diagram-generator/target/site/jacoco/jacoco.xml, - ${{ github.workspace }}/spring-components-detector/target/site/jacoco/jacoco.xml, - ${{ github.workspace }}/structurizr-components-detector/target/site/jacoco/jacoco.xml + ${{ github.workspace }}/sequence-diagram-generator/target/site/jacoco/jacoco.xml token: ${{ secrets.GITHUB_TOKEN }} min-coverage-overall: 10 min-coverage-changed-files: 50 \ No newline at end of file From 8b76f0b55c80deb9d1a746c68e7ff73930390df4 Mon Sep 17 00:00:00 2001 From: Nicolas Delsaux Date: Wed, 7 Dec 2022 14:59:00 +0100 Subject: [PATCH 10/11] Updated config to have the report generated --- pom.xml | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/pom.xml b/pom.xml index 77de6a6a..15f33989 100644 --- a/pom.xml +++ b/pom.xml @@ -294,37 +294,18 @@ 0.8.8 - default-prepare-agent + Jacoco - prepare agent prepare-agent - default-report + Jacoco - generate report + test report - - default-check - - check - - - - - BUNDLE - - - COMPLEXITY - COVEREDRATIO - 0.0 - - - - - - From 0ac2199ca9f5eeaba36661f16f23525512a77d44 Mon Sep 17 00:00:00 2001 From: Nicolas Delsaux Date: Wed, 7 Dec 2022 15:02:49 +0100 Subject: [PATCH 11/11] oops, a YAML typo! --- .../workflows/on_pull_request_push_run_test_and_coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on_pull_request_push_run_test_and_coverage.yml b/.github/workflows/on_pull_request_push_run_test_and_coverage.yml index 2ce191bd..1a30763a 100644 --- a/.github/workflows/on_pull_request_push_run_test_and_coverage.yml +++ b/.github/workflows/on_pull_request_push_run_test_and_coverage.yml @@ -1,7 +1,7 @@ name: On pull request push, perform a build with test reports shown and coverage evaluated (and compared with master) on: pull_request: - branches_ignore: [ master ] + branches-ignore: [ master ] jobs: build: