Skip to content

Commit d4827b6

Browse files
committed
GitHub Actions: cache buildSrc/build to speed up Gradle builds by ~40 seconds
1 parent 02f7cb8 commit d4827b6

File tree

7 files changed

+57
-6
lines changed

7 files changed

+57
-6
lines changed

.editorconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ charset = latin1
77
indent_style = tab
88
indent_size = 4
99

10+
[{*.yaml,*.yml}]
11+
end_of_line = lf
12+
indent_style = space
13+
indent_size = 2
14+
1015
[*.java]
1116
indent_style = tab
1217
ij_continuation_indent_size = 4
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# https://docs.github.com/en/actions/tutorials/create-actions/create-a-composite-action#creating-a-composite-action-within-the-same-repository
2+
3+
# cache uses two files:
4+
#
5+
# - gradle-wrapper-<os>-<arch>-<hash>:
6+
# contains the Gradle wrapper/distribution (~/.gradle/wrapper)
7+
# and is updated when the Gradle version changed
8+
# - gradle-caches-<os>-<arch>-<hash>:
9+
# contains the Gradle caches (~/.gradle/caches), buildSrc/build and buildSrc/.gradle
10+
# and is updated when Gradle related files were changed
11+
# buildSrc/.gradle is needed so that buildSrc tasks are UP-TO-DATE
12+
13+
name: 'Cache Gradle'
14+
runs:
15+
using: "composite"
16+
steps:
17+
18+
- name: Cache '.gradle/wrapper'
19+
uses: actions/cache@v4
20+
with:
21+
key: gradle-wrapper-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles( 'gradle/wrapper/gradle-wrapper.properties' ) }}
22+
path: |
23+
~/.gradle/wrapper
24+
25+
- name: Cache '.gradle/caches' and 'buildSrc/build'
26+
uses: actions/cache@v4
27+
with:
28+
key: gradle-caches-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles( '**/*.gradle*', 'gradle/**', 'gradle.properties', 'buildSrc/src/**' ) }}
29+
path: |
30+
~/.gradle/caches
31+
buildSrc/build
32+
buildSrc/.gradle

.github/workflows/ci.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ on:
1414
- '.*'
1515
- '**/.settings/**'
1616
- 'flatlaf-core/svg/**'
17+
- 'flatlaf-natives/**'
1718
- 'flatlaf-testing/dumps/**'
1819
- 'flatlaf-testing/misc/**'
1920
- 'images/**'
@@ -32,7 +33,9 @@ jobs:
3233
with:
3334
java-version: 21
3435
distribution: temurin # pre-installed on ubuntu-latest
35-
cache: gradle
36+
37+
- name: Cache Gradle
38+
uses: ./.github/actions/cache-gradle
3639

3740

3841
# test against
@@ -100,7 +103,9 @@ jobs:
100103
with:
101104
java-version: 21
102105
distribution: temurin # pre-installed on ubuntu-latest
103-
cache: gradle
106+
107+
- name: Cache Gradle
108+
uses: ./.github/actions/cache-gradle
104109

105110
- name: Release a new stable version to Maven Central
106111
run: ./gradlew publishToSonatype closeSonatypeStagingRepository :flatlaf-demo:build :flatlaf-theme-editor:build -PskipFonts -Prelease -Dorg.gradle.parallel=false

.github/workflows/error-prone.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ on:
1414
- '.*'
1515
- '**/.settings/**'
1616
- 'flatlaf-core/svg/**'
17+
- 'flatlaf-natives/**'
1718
- 'flatlaf-testing/dumps/**'
1819
- 'flatlaf-testing/misc/**'
1920
- 'images/**'
@@ -31,7 +32,9 @@ jobs:
3132
with:
3233
java-version: 21
3334
distribution: temurin # pre-installed on ubuntu-latest
34-
cache: gradle
35+
36+
- name: Cache Gradle
37+
uses: ./.github/actions/cache-gradle
3538

3639
- name: Check with Error Prone
3740
run: ./gradlew errorprone

.github/workflows/fonts.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ jobs:
3939
with:
4040
java-version: 21
4141
distribution: temurin # pre-installed on ubuntu-latest
42-
cache: gradle
42+
43+
- name: Cache Gradle
44+
uses: ./.github/actions/cache-gradle
4345

4446
- name: Build with Gradle
4547
run: ./gradlew :flatlaf-fonts-${{ matrix.font }}:build

.github/workflows/natives.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ jobs:
6363
with:
6464
java-version: 21
6565
distribution: temurin
66-
cache: gradle
66+
67+
- name: Cache Gradle
68+
uses: ./.github/actions/cache-gradle
6769

6870
- name: Build with Gradle
6971
# --no-daemon is necessary on Windows otherwise caching Gradle would fail with:

.github/workflows/pr-snapshots.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ jobs:
2626
with:
2727
java-version: 21
2828
distribution: temurin # pre-installed on ubuntu-latest
29-
cache: gradle
29+
30+
- name: Cache Gradle
31+
uses: ./.github/actions/cache-gradle
3032

3133
- name: Publish PR snapshot to Sonatype Central
3234
run: >

0 commit comments

Comments
 (0)