From 64f58923119e78ae3b3e6a16befff5a91aede0c0 Mon Sep 17 00:00:00 2001 From: miryamfoiferCX Date: Thu, 9 Jan 2025 10:43:26 +0200 Subject: [PATCH 1/8] add code coverage to integration tests --- .github/workflows/ci.yml | 12 +++++++++++- pom.xml | 19 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 15a711be..5aed52bc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,4 +29,14 @@ jobs: - name: Build with Maven run: mvn -B package --file pom.xml -s $GITHUB_WORKSPACE/settings.xml env: - GITHUB_TOKEN: ${{ github.token }} \ No newline at end of file + GITHUB_TOKEN: ${{ github.token }} + + - name: Run tests with coverage + run: mvn test jacoco:report + + - name: Upload coverage report + uses: actions/upload-artifact@v3 + with: + name: coverage-report + path: target/site/jacoco + diff --git a/pom.xml b/pom.xml index 3254157a..b427a422 100644 --- a/pom.xml +++ b/pom.xml @@ -234,6 +234,25 @@ false + + org.jacoco + jacoco-maven-plugin + 0.8.8 + + + + prepare-agent + + + + report + test + + report + + + + From 8f06d493bc6044499da7c77ba964fd34ac80cf43 Mon Sep 17 00:00:00 2001 From: miryamfoiferCX Date: Thu, 9 Jan 2025 12:27:58 +0200 Subject: [PATCH 2/8] print coverage report --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5aed52bc..4564ae87 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,6 +34,9 @@ jobs: - name: Run tests with coverage run: mvn test jacoco:report + - name: Print coverage report + run: cat target/site/jacoco/index.html + - name: Upload coverage report uses: actions/upload-artifact@v3 with: From 99bc5077516b8ef7c7d93c23e12f00f377ad82ea Mon Sep 17 00:00:00 2001 From: miryamfoiferCX Date: Thu, 9 Jan 2025 12:48:00 +0200 Subject: [PATCH 3/8] print total coverage report --- .github/workflows/ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4564ae87..179e551e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,8 +34,10 @@ jobs: - name: Run tests with coverage run: mvn test jacoco:report - - name: Print coverage report - run: cat target/site/jacoco/index.html + - name: Print total number of covered lines + run: | + COVERED_LINES=$(xmllint --xpath "string(//report/counter[@type='LINE']/@covered)" target/site/jacoco/jacoco.xml) + echo "Total number of covered lines: $COVERED_LINES" - name: Upload coverage report uses: actions/upload-artifact@v3 From c035b015cad0857bd49bdeab7b1cb0a3cf5029fd Mon Sep 17 00:00:00 2001 From: miryamfoiferCX Date: Thu, 9 Jan 2025 13:15:44 +0200 Subject: [PATCH 4/8] install xmllint --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 179e551e..d3ad9b89 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,6 +26,9 @@ jobs: server-id: github settings-path: ${{ github.workspace }} + - name: Install xmllint + run: sudo apt-get install -y libxml2-utils + - name: Build with Maven run: mvn -B package --file pom.xml -s $GITHUB_WORKSPACE/settings.xml env: From 79c60e49158624f106e174c4a47249e56a7d4cf1 Mon Sep 17 00:00:00 2001 From: miryamfoiferCX Date: Thu, 9 Jan 2025 13:29:54 +0200 Subject: [PATCH 5/8] total coverage percentage --- .github/workflows/ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d3ad9b89..13ab5a24 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,7 +40,10 @@ jobs: - name: Print total number of covered lines run: | COVERED_LINES=$(xmllint --xpath "string(//report/counter[@type='LINE']/@covered)" target/site/jacoco/jacoco.xml) - echo "Total number of covered lines: $COVERED_LINES" + MISSED_LINES=$(xmllint --xpath "string(//report/counter[@type='LINE']/@missed)" target/site/jacoco/jacoco.xml) + TOTAL_LINES=$((COVERED_LINES + MISSED_LINES)) + COVERAGE_PERCENTAGE=$(echo "scale=2; $COVERED_LINES / $TOTAL_LINES * 100" | bc) + echo "Total coverage percentage: $COVERAGE_PERCENTAGE%" - name: Upload coverage report uses: actions/upload-artifact@v3 From c5e3d8576f04e832f3443f641728f91a608c0468 Mon Sep 17 00:00:00 2001 From: miryamfoiferCX Date: Thu, 9 Jan 2025 14:26:31 +0200 Subject: [PATCH 6/8] add github token --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 13ab5a24..d4b0eb97 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,6 +14,7 @@ jobs: CX_TENANT: ${{ secrets.CX_TENANT }} CX_CLIENT_ID: ${{ secrets.CX_CLIENT_ID }} CX_CLIENT_SECRET: ${{ secrets.CX_CLIENT_SECRET }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - name: Checkout uses: actions/checkout@v4 @@ -37,7 +38,7 @@ jobs: - name: Run tests with coverage run: mvn test jacoco:report - - name: Print total number of covered lines + - name: Print total coverage percentage run: | COVERED_LINES=$(xmllint --xpath "string(//report/counter[@type='LINE']/@covered)" target/site/jacoco/jacoco.xml) MISSED_LINES=$(xmllint --xpath "string(//report/counter[@type='LINE']/@missed)" target/site/jacoco/jacoco.xml) @@ -49,5 +50,4 @@ jobs: uses: actions/upload-artifact@v3 with: name: coverage-report - path: target/site/jacoco - + path: target/site/jacoco \ No newline at end of file From c19e07c4869ce0abbb40448acf26ed6b4ebe660d Mon Sep 17 00:00:00 2001 From: miryamfoiferCX Date: Thu, 9 Jan 2025 14:44:33 +0200 Subject: [PATCH 7/8] include only functional files --- pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pom.xml b/pom.xml index b427a422..f8a42e62 100644 --- a/pom.xml +++ b/pom.xml @@ -250,6 +250,12 @@ report + + + **/src/main/java/** + + + From 1e35c789cfe86c035187532870d9a042047da6ba Mon Sep 17 00:00:00 2001 From: miryamfoiferCX Date: Sun, 12 Jan 2025 12:36:53 +0200 Subject: [PATCH 8/8] Update upload artifact to v4 --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d4b0eb97..48d101bc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,7 +47,7 @@ jobs: echo "Total coverage percentage: $COVERAGE_PERCENTAGE%" - name: Upload coverage report - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: coverage-report - path: target/site/jacoco \ No newline at end of file + path: target/site/jacoco