From 682863600f7d2f28980ee5079c15da754ca1be7b Mon Sep 17 00:00:00 2001 From: Dinitha Wijewardhana Date: Sat, 4 Apr 2026 13:23:31 +0530 Subject: [PATCH 1/2] Add codecov config --- .github/workflows/coverage-generator.yml | 177 +++++++++++++++++++++++ .github/workflows/pr-builder.yml | 10 +- codecov.yml | 15 ++ 3 files changed, 200 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/coverage-generator.yml create mode 100644 codecov.yml diff --git a/.github/workflows/coverage-generator.yml b/.github/workflows/coverage-generator.yml new file mode 100644 index 0000000..0cb7151 --- /dev/null +++ b/.github/workflows/coverage-generator.yml @@ -0,0 +1,177 @@ +name: Code Coverage Generator + +on: + workflow_dispatch: + schedule: + # Daily 22:00 UTC (3.30 AM SL time). + - cron: '00 22 * * *' + +jobs: + build-source: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Adopt JDK 21 + uses: actions/setup-java@v4 + with: + java-version: 21 + distribution: "adopt" + + - name: Build with Maven + run: | + mvn clean install -U -B -Dmaven.test.skip=true + + - name: Cache source code + uses: actions/cache@v4 + with: + path: . + key: ${{ runner.os }}-source-${{ github.sha }} + + oidc-conformance-report: + needs: build-source + runs-on: ubuntu-latest + + steps: + - name: Restore source code + uses: actions/cache@v4 + with: + path: . + key: ${{ runner.os }}-source-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-source- + + - name: Get the latest Jacoco report URL + id: get-artifact-url-oidc + run: | + GITHUB_API_URL="https://api.github.com" + OWNER="wso2" + REPO="product-is" + WORKFLOW_ID="oidc-conformance-test.yml" + GITHUB_TOKEN="${{ secrets.GITHUB_TOKEN }}" + + # Get the latest successful workflow run + WORKFLOW_RUNS=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "$GITHUB_API_URL/repos/$OWNER/$REPO/actions/workflows/$WORKFLOW_ID/runs?status=success&per_page=1") + RUN_ID=$(echo $WORKFLOW_RUNS | jq -r '.workflow_runs[0].id') + + if [ "$RUN_ID" == "null" ]; then + echo "No successful workflow runs found" + exit 1 + fi + + # Get the artifacts for the workflow run + ARTIFACTS=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "$GITHUB_API_URL/repos/$OWNER/$REPO/actions/runs/$RUN_ID/artifacts") + ARTIFACT_URL=$(echo $ARTIFACTS | jq -r '.artifacts[] | select(.name == "jacoco-xml") | .archive_download_url') + + if [ "$ARTIFACT_URL" == "null" ]; then + echo "Artifact not found" + exit 1 + fi + + echo "::set-output name=artifact-url::$ARTIFACT_URL" + + - name: Download latest Jacoco report + run: | + curl -L -o artifact-oidc.zip \ + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + ${{ steps.get-artifact-url-oidc.outputs.artifact-url }} + + - name: Unzip Jacoco report + run: | + unzip artifact-oidc.zip -d ./artifacts-oidc + + - name: Upload coverage reports to Codecov for OIDC + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ./artifacts-oidc/jacoco.xml + flags: conformance-oidc + disable_search: true + + fapi-conformance-report: + needs: build-source + runs-on: ubuntu-latest + + steps: + - name: Restore source code + uses: actions/cache@v4 + with: + path: . + key: ${{ runner.os }}-source-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-source- + + - name: Get the latest Jacoco report URL + id: get-artifact-url-fapi + run: | + GITHUB_API_URL="https://api.github.com" + OWNER="wso2" + REPO="product-is" + WORKFLOW_ID="fapi-oidc-conformance-test.yml" + GITHUB_TOKEN="${{ secrets.GITHUB_TOKEN }}" + + # Get the latest successful workflow run + WORKFLOW_RUNS=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "$GITHUB_API_URL/repos/$OWNER/$REPO/actions/workflows/$WORKFLOW_ID/runs?status=success&per_page=1") + RUN_ID=$(echo $WORKFLOW_RUNS | jq -r '.workflow_runs[0].id') + + if [ "$RUN_ID" == "null" ]; then + echo "No successful workflow runs found" + exit 1 + fi + + # Get the artifacts for the workflow run + ARTIFACTS=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "$GITHUB_API_URL/repos/$OWNER/$REPO/actions/runs/$RUN_ID/artifacts") + ARTIFACT_URL=$(echo $ARTIFACTS | jq -r '.artifacts[] | select(.name == "jacoco-xml") | .archive_download_url') + + if [ "$ARTIFACT_URL" == "null" ]; then + echo "Artifact not found" + exit 1 + fi + + echo "::set-output name=artifact-url::$ARTIFACT_URL" + + - name: Download the latest Jacoco report + run: | + curl -L -o artifact-fapi.zip \ + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + ${{ steps.get-artifact-url-fapi.outputs.artifact-url }} + + - name: Unzip Jacoco report + run: | + unzip artifact-fapi.zip -d ./artifacts-fapi + + - name: Upload coverage reports to Codecov for FAPI + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ./artifacts-fapi/jacoco.xml + flags: conformance-fapi + disable_search: true + + integration-test-report: + needs: build-source + runs-on: ubuntu-latest + + steps: + - name: Restore source code + uses: actions/cache@v4 + with: + path: . + key: ${{ runner.os }}-source-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-source- + + - name: Download integration Jacoco XML report + run: | + mkdir artifacts-integration + curl -L -o ./artifacts-integration/jacoco.xml https://wso2.org/jenkins/job/products/job/product-is/lastSuccessfulBuild/artifact/modules/integration/tests-integration/tests-backend/target/jacoco/coverage/jacoco.xml + + - name: Upload coverage reports to Codecov for integration tests + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ./artifacts-integration/jacoco.xml + flags: integration + disable_search: true diff --git a/.github/workflows/pr-builder.yml b/.github/workflows/pr-builder.yml index fa4b87d..791fc51 100644 --- a/.github/workflows/pr-builder.yml +++ b/.github/workflows/pr-builder.yml @@ -38,5 +38,11 @@ jobs: ${{ runner.os }}- - name: Build with Maven run: mvn clean install -U -B - - name: Generate coverage report - run: mvn test jacoco:report + - name: Delete SNAPSHOT artifacts + run: find ~/.m2/repository/ -name "*-SNAPSHOT" -type d -print -prune -exec rm -r {} + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: components/**/target/site/jacoco/jacoco.xml + diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..25d8f20 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,15 @@ +codecov: + require_ci_to_pass: yes + notify: + wait_for_ci: yes +coverage: + status: + project: # checks the effect for the overall code coverage rate of the repository. + default: + enabled: yes + threshold: null + target: auto + patch: # This status indicates the extent of code coverage achieved by the pull request. + default: + target: 80% + threshold: 40% # With a target of 80% and a threshold of 40%, the acceptable coverage range is 40% to 80%. From c99f0ed97694e6d3c0dc7c2dd07a35d992530cf8 Mon Sep 17 00:00:00 2001 From: Dinitha Wijewardhana Date: Sun, 5 Apr 2026 16:28:10 +0530 Subject: [PATCH 2/2] Update codeconv.yml --- .github/workflows/pr-builder.yml | 1 + codecov.yml | 26 +++++++++++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/.github/workflows/pr-builder.yml b/.github/workflows/pr-builder.yml index 791fc51..be9c347 100644 --- a/.github/workflows/pr-builder.yml +++ b/.github/workflows/pr-builder.yml @@ -45,4 +45,5 @@ jobs: with: token: ${{ secrets.CODECOV_TOKEN }} files: components/**/target/site/jacoco/jacoco.xml + flags: unit diff --git a/codecov.yml b/codecov.yml index 25d8f20..843a427 100644 --- a/codecov.yml +++ b/codecov.yml @@ -2,14 +2,22 @@ codecov: require_ci_to_pass: yes notify: wait_for_ci: yes + max_report_age: false + coverage: status: - project: # checks the effect for the overall code coverage rate of the repository. - default: - enabled: yes - threshold: null - target: auto - patch: # This status indicates the extent of code coverage achieved by the pull request. - default: - target: 80% - threshold: 40% # With a target of 80% and a threshold of 40%, the acceptable coverage range is 40% to 80%. + project: off + patch: off + +flag_management: + default_rules: + carryforward: true + individual_flags: + - name: unit + statuses: + - type: project + target: auto + threshold: null + - type: patch + target: 80% + threshold: 40%