-
Notifications
You must be signed in to change notification settings - Fork 368
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add git action to generate coverage for integration tests
- Loading branch information
Maduranga Siriwardena
committed
Sep 13, 2024
1 parent
1179274
commit db67e3d
Showing
3 changed files
with
156 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
name: Code Coverage Generator | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
oidc-conformance-report: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Get the latest artifact URL for OIDC | ||
id: get-artifact-url-oidc | ||
run: | | ||
GITHUB_API_URL="https://api.github.com" | ||
OWNER="madurangasiriwardena" | ||
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 Jacoco XML artifact for OIDC | ||
run: | | ||
curl -L -o artifact-oidc.zip \ | ||
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
${{ steps.get-artifact-url-oidc.outputs.artifact-url }} | ||
- name: Unzip artifact for OIDC | ||
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: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Get the latest artifact URL for FAPI | ||
id: get-artifact-url-fapi | ||
run: | | ||
GITHUB_API_URL="https://api.github.com" | ||
OWNER="madurangasiriwardena" | ||
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 Jacoco XML artifact for FAPI | ||
run: | | ||
curl -L -o artifact-fapi.zip \ | ||
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
${{ steps.get-artifact-url-fapi.outputs.artifact-url }} | ||
- name: Unzip artifact for FAPI | ||
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: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,3 +55,4 @@ jobs: | |
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
files : target/site/jacoco/jacoco.xml | ||
flags: unit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters