From 59998b0504c706d4860e0f7e50c125da06421ca0 Mon Sep 17 00:00:00 2001 From: Maduranga Siriwardena Date: Wed, 11 Dec 2024 14:23:49 +0530 Subject: [PATCH 1/2] Add codecov configs --- .github/workflows/coverage-generator.yml | 177 ++++++++++++++++++ .github/workflows/pr-builder.yml | 22 ++- codecov.yml | 23 +++ .../pom.xml | 30 +-- .../pom.xml | 19 ++ .../src/test/resources/testng.xml | 28 +++ .../org.wso2.carbon.identity.sso.saml/pom.xml | 37 ++-- pom.xml | 21 ++- 8 files changed, 304 insertions(+), 53 deletions(-) create mode 100644 .github/workflows/coverage-generator.yml create mode 100644 codecov.yml create mode 100644 components/org.wso2.carbon.identity.sso.saml.common/src/test/resources/testng.xml diff --git a/.github/workflows/coverage-generator.yml b/.github/workflows/coverage-generator.yml new file mode 100644 index 000000000..88e3db054 --- /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 11 + uses: actions/setup-java@v4 + with: + java-version: 11 + 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 efbde4d15..e443719e9 100644 --- a/.github/workflows/pr-builder.yml +++ b/.github/workflows/pr-builder.yml @@ -1,7 +1,7 @@ # This workflow will build the project on pull requests with tests # Uses: -# OS: ubuntu-lates -# JDK: Adopt JDK 11 and Adopt JDK 17 +# OS: ubuntu-latest +# JDK: Temurin JDK 11 and Temurin JDK 17 name: PR Builder @@ -22,15 +22,15 @@ jobs: java-version: [ 11, 17 ] steps: - - uses: actions/checkout@v2 - - name: Set up Adopt JDK 11 and 17 - uses: actions/setup-java@v2 + - uses: actions/checkout@v4 + - name: Set up Temurin JDK 11 and 17 + uses: actions/setup-java@v4 with: java-version: ${{ matrix.java-version }} - distribution: "adopt" + distribution: "temurin" - name: Cache local Maven repository id: cache-maven-m2 - uses: actions/cache@v2 + uses: actions/cache@v4 env: cache-name: cache-m2 with: @@ -42,3 +42,11 @@ jobs: ${{ runner.os }}- - name: Build with Maven run: mvn clean install -U -B + - name: Generate coverage report + run: mvn test jacoco:report + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: target/site/jacoco/jacoco.xml + flags: unit diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 000000000..843a42781 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,23 @@ +codecov: + require_ci_to_pass: yes + notify: + wait_for_ci: yes + max_report_age: false + +coverage: + status: + 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% diff --git a/components/org.wso2.carbon.identity.query.saml/pom.xml b/components/org.wso2.carbon.identity.query.saml/pom.xml index 86eb65834..7cfc830de 100644 --- a/components/org.wso2.carbon.identity.query.saml/pom.xml +++ b/components/org.wso2.carbon.identity.query.saml/pom.xml @@ -271,13 +271,14 @@ target/jacoco.exec - --add-opens=java.base/java.lang=ALL-UNNAMED + ${argLine} + --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED - --add-opens=java.base/java.util=ALL-UNNAMED - --add-opens=java.base/java.util.concurrent=ALL-UNNAMED + --add-opens=java.base/java.util=ALL-UNNAMED + --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.zip=ALL-UNNAMED --add-opens=java.base/java.util.random=ALL-UNNAMED - --add-opens=java.base/java.security=ALL-UNNAMED + --add-opens=java.base/java.security=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.security.cert=ALL-UNNAMED --add-opens=java.base/jdk.internal.util=ALL-UNNAMED @@ -291,7 +292,7 @@ --add-opens=java.base/sun.security.validator=ALL-UNNAMED --add-opens=java.base/sun.reflect.misc=ALL-UNNAMED --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED - + @@ -300,30 +301,17 @@ ${jacoco.version} - default-instrument - instrument + prepare-agent - default-restore-instrumented-classes - - restore-instrumented-classes - - - - default-report - prepare-package + report + test report - - default-report-integration - - report-integration - - default-check diff --git a/components/org.wso2.carbon.identity.sso.saml.common/pom.xml b/components/org.wso2.carbon.identity.sso.saml.common/pom.xml index aede9549d..d5edf71b9 100644 --- a/components/org.wso2.carbon.identity.sso.saml.common/pom.xml +++ b/components/org.wso2.carbon.identity.sso.saml.common/pom.xml @@ -63,6 +63,25 @@ + + org.jacoco + jacoco-maven-plugin + ${jacoco.version} + + + + prepare-agent + + + + report + test + + report + + + + diff --git a/components/org.wso2.carbon.identity.sso.saml.common/src/test/resources/testng.xml b/components/org.wso2.carbon.identity.sso.saml.common/src/test/resources/testng.xml new file mode 100644 index 000000000..259a50e43 --- /dev/null +++ b/components/org.wso2.carbon.identity.sso.saml.common/src/test/resources/testng.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + diff --git a/components/org.wso2.carbon.identity.sso.saml/pom.xml b/components/org.wso2.carbon.identity.sso.saml/pom.xml index 396ba0181..3aca7cb78 100755 --- a/components/org.wso2.carbon.identity.sso.saml/pom.xml +++ b/components/org.wso2.carbon.identity.sso.saml/pom.xml @@ -460,28 +460,29 @@ src/test/resources/testng.xml + ${argLine} --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED - --add-opens=java.base/java.util.zip=ALL-UNNAMED + --add-opens=java.base/java.util.zip=ALL-UNNAMED --add-opens=java.base/java.util.random=ALL-UNNAMED --add-opens=java.base/java.security=ALL-UNNAMED - --add-opens=java.base/java.io=ALL-UNNAMED + --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.security.cert=ALL-UNNAMED --add-opens=java.base/java.util.regex=ALL-UNNAMED - --add-opens=java.base/jdk.internal.util=ALL-UNNAMED - --add-opens=java.base/jdk.internal.util.random=ALL-UNNAMED - --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED + --add-opens=java.base/jdk.internal.util=ALL-UNNAMED + --add-opens=java.base/jdk.internal.util.random=ALL-UNNAMED + --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED --add-opens=java.base/jdk.internal.access=ALL-UNNAMED - --add-opens=java.base/sun.nio.fs=ALL-UNNAMED - --add-opens=java.base/sun.security.util=ALL-UNNAMED - --add-opens=java.base/sun.security.jca=ALL-UNNAMED - --add-opens=java.base/sun.security.x509=ALL-UNNAMED + --add-opens=java.base/sun.nio.fs=ALL-UNNAMED + --add-opens=java.base/sun.security.util=ALL-UNNAMED + --add-opens=java.base/sun.security.jca=ALL-UNNAMED + --add-opens=java.base/sun.security.x509=ALL-UNNAMED --add-opens=java.base/sun.security.validator=ALL-UNNAMED --add-opens=java.base/sun.security.cert=ALL-UNNAMED --add-opens=java.base/sun.reflect.misc=ALL-UNNAMED - --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED + --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED @@ -491,29 +492,17 @@ ${jacoco.version} - default-prepare-agent prepare-agent - default-prepare-agent-integration - - prepare-agent-integration - - - - default-report + report + test report - - default-report-integration - - report-integration - - default-check diff --git a/pom.xml b/pom.xml index 300a8636b..c9ea4805c 100644 --- a/pom.xml +++ b/pom.xml @@ -395,6 +395,25 @@ + + org.jacoco + jacoco-maven-plugin + ${jacoco.version} + + + + prepare-agent + + + + report + test + + report + + + + @@ -525,7 +544,7 @@ [1.2.2,2.0.0) 7.0.0 - 0.8.4 + 0.8.12 2.0.2 1.7.21 2.22.0 From 00f1d3fe5211b44760c57b7bdaba18d07c77422a Mon Sep 17 00:00:00 2001 From: Maduranga Siriwardena Date: Fri, 13 Dec 2024 09:25:33 +0530 Subject: [PATCH 2/2] Fix incorrect tab charactors --- .../org.wso2.carbon.identity.sso.saml/pom.xml | 45 ++++++++++++------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/components/org.wso2.carbon.identity.sso.saml/pom.xml b/components/org.wso2.carbon.identity.sso.saml/pom.xml index 3aca7cb78..eaf12ca4f 100755 --- a/components/org.wso2.carbon.identity.sso.saml/pom.xml +++ b/components/org.wso2.carbon.identity.sso.saml/pom.xml @@ -16,7 +16,8 @@ ~ specific language governing permissions and limitations ~ under the License. --> - + org.wso2.carbon.identity.inbound.auth.saml2 @@ -366,14 +367,19 @@ org.wso2.carbon.registry.api; version="${carbon.kernel.registry.imp.pkg.version}", org.wso2.carbon.identity.base;version="${carbon.identity.framework.imp.pkg.version.range}", org.wso2.carbon.idp.mgt; version="${carbon.identity.framework.imp.pkg.version.range}", - org.wso2.carbon.identity.application.common; version="${carbon.identity.framework.imp.pkg.version.range}", - org.wso2.carbon.identity.application.mgt.listener; version="${carbon.identity.framework.imp.pkg.version.range}", + org.wso2.carbon.identity.application.common; + version="${carbon.identity.framework.imp.pkg.version.range}", + org.wso2.carbon.identity.application.mgt.listener; + version="${carbon.identity.framework.imp.pkg.version.range}", org.apache.xerces.impl; resolution:= optional, org.owasp.encoder, org.wso2.carbon.base.api, - org.wso2.carbon.identity.sp.metadata.saml2.exception; version="${identity.metadata.saml2.imp.pkg.version.range}", - org.wso2.carbon.identity.sp.metadata.saml2.util; version="${identity.metadata.saml2.imp.pkg.version.range}", - org.wso2.carbon.identity.core.model; version="${carbon.identity.framework.imp.pkg.version.range}", + org.wso2.carbon.identity.sp.metadata.saml2.exception; + version="${identity.metadata.saml2.imp.pkg.version.range}", + org.wso2.carbon.identity.sp.metadata.saml2.util; + version="${identity.metadata.saml2.imp.pkg.version.range}", + org.wso2.carbon.identity.core.model; + version="${carbon.identity.framework.imp.pkg.version.range}", org.wso2.carbon.identity.saml.common.util.*; version="${saml.common.util.version.range}", org.wso2.carbon.idp.mgt.util; version="${carbon.identity.framework.imp.pkg.version.range}", javax.crypto, @@ -427,12 +433,17 @@ org.wso2.carbon.identity.application.common.util; version="${carbon.identity.framework.imp.pkg.version.range}", org.wso2.carbon.identity.core; version="${carbon.identity.framework.imp.pkg.version.range}", - org.wso2.carbon.identity.core.dao; version="${carbon.identity.framework.imp.pkg.version.range}", - org.wso2.carbon.identity.core.persistence; version="${carbon.identity.framework.imp.pkg.version.range}", - org.wso2.carbon.identity.core.util; version="${carbon.identity.framework.imp.pkg.version.range}", + org.wso2.carbon.identity.core.dao; + version="${carbon.identity.framework.imp.pkg.version.range}", + org.wso2.carbon.identity.core.persistence; + version="${carbon.identity.framework.imp.pkg.version.range}", + org.wso2.carbon.identity.core.util; + version="${carbon.identity.framework.imp.pkg.version.range}", org.wso2.carbon.security; version="${carbon.identity.framework.imp.pkg.version.range}", - org.wso2.carbon.security.keystore; version="${carbon.identity.framework.imp.pkg.version.range}", - org.wso2.carbon.security.keystore.service; version="${carbon.identity.framework.imp.pkg.version.range}", + org.wso2.carbon.security.keystore; + version="${carbon.identity.framework.imp.pkg.version.range}", + org.wso2.carbon.security.keystore.service; + version="${carbon.identity.framework.imp.pkg.version.range}", org.wso2.carbon.user.core, org.wso2.carbon.user.core.claim, org.wso2.carbon.user.core.service, @@ -440,8 +451,10 @@ org.wso2.carbon.utils, org.wso2.carbon.utils.multitenancy, org.wso2.carbon.identity.event; version="${carbon.identity.package.import.version.range}", - org.wso2.carbon.identity.event.event; version="${carbon.identity.package.import.version.range}", - org.wso2.carbon.identity.event.handler; version="${carbon.identity.package.import.version.range}", + org.wso2.carbon.identity.event.event; + version="${carbon.identity.package.import.version.range}", + org.wso2.carbon.identity.event.handler; + version="${carbon.identity.package.import.version.range}", !org.wso2.carbon.identity.sso.saml.internal, @@ -465,10 +478,10 @@ --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED - --add-opens=java.base/java.util.zip=ALL-UNNAMED + --add-opens=java.base/java.util.zip=ALL-UNNAMED --add-opens=java.base/java.util.random=ALL-UNNAMED --add-opens=java.base/java.security=ALL-UNNAMED - --add-opens=java.base/java.io=ALL-UNNAMED + --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.security.cert=ALL-UNNAMED --add-opens=java.base/java.util.regex=ALL-UNNAMED --add-opens=java.base/jdk.internal.util=ALL-UNNAMED @@ -482,7 +495,7 @@ --add-opens=java.base/sun.security.validator=ALL-UNNAMED --add-opens=java.base/sun.security.cert=ALL-UNNAMED --add-opens=java.base/sun.reflect.misc=ALL-UNNAMED - --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED + --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED