Skip to content

Commit 5ff6f61

Browse files
authored
ci: update build.yml (#310)
Signed-off-by: kvmw <[email protected]>
1 parent 82e278a commit 5ff6f61

File tree

1 file changed

+41
-23
lines changed

1 file changed

+41
-23
lines changed

.github/workflows/build.yml

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,58 @@ name: build
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [main]
66
pull_request:
7-
branches: [ main ]
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
pull-requests: read
812

913
jobs:
1014
build:
1115
runs-on: ubuntu-latest
1216
strategy:
1317
matrix:
14-
java: [ '17' ]
15-
name: Java ${{ matrix.Java }} build
18+
java: ["17", "21"]
19+
name: jdk-${{ matrix.java }}
1620
steps:
17-
- uses: actions/checkout@v4
18-
- name: Set up JDK
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- name: Set up JDK ${{ matrix.java }}
1925
uses: actions/setup-java@v4
2026
with:
2127
java-version: ${{ matrix.java }}
22-
distribution: adopt
23-
- name: Cache Gradle packages
24-
uses: actions/cache@v4
25-
with:
26-
path: |
27-
~/.gradle/caches
28-
~/.gradle/wrapper
29-
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
30-
restore-keys: |
31-
${{ runner.os }}-gradle-
28+
distribution: temurin
29+
3230
- name: Validate Gradle wrapper
3331
uses: gradle/wrapper-validation-action@v2
32+
continue-on-error: true
33+
34+
- name: Setup Gradle
35+
uses: gradle/gradle-build-action@v2
36+
with:
37+
cache-read-only: false
38+
3439
- name: Build with Gradle
35-
run: ./gradlew build
36-
- name: Cleanup Gradle Cache
37-
# Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
38-
# Restoring these files from a GitHub Actions cache might cause problems for future builds.
39-
run: |
40-
rm -f ~/.gradle/caches/modules-2/modules-2.lock
41-
rm -f ~/.gradle/caches/modules-2/gc.properties
40+
run: ./gradlew build --no-daemon --stacktrace
41+
42+
- name: Upload test results
43+
if: always()
44+
uses: actions/upload-artifact@v4
45+
with:
46+
name: test-results-java-${{ matrix.java }}
47+
path: |
48+
**/build/test-results/**/*.xml
49+
**/build/reports/tests/**/*
50+
retention-days: 7
51+
52+
- name: Upload build reports
53+
if: always()
54+
uses: actions/upload-artifact@v4
55+
with:
56+
name: build-reports-java-${{ matrix.java }}
57+
path: |
58+
**/build/reports/**/*
59+
retention-days: 7

0 commit comments

Comments
 (0)