-
Notifications
You must be signed in to change notification settings - Fork 2
142 lines (129 loc) · 4.63 KB
/
test.yml
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: Run Tests
on:
push:
branches:
- '**'
tags-ignore:
- stage0/v*
- stage2/v*
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: |
8
16
17
# Can't use setup-java for this because https://github.com/actions/setup-java/issues/366
- uses: actions/cache@v4
with:
path: ~/.gradle/wrapper
key: gradle-wrapper-${{ hashFiles('**/gradle-wrapper.properties') }}
- uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: gradle-caches-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle.properties', 'gradle/*.versions.toml') }}
restore-keys: |
gradle-caches-${{ hashFiles('**/*.gradle*') }}
gradle-caches-
- run: ./gradlew build -x integrationTest setupDownloadsApi --stacktrace
- uses: actions/upload-artifact@v4
if: ${{ failure() || success() }}
with:
name: Raw Test Results
path: "**/build/test-results/**/*.xml"
retention-days: 1 # only for the report at the end
- uses: actions/upload-artifact@v4
if: ${{ failure() }}
with:
name: Unit Test Results
path: "**/build/reports/"
- uses: actions/cache/save@v4
with:
path: |
**/.gradle
**/build
key: test-build-${{ github.run_id }}-${{ github.run_attempt }}
prepare_integration_test_matrix:
needs: build # don't even bother with tests if it doesn't even build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/github-script@v7
id: create-matrix
with:
script: |
const tests = []
for (platform of ["launchwrapper", "fabric"]) {
const prefix = `integrationTest/${platform}/src/main/java/`
for await (const file of (await glob.create(`${prefix}/**/*Tests.java`)).globGenerator()) {
const cls = file.slice(file.indexOf(prefix) + prefix.length, file.length - 5).replaceAll("/", ".")
tests.push({ platform, "class": cls })
}
}
return tests
github-token: dummy # we don't need one but it'll complain without one (when running locally via act)
outputs:
matrix: ${{ steps.create-matrix.outputs.result }}
integration_tests:
needs:
- prepare_integration_test_matrix
- build # we'll want to re-use the caches it produces
strategy:
fail-fast: false
matrix:
test: ${{ fromJson(needs.prepare_integration_test_matrix.outputs.matrix) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: |
8
16
17
- uses: actions/cache/restore@v4
with:
path: ~/.gradle/wrapper
key: gradle-wrapper-${{ hashFiles('**/gradle-wrapper.properties') }}
- uses: actions/cache/restore@v4
with:
path: ~/.gradle/caches
key: gradle-caches-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle.properties', 'gradle/*.versions.toml') }}
- uses: actions/cache/restore@v4
with:
path: |
**/.gradle
**/build
key: test-build-${{ github.run_id }}-${{ github.run_attempt }}
- run: ./gradlew :integrationTest:${{ matrix.test.platform }}:integrationTest --tests ${{ matrix.test.class }} --stacktrace
- uses: actions/upload-artifact@v4
if: ${{ failure() || success() }}
with:
name: ${{ matrix.test.platform }}_${{ matrix.test.class }} Results
path: integrationTest/${{ matrix.test.platform }}/build/test-results/**/*.xml
retention-days: 1 # only for the report at the end
- uses: actions/upload-artifact@v4
if: ${{ failure() }}
with:
name: ${{ matrix.test.platform }}_${{ matrix.test.class }} Reports
path: integrationTest/${{ matrix.test.platform }}/build/reports/
test_report:
runs-on: ubuntu-latest
needs: [build, integration_tests]
if: ${{ !cancelled() }}
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Publish test report
uses: EnricoMi/publish-unit-test-result-action@567cc7f8dcea3eba5da355f6ebc95663310d8a07 # v2.17.0
with:
junit_files: "artifacts/**/*.xml"