Skip to content

ci: use gradle/actions/setup-gradle for build caching - #51

Merged
wassupluke merged 2 commits into
mainfrom
ci/gradle-build-cache
Aug 2, 2026
Merged

wassupluke merged 2 commits into
mainfrom
ci/gradle-build-cache

Conversation

@wassupluke

@wassupluke wassupluke commented Aug 2, 2026 •

Copy link
Copy Markdown
Owner

Switches all three workflows from setup-java's cache: gradle to gradle/actions/setup-gradle@v4, the Gradle-team-recommended approach.

Why

  • Caches more: the Gradle build cache (compiled task outputs — Kotlin compilation, resource processing) on top of dependency downloads.
  • Write-safe keying: only writes the cache from main; PRs read it. Stops PR branches from thrashing the cache / blowing the 10 GB repo limit.
  • Cache report in each job summary (hit/miss visibility).

Changes

  • gradle.properties: org.gradle.caching=true (configuration cache was already enabled).
  • check.yml, dev-release.yml, release.yml: drop cache: gradle from setup-java, add a setup-gradle step.

Verification

./gradlew :app:testDebugUnitTest passes locally with the build cache enabled. CI caching itself only demonstrates a hit once this is on main and a second run follows.

Summary by Sourcery

Enable Gradle build caching and adopt the recommended Gradle setup action in CI workflows.

Enhancements:

  • Turn on Gradle build caching globally via gradle.properties configuration.

CI:

  • Replace setup-java Gradle caching with gradle/actions/setup-gradle in check, dev-release, and release workflows to improve cache behavior and visibility.

Switch all three workflows from setup-java's `cache: gradle` to
gradle/actions/setup-gradle@v4, which caches the Gradle build cache
(compiled task outputs) in addition to dependency downloads, and only
writes the cache from main so PR branches don't thrash it. Enable the
local build cache via org.gradle.caching=true.
@sourcery-ai

sourcery-ai Bot commented Aug 2, 2026 •

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Switches CI Gradle caching from setup-java’s cache flag to the official gradle/actions/setup-gradle action and enables Gradle’s build cache globally via gradle.properties.

File-Level Changes

Change Details Files
Enable Gradle build cache at the project level.
  • Turn on org.gradle.caching to allow reuse of compiled task outputs across builds
  • Keep existing configuration cache settings intact while extending caching behavior
gradle.properties
Update all GitHub Actions workflows to use gradle/actions/setup-gradle for caching instead of setup-java’s cache: gradle option.
  • Remove cache: gradle from setup-java steps to avoid relying on Java action-based Gradle caching
  • Add a dedicated Set up Gradle step using gradle/actions/setup-gradle@v4 after Java setup in each workflow
  • Apply this workflow change consistently across check, dev-release, and release pipelines
.github/workflows/check.yml
.github/workflows/dev-release.yml
.github/workflows/release.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • Consider pinning gradle/actions/setup-gradle@v4 to a specific commit SHA rather than a moving tag to improve supply-chain security for your CI workflows.
  • It may be worth enabling validate-wrappers: true on the setup-gradle steps so that the Gradle wrapper is validated during CI runs, catching tampering or misconfiguration early.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider pinning `gradle/actions/setup-gradle@v4` to a specific commit SHA rather than a moving tag to improve supply-chain security for your CI workflows.
- It may be worth enabling `validate-wrappers: true` on the `setup-gradle` steps so that the Gradle wrapper is validated during CI runs, catching tampering or misconfiguration early.

## Individual Comments

### Comment 1
<location path=".github/workflows/check.yml" line_range="33-34" />
<code_context>
           distribution: 'temurin'
-          cache: gradle
+
+      - name: Set up Gradle
+        uses: gradle/actions/setup-gradle@v4

       - name: Grant execute permission for gradlew
</code_context>
<issue_to_address>
**🚨 suggestion (security):** Consider pinning the setup-gradle action to a specific commit SHA for supply-chain safety.

Using `gradle/actions/setup-gradle@v4` means the workflow will automatically pick up any future v4 changes, which can alter behavior without notice. For CI, it’s safer to pin to a specific commit SHA (or at least a fixed minor/patch tag) and update it intentionally to reduce supply-chain risk and unexpected changes.

```suggestion
      - name: Set up Gradle
        # Pin to a specific version for supply-chain safety; update intentionally when needed
        uses: gradle/actions/setup-gradle@v4.0.0
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread .github/workflows/check.yml Outdated
Comment on lines +33 to +34
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 suggestion (security): Consider pinning the setup-gradle action to a specific commit SHA for supply-chain safety.

Using gradle/actions/setup-gradle@v4 means the workflow will automatically pick up any future v4 changes, which can alter behavior without notice. For CI, it’s safer to pin to a specific commit SHA (or at least a fixed minor/patch tag) and update it intentionally to reduce supply-chain risk and unexpected changes.

Suggested change
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4
- name: Set up Gradle
# Pin to a specific version for supply-chain safety; update intentionally when needed
uses: gradle/actions/setup-gradle@v4.0.0

The setup-java + setup-gradle + chmod trio was identical across all
three workflows. Move it into .github/actions/gradle-setup so the JDK
version and caching config live in one place and can't drift. Checkout
stays per-workflow (local composite actions need the repo already
checked out, and the release workflows require fetch-depth: 0).
@wassupluke
wassupluke merged commit cfa5e50 into main Aug 2, 2026
6 of 7 checks passed
@wassupluke
wassupluke deleted the ci/gradle-build-cache branch August 2, 2026 05:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant