Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ jobs:
cache-key: integration-test
project-dir: ${{ runner.temp }}/project
gradle-user-home: ${{ runner.temp }}/gradle-home
branch: "false"
ref: HEAD
log-level: debug

Expand Down Expand Up @@ -160,13 +161,15 @@ jobs:
INTEGRATION_PROJECT_DIR: ${{ runner.temp }}/project
GRADLE_USER_HOME: ${{ runner.temp }}/gradle-home

# Modify build.gradle to invalidate the configuration cache, then
# Modify build.gradle.kts to invalidate the configuration cache, then
# rebuild so the delta captures the regenerated config cache entry.
- name: Modify build.gradle and rebuild
- name: Modify build.gradle.kts and rebuild
run: |
echo '// delta change' >> "$RUNNER_TEMP/project/build.gradle"
cd "$RUNNER_TEMP/project"
GRADLE_USER_HOME="${{ runner.temp }}/gradle-home" ./gradlew build
echo '// delta change' >> "$RUNNER_TEMP/project/build.gradle.kts"
go test -v -run ^TestIntegrationGradleBuild$ -timeout 300s ./cmd/gradle-cache/
env:
INTEGRATION_PROJECT_DIR: ${{ runner.temp }}/project
GRADLE_USER_HOME: ${{ runner.temp }}/gradle-home

# Post step saves a delta bundle for branch "integration-delta-test".

Expand Down Expand Up @@ -206,6 +209,7 @@ jobs:
run: |
cp -r cmd/gradle-cache/testdata/gradle-project "$RUNNER_TEMP/project"
chmod +x "$RUNNER_TEMP/project/gradlew"
echo '// delta change' >> "$RUNNER_TEMP/project/build.gradle.kts"

# Restore full + delta bundle concurrently.
- uses: ./
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ needed:
|-------|---------|-------------|
| `cache-key` | `github.job` | Cache key identifying the bundle. Each job gets its own cache by default. |
| `ref` | repo default branch | Git ref used to search for a base bundle. On PR restores, history walks from the merge-base of `HEAD` and this ref. |
| `branch` | auto-detected on PRs | Branch name for delta cache support. |
| `branch` | auto-detected on PRs | Branch name for delta cache support. Set to `"false"` to disable deltas and save a full bundle. |
| `project-dir` | `.` | Path to the Gradle project root. |
| `gradle-user-home` | `~/.gradle` | Path to GRADLE_USER_HOME. |
| `included-build` | | Comma-separated included build paths (e.g. `buildSrc,build-logic`). |
Expand Down
1 change: 1 addition & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ inputs:
it. When active, restore applies a branch delta concurrently with the
base bundle, and save-delta runs in the post step instead of a full save.
On pushes to the default branch, a full bundle is saved automatically.
Set to "false" to disable delta caching and save a full bundle on PRs too.
required: false
project-dir:
description: >
Expand Down
22 changes: 11 additions & 11 deletions action/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion action/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
"@vercel/ncc": "^0.45.0"
},
"overrides": {
"undici": "^8.0.0"
"undici": "^8.12.2"
}
}
18 changes: 10 additions & 8 deletions action/src/helpers.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const core = require("@actions/core");
const exec = require("@actions/exec");
const tc = require("@actions/tool-cache");
const fs = require("fs");
const os = require("os");
const path = require("path");
import * as core from "@actions/core";
import * as exec from "@actions/exec";
import * as tc from "@actions/tool-cache";
import * as fs from "node:fs";
import * as os from "node:os";
import * as path from "node:path";

/**
* Install the gradle-cache binary. Skips download if it's already on PATH.
Expand Down Expand Up @@ -126,12 +126,14 @@ function execOptions(extra) {
*
* Explicit `branch` input takes priority. Otherwise, on pull_request events
* we automatically use GITHUB_HEAD_REF (the PR source branch) so that delta
* caches work out of the box without any configuration.
* caches work out of the box without any configuration. Set `branch` to
* "false" to disable delta caching and save a full bundle instead.
*
* Returns empty string on push events (default branch builds save full bundles).
*/
function resolveBranch() {
const explicit = core.getInput("branch");
if (explicit === "false") return "";
if (explicit) return explicit;

const event = process.env.GITHUB_EVENT_NAME || "";
Expand Down Expand Up @@ -176,7 +178,7 @@ function isDefaultBranchBuild() {
return def !== "HEAD" && refName === def;
}

module.exports = {
export {
install,
backendArgs,
commonArgs,
Expand Down
8 changes: 4 additions & 4 deletions action/src/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const core = require("@actions/core");
const exec = require("@actions/exec");
const {
import * as core from "@actions/core";
import * as exec from "@actions/exec";
import {
backendArgs,
commonArgs,
gradleHomeArgs,
Expand All @@ -10,7 +10,7 @@ const {
resolveBranch,
defaultBranch,
isDefaultBranchBuild,
} = require("./helpers");
} from "./helpers.js";

async function run() {
try {
Expand Down
12 changes: 6 additions & 6 deletions action/src/post.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
const fs = require("fs");
const path = require("path");
const core = require("@actions/core");
const exec = require("@actions/exec");
const {
import * as fs from "node:fs";
import * as path from "node:path";
import * as core from "@actions/core";
import * as exec from "@actions/exec";
import {
backendArgs,
commonArgs,
gradleHomeArgs,
includedBuildArgs,
gitDirArgs,
execOptions,
resolveBranch,
} = require("./helpers");
} from "./helpers.js";

async function run() {
try {
Expand Down
4 changes: 2 additions & 2 deletions action/src/pre.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const core = require("@actions/core");
const { install } = require("./helpers");
import * as core from "@actions/core";
import { install } from "./helpers.js";

async function run() {
try {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion bin/go
2 changes: 1 addition & 1 deletion bin/gofmt
2 changes: 1 addition & 1 deletion cmd/gradle-cache/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ dependencies { implementation 'com.google.guava:guava:33.4.0-jre' }
name: "kotlin-dsl",
fixture: "gradle-project",
dslCacheID: "kotlin-dsl",
newBuild: `plugins { kotlin("jvm") version "2.3.20" }
newBuild: `plugins { kotlin("jvm") }
repositories { mavenCentral() }
dependencies { implementation("com.google.guava:guava:33.4.0-jre") }
`,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
kotlin("jvm") version "2.3.20"
kotlin("jvm") version "2.4.21"
id("com.example.included")
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.8.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.8.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Loading
Loading