Skip to content

Commit 75ec655

Browse files
Merge pull request #12 from thriving-dev/feat/correctly-use-gradle-build-action-with-cache
Feat/correctly use gradle build action with cache
2 parents 1de4e38 + 3b72191 commit 75ec655

File tree

8 files changed

+49
-52
lines changed

8 files changed

+49
-52
lines changed

.github/workflows/callable.build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ jobs:
1515
with:
1616
distribution: 'corretto'
1717
java-version: '17'
18-
cache: 'gradle'
1918
- uses: gradle/wrapper-validation-action@v1
2019
- name: Setup Gradle
2120
uses: gradle/[email protected]
22-
21+
with:
22+
cache-write-only: true
2323
- name: Run build (incl. test)
24-
run: gradle build -x intTest --no-daemon
24+
run: ./gradlew build -x intTest --no-daemon

.github/workflows/callable.code-analysis.codeql.yml

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,37 +19,38 @@ jobs:
1919
security-events: write
2020

2121
steps:
22-
- name: Checkout repository
23-
uses: actions/checkout@v4
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
2424

25-
# Initializes the CodeQL tools for scanning.
26-
- name: Initialize CodeQL
27-
uses: github/codeql-action/init@v2
28-
with:
29-
languages: java
30-
# If you wish to specify custom queries, you can do so here or in a config file.
31-
# By default, queries listed here will override any specified in a config file.
32-
# Prefix the list here with "+" to use these queries and those in the config file.
25+
# Initializes the CodeQL tools for scanning.
26+
- name: Initialize CodeQL
27+
uses: github/codeql-action/init@v2
28+
with:
29+
languages: java
30+
# If you wish to specify custom queries, you can do so here or in a config file.
31+
# By default, queries listed here will override any specified in a config file.
32+
# Prefix the list here with "+" to use these queries and those in the config file.
3333

34-
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
35-
# queries: security-extended,security-and-quality
36-
queries: security-extended,security-and-quality
34+
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
35+
# queries: security-extended,security-and-quality
36+
queries: security-extended,security-and-quality
3737

38-
- uses: actions/setup-java@v3
39-
with:
40-
distribution: 'corretto'
41-
java-version: '17'
42-
cache: 'gradle'
43-
- uses: gradle/wrapper-validation-action@v1
44-
- name: Setup Gradle
45-
uses: gradle/[email protected]
46-
- name: Run build with Gradle Wrapper
47-
run: |
48-
gradle build -x intTest --no-daemon
49-
# ignore ./.gradle folder for analysis
50-
rm -Rf .gradle
38+
- uses: actions/setup-java@v3
39+
with:
40+
distribution: 'corretto'
41+
java-version: '17'
42+
- uses: gradle/wrapper-validation-action@v1
43+
- name: Setup Gradle
44+
uses: gradle/[email protected]
45+
with:
46+
cache-read-only: true
47+
- name: Run build with Gradle Wrapper
48+
run: |
49+
./gradlew build -x intTest --no-daemon
50+
# ignore ./.gradle folder for analysis
51+
rm -Rf .gradle
5152
52-
- name: Perform CodeQL Analysis
53-
uses: github/codeql-action/analyze@v2
54-
with:
55-
category: "/language:${{matrix.language}}"
53+
- name: Perform CodeQL Analysis
54+
uses: github/codeql-action/analyze@v2
55+
with:
56+
category: "/language:${{matrix.language}}"

.github/workflows/callable.code-analysis.trivy.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ jobs:
2121
with:
2222
distribution: 'corretto'
2323
java-version: '17'
24-
cache: 'gradle'
2524
- uses: gradle/wrapper-validation-action@v1
2625
- name: Setup Gradle
2726
uses: gradle/[email protected]
27+
with:
28+
cache-read-only: true
2829

2930
- name: Generate gradle.lockfile for trivy scan
3031
run: gradle dependencies --write-locks

.github/workflows/callable.gradle-release.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ jobs:
1414
runs-on: ubuntu-latest
1515
steps:
1616
- name: Validate 'Release Type' param
17-
id: validate_type
1817
env:
1918
TYPE: ${{ inputs.type }}
2019
run: |
@@ -32,19 +31,18 @@ jobs:
3231
with:
3332
distribution: 'corretto'
3433
java-version: '17'
35-
cache: 'gradle'
3634
- uses: gradle/wrapper-validation-action@v1
3735
- name: Setup Gradle
3836
uses: gradle/[email protected]
37+
with:
38+
cache-read-only: true
3939

4040
- name: Get current version
41-
id: get_version
4241
run: |
4342
source gradle.properties
4443
echo "current_version=${version}" >> $GITHUB_ENV
4544
4645
- name: Determine version type
47-
id: bump_version
4846
env:
4947
TYPE: ${{ inputs.type }}
5048
VERSION: ${{ env.current_version }}
@@ -69,7 +67,6 @@ jobs:
6967
git config --local user.email "[email protected]"
7068
git config --local user.name "GitHub Action"
7169
- name: Run 'gradle release'
72-
id: gradle_release
7370
run: |
7471
echo "Type: ${{ inputs.type }}"
7572
echo "Current version: ${{ env.current_version }}"

.github/workflows/callable.integration-test.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@ jobs:
1515
with:
1616
distribution: 'corretto'
1717
java-version: '17'
18-
cache: 'gradle'
1918
- uses: gradle/wrapper-validation-action@v1
2019
- name: Setup Gradle
2120
uses: gradle/[email protected]
22-
23-
- name: Run build (incl. test)
24-
run: gradle build -x intTest --no-daemon
21+
with:
22+
cache-read-only: true
2523

2624
- name: Run integration tests
27-
run: gradle intTest --no-daemon
25+
run: ./gradlew intTest -x test --no-daemon

.github/workflows/callable.publish-javadoc.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@ jobs:
1818
with:
1919
distribution: 'corretto'
2020
java-version: '17'
21-
cache: 'gradle'
2221
- uses: gradle/wrapper-validation-action@v1
2322
- name: Setup Gradle
2423
uses: gradle/[email protected]
24+
with:
25+
cache-read-only: true
2526

2627
- name: Run build (incl. test)
27-
run: gradle javadoc
28+
run: ./gradlew javadoc
2829

2930
- name: Conclude javadoc version and set env
3031
run: |

.github/workflows/callable.publish-sonatype.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,24 @@ jobs:
1414
with:
1515
distribution: 'corretto'
1616
java-version: '17'
17-
cache: 'gradle'
1817
- uses: gradle/wrapper-validation-action@v1
1918
- name: Setup Gradle
2019
uses: gradle/[email protected]
20+
with:
21+
cache-read-only: true
2122

23+
# note the following two steps are identical but different names for better DX in GitHub Actions UI
2224
- name: Publish SNAPSHOT to Sonatype (Maven Central)
2325
if: github.ref == 'refs/heads/main'
24-
run: gradle publishToSonatype closeAndReleaseSonatypeStagingRepository
26+
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
2527
env:
2628
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
2729
GPG_SIGNING_PASSPHRASE: ${{ secrets.GPG_SIGNING_PASSPHRASE }}
2830
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
2931
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
30-
3132
- name: Publish RELEASE to Sonatype (Maven Central)
3233
if: github.ref_type == 'tag'
33-
run: gradle publishToSonatype closeAndReleaseSonatypeStagingRepository
34+
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
3435
env:
3536
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
3637
GPG_SIGNING_PASSPHRASE: ${{ secrets.GPG_SIGNING_PASSPHRASE }}

java-library-template/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)