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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ Have a look under [Advanced Configuration](#advanced-configuration) for detailed
# Whether to restore the cache if found
restore-cache: "true"

# Whether to save the cache after the run
save-cache: "true"
# Whether to save the cache after the run: true, false, or auto (disabled for merge_group events)
save-cache: "auto"

# Suffix for the cache key
cache-suffix: ""
Expand Down Expand Up @@ -159,7 +159,7 @@ python 3.13
```

```yaml
- uses: step-security/setup-uv@v9
- uses: step-security/setup-uv@v10
with:
version-file: ".tool-versions"
```
Expand Down
45 changes: 45 additions & 0 deletions __tests__/utils/inputs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,51 @@ describe("loadInputs", () => {
expect(inputs.enableCache).toBe(true);
});

it("restores but does not save cache automatically for merge groups", () => {
mockInputs["working-directory"] = "/workspace";
mockInputs["enable-cache"] = "auto";
mockInputs["restore-cache"] = "true";
mockInputs["save-cache"] = "auto";
process.env.RUNNER_ENVIRONMENT = "github-hosted";
process.env.RUNNER_TEMP = "/runner-temp";
process.env.GITHUB_EVENT_NAME = "merge_group";

const inputs = loadInputs();

expect(inputs.enableCache).toBe(true);
expect(inputs.restoreCache).toBe(true);
expect(inputs.saveCache).toBe(false);
expect(mockInfo).toHaveBeenCalledWith(
"Cache saving is disabled for the merge_group event",
);
});

it.each([
["true", true],
["false", false],
])("honors save-cache %s for merge groups", (saveCacheInput, expected) => {
mockInputs["working-directory"] = "/workspace";
mockInputs["save-cache"] = saveCacheInput;
process.env.GITHUB_EVENT_NAME = "merge_group";

const inputs = loadInputs();

expect(inputs.saveCache).toBe(expected);
expect(mockInfo).not.toHaveBeenCalledWith(
"Cache saving is disabled for the merge_group event",
);
});

it("automatically saves cache for other events", () => {
mockInputs["working-directory"] = "/workspace";
mockInputs["save-cache"] = "auto";
process.env.GITHUB_EVENT_NAME = "push";

const inputs = loadInputs();

expect(inputs.saveCache).toBe(true);
});

it("uses cache-dir from pyproject.toml when present", () => {
mockInputs["working-directory"] = createTempProject({
"pyproject.toml": `[project]
Expand Down
6 changes: 5 additions & 1 deletion action-types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ inputs:
restore-cache:
type: boolean
save-cache:
type: boolean
type: enum
allowed-values:
- "true"
- "false"
- auto
cache-suffix:
type: string
cache-local-path:
Expand Down
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ inputs:
description: "Whether to restore the cache if found."
default: "true"
save-cache:
description: "Whether to save the cache after the run."
default: "true"
description: "Whether to save the cache after the run. 'auto' disables saving for merge_group events."
default: "auto"
cache-suffix:
description: "Suffix for the cache key"
required: false
Expand Down
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://biomejs.dev/schemas/2.5.8/schema.json",
"$schema": "https://biomejs.dev/schemas/2.5.9/schema.json",
"assist": {
"actions": {
"source": {
Expand Down
Loading
Loading