Skip to content

Commit 0493710

Browse files
authored
[PM-16827] Fix test.yml sdk package access and refactor test jobs (#4538)
1 parent b5d73c9 commit 0493710

File tree

1 file changed

+47
-9
lines changed

1 file changed

+47
-9
lines changed

.github/workflows/test.yml

+47-9
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,16 @@ on:
1313
workflow_dispatch:
1414

1515
env:
16-
JAVA_VERSION: 17
16+
_JAVA_VERSION: 17
17+
_GITHUB_ACTION_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}
18+
1719

1820
jobs:
1921
test:
2022
name: Test
2123
runs-on: ubuntu-24.04
2224
permissions:
23-
contents: read
24-
issues: write
2525
packages: read
26-
pull-requests: write
2726

2827
steps:
2928
- name: Check out repo
@@ -60,7 +59,7 @@ jobs:
6059
uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0
6160
with:
6261
distribution: "temurin"
63-
java-version: ${{ env.JAVA_VERSION }}
62+
java-version: ${{ env._JAVA_VERSION }}
6463

6564
- name: Install Fastlane
6665
run: |
@@ -69,17 +68,56 @@ jobs:
6968
bundle install --jobs 4 --retry 3
7069
7170
- name: Build and test
71+
env:
72+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Used in settings.gradle.kts to download the SDK from GitHub Maven Packages
7273
run: |
7374
bundle exec fastlane check
7475
75-
- name: Upload test reports on failure
76+
- name: Upload test reports
7677
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
77-
if: failure()
78+
if: always()
79+
with:
80+
name: test-reports
81+
path: |
82+
app/build/reports/tests/
83+
app/build/reports/kover/reportStandardDebug.xml
84+
85+
report:
86+
name: Process Test Reports
87+
needs: test
88+
runs-on: ubuntu-24.04
89+
permissions:
90+
contents: read
91+
issues: write
92+
pull-requests: write
93+
if: always()
94+
95+
steps:
96+
- name: Download test artifacts
97+
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
7898
with:
7999
name: test-reports
80-
path: app/build/reports/tests/
81100

82101
- name: Upload to codecov.io
102+
id: upload-to-codecov
83103
uses: codecov/codecov-action@1e68e06f1dbfde0e4cefc87efeba9e4643565303 # v5.1.2
104+
continue-on-error: true
84105
with:
85-
files: app/build/reports/kover/reportStandardDebug.xml
106+
os: linux
107+
files: kover/reportStandardDebug.xml
108+
fail_ci_if_error: true
109+
110+
- name: Comment PR if tests failed
111+
if: steps.upload-to-codecov.outcome == 'failure'
112+
env:
113+
PR_NUMBER: ${{ github.event.number }}
114+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
115+
RUN_ACTOR: ${{ github.triggering_actor }}
116+
run: |
117+
echo "> [!WARNING]" >> $GITHUB_STEP_SUMMARY
118+
echo "> Uploading code coverage report failed. Please check the \"Upload to codecov.io\" step of \"Process Test Reports\" job for more details." >> $GITHUB_STEP_SUMMARY
119+
120+
if [ ! -z "$PR_NUMBER" ]; then
121+
message=$'> [!WARNING]\n> @'$RUN_ACTOR' Uploading code coverage report failed. Please check the "Upload to codecov.io" step of [Process Test Reports job]('$_GITHUB_ACTION_RUN_URL') for more details.'
122+
gh pr comment --repo $GITHUB_REPOSITORY $PR_NUMBER --body "$message"
123+
fi

0 commit comments

Comments
 (0)