From 29d9973163c77da97bc2984808ee142f54daa47d Mon Sep 17 00:00:00 2001 From: Tanmay Deobhankar Date: Tue, 8 Jul 2025 15:32:34 +0530 Subject: [PATCH 1/8] enhance(workflow): updating the test-coverage workflow --- .github/workflows/testcase-coverage.yml | 39 +++++++++++++++++++++---- 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/.github/workflows/testcase-coverage.yml b/.github/workflows/testcase-coverage.yml index 0231aa8..7fcfd1a 100644 --- a/.github/workflows/testcase-coverage.yml +++ b/.github/workflows/testcase-coverage.yml @@ -5,20 +5,27 @@ on: branches: - master - develop - + pull_request_target: + branches: + - master + - develop + permissions: contents: read pull-requests: write issues: write - + jobs: - Build: + build-and-test-pr: runs-on: ubuntu-latest + permissions: + contents: read steps: - - name: Checkout code + - name: Checkout PR Head uses: actions/checkout@v4 with: + ref: ${{ github.event.pull_request.head.sha }} fetch-depth: 0 - name: Setup JDK 17 @@ -27,7 +34,7 @@ jobs: java-version: '17' distribution: 'temurin' - - name: Build with Maven + - name: Build with Maven and Run Tests run: | mvn clean verify -Dmaven.test.failure.ignore=false @@ -38,7 +45,27 @@ jobs: path: target/site/jacoco/jacoco.xml if-no-files-found: warn - - name: Compare JaCoCo Coverage + post-coverage-comment: + runs-on: ubuntu-latest + needs: build-and-test-pr + permissions: + pull-requests: write + contents: read + + steps: + - name: Checkout Base Branch (for JaCoCo action context) + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.base.ref }} + fetch-depth: 0 + + - name: Download JaCoCo Report Artifact + uses: actions/download-artifact@v4 + with: + name: jacoco-report + path: target/site/jacoco/ + + - name: Compare JaCoCo Coverage and Post Comment uses: madrapps/jacoco-report@v1.7.2 with: paths: ${{ github.workspace }}/target/site/jacoco/jacoco.xml From ab0ef30cac5cdb61e31251040650d07096642564 Mon Sep 17 00:00:00 2001 From: Tanmay Deobhankar Date: Tue, 8 Jul 2025 15:50:24 +0530 Subject: [PATCH 2/8] fix(workflow):codeRabbit suggestion --- .github/workflows/testcase-coverage.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/testcase-coverage.yml b/.github/workflows/testcase-coverage.yml index 7fcfd1a..6ec8299 100644 --- a/.github/workflows/testcase-coverage.yml +++ b/.github/workflows/testcase-coverage.yml @@ -9,6 +9,8 @@ on: branches: - master - develop + paths-ignore: + - '**' permissions: contents: read @@ -17,6 +19,7 @@ permissions: jobs: build-and-test-pr: + if: github.event_name == 'pull_request' runs-on: ubuntu-latest permissions: contents: read @@ -46,6 +49,7 @@ jobs: if-no-files-found: warn post-coverage-comment: + if: github.event_name == 'pull_request_target' runs-on: ubuntu-latest needs: build-and-test-pr permissions: From ea2db609d7fc95bee16fb8a44da826fa73c1e9e5 Mon Sep 17 00:00:00 2001 From: Tanmay Deobhankar Date: Tue, 8 Jul 2025 15:59:01 +0530 Subject: [PATCH 3/8] empty commit to check trigger of new workflow --- .github/workflows/testcase-coverage.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/testcase-coverage.yml b/.github/workflows/testcase-coverage.yml index 6ec8299..c4b3671 100644 --- a/.github/workflows/testcase-coverage.yml +++ b/.github/workflows/testcase-coverage.yml @@ -17,6 +17,8 @@ permissions: pull-requests: write issues: write + + jobs: build-and-test-pr: if: github.event_name == 'pull_request' From 8ddbdc5387d15d0335c9b762f453052b70124748 Mon Sep 17 00:00:00 2001 From: Tanmay Deobhankar Date: Tue, 8 Jul 2025 16:03:47 +0530 Subject: [PATCH 4/8] test - fixed workflow --- .github/workflows/testcase-coverage.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/testcase-coverage.yml b/.github/workflows/testcase-coverage.yml index c4b3671..1600ad3 100644 --- a/.github/workflows/testcase-coverage.yml +++ b/.github/workflows/testcase-coverage.yml @@ -9,19 +9,14 @@ on: branches: - master - develop - paths-ignore: - - '**' permissions: contents: read pull-requests: write issues: write - - jobs: build-and-test-pr: - if: github.event_name == 'pull_request' runs-on: ubuntu-latest permissions: contents: read From 38dead1bc52da25951feeda326b5e17e8d855889 Mon Sep 17 00:00:00 2001 From: Zapper9982 Date: Wed, 20 Aug 2025 13:24:44 +0530 Subject: [PATCH 5/8] fix(workflow): adding write permission to pull request --- .github/workflows/testcase-coverage.yml | 53 ++++++------------------- 1 file changed, 13 insertions(+), 40 deletions(-) diff --git a/.github/workflows/testcase-coverage.yml b/.github/workflows/testcase-coverage.yml index 1600ad3..a229f4c 100644 --- a/.github/workflows/testcase-coverage.yml +++ b/.github/workflows/testcase-coverage.yml @@ -1,74 +1,47 @@ name: TestCase Coverage Check - on: pull_request: branches: - master - develop - pull_request_target: - branches: - - master - - develop - + permissions: contents: read pull-requests: write issues: write - + checks: write + jobs: - build-and-test-pr: + Build: runs-on: ubuntu-latest - permissions: - contents: read - steps: - - name: Checkout PR Head + - name: Checkout code uses: actions/checkout@v4 with: - ref: ${{ github.event.pull_request.head.sha }} fetch-depth: 0 - + - name: Setup JDK 17 uses: actions/setup-java@v4 with: java-version: '17' distribution: 'temurin' - - - name: Build with Maven and Run Tests + + - name: Build with Maven run: | mvn clean verify -Dmaven.test.failure.ignore=false - + - name: Upload JaCoCo Report Artifact uses: actions/upload-artifact@v4 with: name: jacoco-report path: target/site/jacoco/jacoco.xml if-no-files-found: warn - - post-coverage-comment: - if: github.event_name == 'pull_request_target' - runs-on: ubuntu-latest - needs: build-and-test-pr - permissions: - pull-requests: write - contents: read - - steps: - - name: Checkout Base Branch (for JaCoCo action context) - uses: actions/checkout@v4 - with: - ref: ${{ github.event.pull_request.base.ref }} - fetch-depth: 0 - - - name: Download JaCoCo Report Artifact - uses: actions/download-artifact@v4 - with: - name: jacoco-report - path: target/site/jacoco/ - - - name: Compare JaCoCo Coverage and Post Comment + + - name: Compare JaCoCo Coverage uses: madrapps/jacoco-report@v1.7.2 with: paths: ${{ github.workspace }}/target/site/jacoco/jacoco.xml token: ${{ secrets.GITHUB_TOKEN }} min-coverage-overall: 0 + update-comment: true + title: 'Code Coverage Report' \ No newline at end of file From b5d249b782235c0db305819406c9a8af62f2db5d Mon Sep 17 00:00:00 2001 From: Zapper9982 Date: Tue, 2 Sep 2025 23:28:06 +0530 Subject: [PATCH 6/8] test(workflow):workflow working --- .github/workflows/testcase-coverage.yml | 29 +++++++++++-------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/.github/workflows/testcase-coverage.yml b/.github/workflows/testcase-coverage.yml index a229f4c..45da700 100644 --- a/.github/workflows/testcase-coverage.yml +++ b/.github/workflows/testcase-coverage.yml @@ -1,16 +1,13 @@ name: TestCase Coverage Check on: - pull_request: - branches: - - master - - develop - + pull_request_target: + + permissions: contents: read pull-requests: write - issues: write - checks: write - + actions: read + jobs: Build: runs-on: ubuntu-latest @@ -18,30 +15,30 @@ jobs: - name: Checkout code uses: actions/checkout@v4 with: + ref: ${{ github.event.pull_request.head.sha }} fetch-depth: 0 - + - name: Setup JDK 17 uses: actions/setup-java@v4 with: java-version: '17' distribution: 'temurin' - + - name: Build with Maven - run: | - mvn clean verify -Dmaven.test.failure.ignore=false - + run: mvn clean verify + - name: Upload JaCoCo Report Artifact uses: actions/upload-artifact@v4 with: name: jacoco-report path: target/site/jacoco/jacoco.xml if-no-files-found: warn - + - name: Compare JaCoCo Coverage uses: madrapps/jacoco-report@v1.7.2 with: paths: ${{ github.workspace }}/target/site/jacoco/jacoco.xml token: ${{ secrets.GITHUB_TOKEN }} min-coverage-overall: 0 - update-comment: true - title: 'Code Coverage Report' \ No newline at end of file + title: Code Coverage Report + comment-type: pr_comment \ No newline at end of file From 732352e02a09324a059106fe509df09f1d99a1c6 Mon Sep 17 00:00:00 2001 From: Zapper9982 Date: Wed, 3 Sep 2025 18:14:14 +0530 Subject: [PATCH 7/8] test(workflow): making required changes --- .github/workflows/testcase-coverage.yml | 64 ++++++++++++++++++------- 1 file changed, 47 insertions(+), 17 deletions(-) diff --git a/.github/workflows/testcase-coverage.yml b/.github/workflows/testcase-coverage.yml index 45da700..ec92674 100644 --- a/.github/workflows/testcase-coverage.yml +++ b/.github/workflows/testcase-coverage.yml @@ -1,44 +1,74 @@ name: TestCase Coverage Check on: - pull_request_target: - + pull_request: + types: [opened, synchronize, reopened] + pull_request_target: + types: [opened, synchronize, reopened] permissions: contents: read pull-requests: write - actions: read + actions: read + checks: write jobs: - Build: + coverage-check: runs-on: ubuntu-latest + steps: - - name: Checkout code + - name: Checkout PR code uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} fetch-depth: 0 - + repository: ${{ github.event.pull_request.head.repo.full_name }} + - name: Setup JDK 17 uses: actions/setup-java@v4 with: java-version: '17' distribution: 'temurin' - - - name: Build with Maven - run: mvn clean verify - + cache: maven + + - name: Cache Maven dependencies + uses: actions/cache@v3 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + + - name: Build and run tests with Maven + run: | + mvn clean compile test-compile + mvn test jacoco:report + env: + MAVEN_OPTS: "-Dmaven.repo.local=~/.m2/repository" + + - name: Verify JaCoCo report exists + run: | + if [ ! -f "target/site/jacoco/jacoco.xml" ]; then + echo "JaCoCo report not found. Checking alternative locations..." + find . -name "jacoco.xml" -type f || echo "No jacoco.xml found anywhere" + exit 1 + fi + echo "JaCoCo report found at target/site/jacoco/jacoco.xml" + - name: Upload JaCoCo Report Artifact uses: actions/upload-artifact@v4 with: - name: jacoco-report - path: target/site/jacoco/jacoco.xml - if-no-files-found: warn - - - name: Compare JaCoCo Coverage + name: jacoco-report-${{ github.event.pull_request.number }} + path: target/site/jacoco/ + retention-days: 30 + if-no-files-found: error + + - name: Add coverage report to PR uses: madrapps/jacoco-report@v1.7.2 with: paths: ${{ github.workspace }}/target/site/jacoco/jacoco.xml token: ${{ secrets.GITHUB_TOKEN }} min-coverage-overall: 0 - title: Code Coverage Report - comment-type: pr_comment \ No newline at end of file + min-coverage-changed-files: 0 + title: 📊 Code Coverage Report + update-comment: true + comment-type: pr_comment + skip-if-no-changes: false \ No newline at end of file From b7aba75165238fd457e5d8600900debb6666d146 Mon Sep 17 00:00:00 2001 From: Zapper9982 Date: Wed, 3 Sep 2025 23:51:21 +0530 Subject: [PATCH 8/8] test(workflow):making changes so that PR comment posted on PR's not from fork --- .github/workflows/testcase-coverage.yml | 72 ++++++++----------------- 1 file changed, 21 insertions(+), 51 deletions(-) diff --git a/.github/workflows/testcase-coverage.yml b/.github/workflows/testcase-coverage.yml index ec92674..cb60ac2 100644 --- a/.github/workflows/testcase-coverage.yml +++ b/.github/workflows/testcase-coverage.yml @@ -1,74 +1,44 @@ name: TestCase Coverage Check + on: pull_request: - types: [opened, synchronize, reopened] - pull_request_target: - types: [opened, synchronize, reopened] + types: [opened, synchronize] -permissions: - contents: read - pull-requests: write - actions: read - checks: write +permissions: {} jobs: - coverage-check: + build_and_check_coverage: runs-on: ubuntu-latest - + permissions: + contents: read + steps: - - name: Checkout PR code + - name: Checkout code uses: actions/checkout@v4 - with: - ref: ${{ github.event.pull_request.head.sha }} - fetch-depth: 0 - repository: ${{ github.event.pull_request.head.repo.full_name }} - + - name: Setup JDK 17 uses: actions/setup-java@v4 with: java-version: '17' distribution: 'temurin' - cache: maven - + - name: Cache Maven dependencies uses: actions/cache@v3 with: path: ~/.m2 key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2 - - - name: Build and run tests with Maven - run: | - mvn clean compile test-compile - mvn test jacoco:report - env: - MAVEN_OPTS: "-Dmaven.repo.local=~/.m2/repository" - - - name: Verify JaCoCo report exists - run: | - if [ ! -f "target/site/jacoco/jacoco.xml" ]; then - echo "JaCoCo report not found. Checking alternative locations..." - find . -name "jacoco.xml" -type f || echo "No jacoco.xml found anywhere" - exit 1 - fi - echo "JaCoCo report found at target/site/jacoco/jacoco.xml" - - - name: Upload JaCoCo Report Artifact - uses: actions/upload-artifact@v4 - with: - name: jacoco-report-${{ github.event.pull_request.number }} - path: target/site/jacoco/ - retention-days: 30 - if-no-files-found: error - - - name: Add coverage report to PR + restore-keys: | + ${{ runner.os }}-m2- + + - name: Build with Maven + run: mvn clean verify + + - name: Run Coverage Check uses: madrapps/jacoco-report@v1.7.2 with: - paths: ${{ github.workspace }}/target/site/jacoco/jacoco.xml + paths: target/site/jacoco/jacoco.xml token: ${{ secrets.GITHUB_TOKEN }} - min-coverage-overall: 0 - min-coverage-changed-files: 0 - title: 📊 Code Coverage Report - update-comment: true + min-coverage-overall: 40 + min-coverage-changed-files: 60 + title: Code Coverage Report comment-type: pr_comment - skip-if-no-changes: false \ No newline at end of file