|
| 1 | +name: Code Coverage Generator |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + schedule: |
| 6 | + # Daily 22:00 UTC (3.30 AM SL time). |
| 7 | + - cron: '00 22 * * *' |
| 8 | + |
| 9 | +jobs: |
| 10 | + build-source: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + |
| 13 | + steps: |
| 14 | + - name: Checkout repository |
| 15 | + uses: actions/checkout@v4 |
| 16 | + |
| 17 | + - name: Set up Adopt JDK 11 |
| 18 | + uses: actions/setup-java@v4 |
| 19 | + with: |
| 20 | + java-version: 11 |
| 21 | + distribution: "adopt" |
| 22 | + |
| 23 | + - name: Build with Maven |
| 24 | + run: | |
| 25 | + mvn clean install -U -B -Dmaven.test.skip=true |
| 26 | +
|
| 27 | + - name: Cache source code |
| 28 | + uses: actions/cache@v4 |
| 29 | + with: |
| 30 | + path: . |
| 31 | + key: ${{ runner.os }}-source-${{ github.sha }} |
| 32 | + |
| 33 | + oidc-conformance-report: |
| 34 | + needs: build-source |
| 35 | + runs-on: ubuntu-latest |
| 36 | + |
| 37 | + steps: |
| 38 | + - name: Restore source code |
| 39 | + uses: actions/cache@v4 |
| 40 | + with: |
| 41 | + path: . |
| 42 | + key: ${{ runner.os }}-source-${{ github.sha }} |
| 43 | + restore-keys: | |
| 44 | + ${{ runner.os }}-source- |
| 45 | +
|
| 46 | + - name: Get the latest Jacoco report URL |
| 47 | + id: get-artifact-url-oidc |
| 48 | + run: | |
| 49 | + GITHUB_API_URL="https://api.github.com" |
| 50 | + OWNER="wso2" |
| 51 | + REPO="product-is" |
| 52 | + WORKFLOW_ID="oidc-conformance-test.yml" |
| 53 | + GITHUB_TOKEN="${{ secrets.GITHUB_TOKEN }}" |
| 54 | +
|
| 55 | + # Get the latest successful workflow run |
| 56 | + 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") |
| 57 | + RUN_ID=$(echo $WORKFLOW_RUNS | jq -r '.workflow_runs[0].id') |
| 58 | +
|
| 59 | + if [ "$RUN_ID" == "null" ]; then |
| 60 | + echo "No successful workflow runs found" |
| 61 | + exit 1 |
| 62 | + fi |
| 63 | +
|
| 64 | + # Get the artifacts for the workflow run |
| 65 | + ARTIFACTS=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "$GITHUB_API_URL/repos/$OWNER/$REPO/actions/runs/$RUN_ID/artifacts") |
| 66 | + ARTIFACT_URL=$(echo $ARTIFACTS | jq -r '.artifacts[] | select(.name == "jacoco-xml") | .archive_download_url') |
| 67 | +
|
| 68 | + if [ "$ARTIFACT_URL" == "null" ]; then |
| 69 | + echo "Artifact not found" |
| 70 | + exit 1 |
| 71 | + fi |
| 72 | +
|
| 73 | + echo "::set-output name=artifact-url::$ARTIFACT_URL" |
| 74 | +
|
| 75 | + - name: Download latest Jacoco report |
| 76 | + run: | |
| 77 | + curl -L -o artifact-oidc.zip \ |
| 78 | + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ |
| 79 | + ${{ steps.get-artifact-url-oidc.outputs.artifact-url }} |
| 80 | +
|
| 81 | + - name: Unzip Jacoco report |
| 82 | + run: | |
| 83 | + unzip artifact-oidc.zip -d ./artifacts-oidc |
| 84 | +
|
| 85 | + - name: Upload coverage reports to Codecov for OIDC |
| 86 | + uses: codecov/codecov-action@v4 |
| 87 | + with: |
| 88 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 89 | + files: ./artifacts-oidc/jacoco.xml |
| 90 | + flags: conformance-oidc |
| 91 | + disable_search: true |
| 92 | + |
| 93 | + fapi-conformance-report: |
| 94 | + needs: build-source |
| 95 | + runs-on: ubuntu-latest |
| 96 | + |
| 97 | + steps: |
| 98 | + - name: Restore source code |
| 99 | + uses: actions/cache@v4 |
| 100 | + with: |
| 101 | + path: . |
| 102 | + key: ${{ runner.os }}-source-${{ github.sha }} |
| 103 | + restore-keys: | |
| 104 | + ${{ runner.os }}-source- |
| 105 | +
|
| 106 | + - name: Get the latest Jacoco report URL |
| 107 | + id: get-artifact-url-fapi |
| 108 | + run: | |
| 109 | + GITHUB_API_URL="https://api.github.com" |
| 110 | + OWNER="wso2" |
| 111 | + REPO="product-is" |
| 112 | + WORKFLOW_ID="fapi-oidc-conformance-test.yml" |
| 113 | + GITHUB_TOKEN="${{ secrets.GITHUB_TOKEN }}" |
| 114 | +
|
| 115 | + # Get the latest successful workflow run |
| 116 | + 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") |
| 117 | + RUN_ID=$(echo $WORKFLOW_RUNS | jq -r '.workflow_runs[0].id') |
| 118 | +
|
| 119 | + if [ "$RUN_ID" == "null" ]; then |
| 120 | + echo "No successful workflow runs found" |
| 121 | + exit 1 |
| 122 | + fi |
| 123 | +
|
| 124 | + # Get the artifacts for the workflow run |
| 125 | + ARTIFACTS=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "$GITHUB_API_URL/repos/$OWNER/$REPO/actions/runs/$RUN_ID/artifacts") |
| 126 | + ARTIFACT_URL=$(echo $ARTIFACTS | jq -r '.artifacts[] | select(.name == "jacoco-xml") | .archive_download_url') |
| 127 | +
|
| 128 | + if [ "$ARTIFACT_URL" == "null" ]; then |
| 129 | + echo "Artifact not found" |
| 130 | + exit 1 |
| 131 | + fi |
| 132 | +
|
| 133 | + echo "::set-output name=artifact-url::$ARTIFACT_URL" |
| 134 | +
|
| 135 | + - name: Download the latest Jacoco report |
| 136 | + run: | |
| 137 | + curl -L -o artifact-fapi.zip \ |
| 138 | + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ |
| 139 | + ${{ steps.get-artifact-url-fapi.outputs.artifact-url }} |
| 140 | +
|
| 141 | + - name: Unzip Jacoco report |
| 142 | + run: | |
| 143 | + unzip artifact-fapi.zip -d ./artifacts-fapi |
| 144 | +
|
| 145 | + - name: Upload coverage reports to Codecov for FAPI |
| 146 | + uses: codecov/codecov-action@v4 |
| 147 | + with: |
| 148 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 149 | + files: ./artifacts-fapi/jacoco.xml |
| 150 | + flags: conformance-fapi |
| 151 | + disable_search: true |
| 152 | + |
| 153 | + integration-test-report: |
| 154 | + needs: build-source |
| 155 | + runs-on: ubuntu-latest |
| 156 | + |
| 157 | + steps: |
| 158 | + - name: Restore source code |
| 159 | + uses: actions/cache@v4 |
| 160 | + with: |
| 161 | + path: . |
| 162 | + key: ${{ runner.os }}-source-${{ github.sha }} |
| 163 | + restore-keys: | |
| 164 | + ${{ runner.os }}-source- |
| 165 | +
|
| 166 | + - name: Download integration Jacoco XML report |
| 167 | + run: | |
| 168 | + mkdir artifacts-integration |
| 169 | + 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 |
| 170 | +
|
| 171 | + - name: Upload coverage reports to Codecov for integration tests |
| 172 | + uses: codecov/codecov-action@v4 |
| 173 | + with: |
| 174 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 175 | + files: ./artifacts-integration/jacoco.xml |
| 176 | + flags: integration |
| 177 | + disable_search: true |
0 commit comments