-
Notifications
You must be signed in to change notification settings - Fork 8
69 lines (60 loc) · 1.98 KB
/
test.yml
File metadata and controls
69 lines (60 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
name: Run Gradle Tests
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
types: [ opened, synchronize, reopened ]
jobs:
# Job 1: Build the code and run tests
# This job runs in the context of the pull request and has read-only permissions.
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Run tests with Gradle
# The 'continue-on-error' flag ensures that the workflow proceeds to the
# artifact upload step even if the tests fail.
continue-on-error: true
run: ./gradlew test
- name: Upload test results
# This step always runs to ensure the report is available for the next job.
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: build/test-results/test/*.xml
retention-days: 1
# Job 2: Publish the test report
# This job runs in the context of the base repository
# and has the necessary write permissions to create a check run.
report-tests:
# It requires the 'build-and-test' job to complete first.
needs: build-and-test
runs-on: ubuntu-latest
permissions:
# This grants the job permission to post check runs.
checks: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download test results
uses: actions/download-artifact@v5
with:
name: test-results
- name: Publish Test Report
uses: dorny/test-reporter@v2
with:
name: Test Results
# The path now points to the XML files downloaded by the artifact step.
path: '*.xml'
reporter: java-junit
fail-on-error: 'false'