Skip to content

Commit f6ea2dd

Browse files
committed
Make skip-restore opinionated, drop the restore input
Default-branch builds always skip restore and publish a fresh base bundle. No setting to override.
1 parent 250295e commit f6ea2dd

7 files changed

Lines changed: 12 additions & 84 deletions

File tree

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@ needed:
6363
from the **merge-base** of the PR branch and the default branch) and, after
6464
the build, publish a **delta** containing only the files that changed.
6565

66-
If you need to override the automatic choice, set the `restore` input to
67-
`"true"` or `"false"` (default is `"auto"`).
68-
6966
### Inputs
7067

7168
| Input | Default | Description |
@@ -78,7 +75,6 @@ If you need to override the automatic choice, set the `restore` input to
7875
| `included-build` | | Comma-separated included build paths (e.g. `buildSrc,build-logic`). |
7976
| `bucket` | | S3 bucket name. When set, uses S3 instead of the GitHub Actions cache. |
8077
| `region` | `us-west-2` | AWS region (only used with `bucket`). |
81-
| `restore` | `auto` | Restore before the build. `auto` skips restore on default-branch builds and restores on branches/PRs. Set `true`/`false` to override. |
8278
| `save` | `true` | Set to `false` to skip saving after the build. |
8379
| `version` | `latest` | Version of gradle-cache to install. |
8480
| `log-level` | `info` | Log level: `debug`, `info`, `warn`, or `error`. |

action.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,6 @@ inputs:
5757
Comma-separated list of included build paths to archive
5858
(e.g. "buildSrc,build-logic"). Defaults to buildSrc.
5959
required: false
60-
restore:
61-
description: >
62-
Whether to restore a cache before the build. Defaults to "auto": restore
63-
is skipped on default-branch builds (which publish a fresh base bundle so
64-
it never grows without bound) and enabled on branches/PRs (which restore
65-
the base and publish a delta). Set to "true" or "false" to override.
66-
required: false
67-
default: "auto"
6860
save:
6961
description: Whether to save the cache after the build. Set to "false" to skip.
7062
required: false

action/src/helpers.js

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ function defaultBranch() {
163163
/**
164164
* True when this run is a push build of the repository's default branch.
165165
* These builds publish a fresh full ("base") bundle and never restore, so the
166-
* bundle doesn't grow without bound across commits.
166+
* bundle doesn't grow without bound across commits. Branches and PRs restore
167+
* the base and publish a delta.
167168
*/
168169
function isDefaultBranchBuild() {
169170
const event = process.env.GITHUB_EVENT_NAME || "";
@@ -175,21 +176,6 @@ function isDefaultBranchBuild() {
175176
return def !== "HEAD" && refName === def;
176177
}
177178

178-
/**
179-
* Decide whether to restore a cache before the build.
180-
*
181-
* The `restore` input is an explicit override ("true"/"false"). When left at
182-
* the default ("auto"), restore is skipped on default-branch builds (which
183-
* publish a fresh base bundle) and enabled everywhere else (branches/PRs that
184-
* restore the base and publish a delta).
185-
*/
186-
function shouldRestore() {
187-
const input = (core.getInput("restore") || "auto").toLowerCase();
188-
if (input === "false") return false;
189-
if (input === "true") return true;
190-
return !isDefaultBranchBuild();
191-
}
192-
193179
module.exports = {
194180
install,
195181
backendArgs,
@@ -201,5 +187,4 @@ module.exports = {
201187
resolveBranch,
202188
defaultBranch,
203189
isDefaultBranchBuild,
204-
shouldRestore,
205190
};

action/src/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const {
99
execOptions,
1010
resolveBranch,
1111
defaultBranch,
12-
shouldRestore,
12+
isDefaultBranchBuild,
1313
} = require("./helpers");
1414

1515
async function run() {
@@ -18,7 +18,7 @@ async function run() {
1818
core.saveState("cache-key", core.getInput("cache-key"));
1919
core.saveState("save", core.getInput("save"));
2020

21-
if (!shouldRestore()) {
21+
if (isDefaultBranchBuild()) {
2222
core.info(
2323
"Cache restore skipped — default-branch build publishes a fresh base bundle",
2424
);

dist/main/index.js

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33687,7 +33687,8 @@ function defaultBranch() {
3368733687
/**
3368833688
* True when this run is a push build of the repository's default branch.
3368933689
* These builds publish a fresh full ("base") bundle and never restore, so the
33690-
* bundle doesn't grow without bound across commits.
33690+
* bundle doesn't grow without bound across commits. Branches and PRs restore
33691+
* the base and publish a delta.
3369133692
*/
3369233693
function isDefaultBranchBuild() {
3369333694
const event = process.env.GITHUB_EVENT_NAME || "";
@@ -33699,21 +33700,6 @@ function isDefaultBranchBuild() {
3369933700
return def !== "HEAD" && refName === def;
3370033701
}
3370133702

33702-
/**
33703-
* Decide whether to restore a cache before the build.
33704-
*
33705-
* The `restore` input is an explicit override ("true"/"false"). When left at
33706-
* the default ("auto"), restore is skipped on default-branch builds (which
33707-
* publish a fresh base bundle) and enabled everywhere else (branches/PRs that
33708-
* restore the base and publish a delta).
33709-
*/
33710-
function shouldRestore() {
33711-
const input = (core.getInput("restore") || "auto").toLowerCase();
33712-
if (input === "false") return false;
33713-
if (input === "true") return true;
33714-
return !isDefaultBranchBuild();
33715-
}
33716-
3371733703
module.exports = {
3371833704
install,
3371933705
backendArgs,
@@ -33725,7 +33711,6 @@ module.exports = {
3372533711
resolveBranch,
3372633712
defaultBranch,
3372733713
isDefaultBranchBuild,
33728-
shouldRestore,
3372933714
};
3373033715

3373133716

@@ -34061,7 +34046,7 @@ const {
3406134046
execOptions,
3406234047
resolveBranch,
3406334048
defaultBranch,
34064-
shouldRestore,
34049+
isDefaultBranchBuild,
3406534050
} = __nccwpck_require__(6636);
3406634051

3406734052
async function run() {
@@ -34070,7 +34055,7 @@ async function run() {
3407034055
core.saveState("cache-key", core.getInput("cache-key"));
3407134056
core.saveState("save", core.getInput("save"));
3407234057

34073-
if (!shouldRestore()) {
34058+
if (isDefaultBranchBuild()) {
3407434059
core.info(
3407534060
"Cache restore skipped — default-branch build publishes a fresh base bundle",
3407634061
);

dist/post/index.js

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33687,7 +33687,8 @@ function defaultBranch() {
3368733687
/**
3368833688
* True when this run is a push build of the repository's default branch.
3368933689
* These builds publish a fresh full ("base") bundle and never restore, so the
33690-
* bundle doesn't grow without bound across commits.
33690+
* bundle doesn't grow without bound across commits. Branches and PRs restore
33691+
* the base and publish a delta.
3369133692
*/
3369233693
function isDefaultBranchBuild() {
3369333694
const event = process.env.GITHUB_EVENT_NAME || "";
@@ -33699,21 +33700,6 @@ function isDefaultBranchBuild() {
3369933700
return def !== "HEAD" && refName === def;
3370033701
}
3370133702

33702-
/**
33703-
* Decide whether to restore a cache before the build.
33704-
*
33705-
* The `restore` input is an explicit override ("true"/"false"). When left at
33706-
* the default ("auto"), restore is skipped on default-branch builds (which
33707-
* publish a fresh base bundle) and enabled everywhere else (branches/PRs that
33708-
* restore the base and publish a delta).
33709-
*/
33710-
function shouldRestore() {
33711-
const input = (core.getInput("restore") || "auto").toLowerCase();
33712-
if (input === "false") return false;
33713-
if (input === "true") return true;
33714-
return !isDefaultBranchBuild();
33715-
}
33716-
3371733703
module.exports = {
3371833704
install,
3371933705
backendArgs,
@@ -33725,7 +33711,6 @@ module.exports = {
3372533711
resolveBranch,
3372633712
defaultBranch,
3372733713
isDefaultBranchBuild,
33728-
shouldRestore,
3372933714
};
3373033715

3373133716

dist/pre/index.js

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33687,7 +33687,8 @@ function defaultBranch() {
3368733687
/**
3368833688
* True when this run is a push build of the repository's default branch.
3368933689
* These builds publish a fresh full ("base") bundle and never restore, so the
33690-
* bundle doesn't grow without bound across commits.
33690+
* bundle doesn't grow without bound across commits. Branches and PRs restore
33691+
* the base and publish a delta.
3369133692
*/
3369233693
function isDefaultBranchBuild() {
3369333694
const event = process.env.GITHUB_EVENT_NAME || "";
@@ -33699,21 +33700,6 @@ function isDefaultBranchBuild() {
3369933700
return def !== "HEAD" && refName === def;
3370033701
}
3370133702

33702-
/**
33703-
* Decide whether to restore a cache before the build.
33704-
*
33705-
* The `restore` input is an explicit override ("true"/"false"). When left at
33706-
* the default ("auto"), restore is skipped on default-branch builds (which
33707-
* publish a fresh base bundle) and enabled everywhere else (branches/PRs that
33708-
* restore the base and publish a delta).
33709-
*/
33710-
function shouldRestore() {
33711-
const input = (core.getInput("restore") || "auto").toLowerCase();
33712-
if (input === "false") return false;
33713-
if (input === "true") return true;
33714-
return !isDefaultBranchBuild();
33715-
}
33716-
3371733703
module.exports = {
3371833704
install,
3371933705
backendArgs,
@@ -33725,7 +33711,6 @@ module.exports = {
3372533711
resolveBranch,
3372633712
defaultBranch,
3372733713
isDefaultBranchBuild,
33728-
shouldRestore,
3372933714
};
3373033715

3373133716

0 commit comments

Comments
 (0)