Skip to content

Commit 8351fb9

Browse files
authored
Merge pull request #45 from nix-community/43-bug-restore-prefixes-first-match-still-triggers-when-primary-key-matches
2 parents 433f47d + 7e7c128 commit 8351fb9

File tree

8 files changed

+11
-11
lines changed

8 files changed

+11
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ See [action.yml](action.yml).
111111
| `primary-key` | <ul> <li>When a non-empty string, the action uses this key for restoring and saving a cache.</li> <li>Otherwise, the action fails.</li> </ul> | `true` | `""` |
112112
| `restore-prefixes-first-match` | <ul> <li>When a newline-separated non-empty list of non-empty key prefixes, when there's a miss on the <code>primary-key</code>, the action searches in this list for the first prefix for which there exists a cache with a matching key and the action tries to restore that cache.</li> <li>Otherwise, this input has no effect.</li> </ul> | `false` | `""` |
113113
| `restore-prefixes-all-matches` | <ul> <li>When a newline-separated non-empty list of non-empty key prefixes, the action tries to restore all caches whose keys match these prefixes.</li> <li>Tries caches across all refs to make use of caches created on the current, base, and default branches (see <a href="https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache">docs</a>).</li> <li>Otherwise, this input has no effect.</li> </ul> | `false` | `""` |
114-
| `skip-restore-on-hit-primary-key` | <ul> <li>Can have an effect only when <code>restore-prefixes-first-match</code> has no effect.</li> <li>When <code>true</code>, when there's a hit on the <code>primary-key</code>, the action doesn't restore caches.</li> <li>Otherwise, this input has no effect.</li> </ul> | `false` | `false` |
114+
| `skip-restore-on-hit-primary-key` | <ul> <li>Can have an effect only when <code>restore-prefixes-first-match</code> has no effect.</li> <li>When <code>true</code>, when there's a hit on the <code>primary-key</code>, the action doesn't restore caches.</li> <li>Otherwise, the action restores caches.</li> </ul> | `false` | `false` |
115115
| `fail-on` | <ul> <li>Input form: <code>&lt;key type&gt;.&lt;result&gt;</code>.</li> <li><code>&lt;key type&gt;</code> options: <code>primary-key</code>, <code>first-match</code>.</li> <li><code>&lt;result&gt;</code> options: <code>miss</code>, <code>not-restored</code>.</li> <li>When the input satisfies the input form, when the event described in the input happens, the action fails.</li> <li>Example:<ul> <li>Input: <code>primary-key.not-restored</code>.</li> <li>Event: a cache could not be restored via the <code>primary-key</code>.</li></ul></li> <li>Otherwise, this input has no effect.</li> </ul> | `false` | `""` |
116116
| `nix` | <ul> <li>Can have an effect only when the action runs on a <code>Linux</code> or a <code>macOS</code> runner.</li> <li>When <code>true</code>, the action can do Nix-specific things.</li> <li>Otherwise, the action doesn't do them.</li> </ul> | `false` | `true` |
117117
| `save` | <ul> <li>When <code>true</code>, the action can save a cache with the <code>primary-key</code>.</li> <li>Otherwise, the action can't save a cache.</li> </ul> | `false` | `true` |

action.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ in
9191
description: |
9292
- Can have an effect only when ${q restore-prefixes-first-match} has no effect.
9393
- When `true`, when there's a hit on the ${q primary-key}, the action doesn't restore caches.
94-
- ${noEffectOtherwise}
94+
- Otherwise, the action restores caches.
9595
default: "false"
9696
9797
fail-on:

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ inputs:
2929
description: |
3030
- Can have an effect only when `restore-prefixes-first-match` has no effect.
3131
- When `true`, when there's a hit on the `primary-key`, the action doesn't restore caches.
32-
- Otherwise, this input has no effect.
32+
- Otherwise, the action restores caches.
3333
default: "false"
3434

3535
fail-on:

dist/restore-only/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94537,7 +94537,7 @@ function restoreImpl(stateProvider, earlyExit) {
9453794537
}
9453894538
let hitFirstMatch = false;
9453994539
if (inputs.restorePrefixesFirstMatch.length > 0 &&
94540-
!(lookedUpPrimaryKey && inputs.skipRestoreOnHitPrimaryKey)) {
94540+
!(lookedUpPrimaryKey || inputs.skipRestoreOnHitPrimaryKey)) {
9454194541
utils.info(`
9454294542
Searching for a cache using the "${constants_1.Inputs.RestorePrefixesFirstMatch}":
9454394543
${JSON.stringify(inputs.restorePrefixesFirstMatch)}
@@ -94569,7 +94569,7 @@ function restoreImpl(stateProvider, earlyExit) {
9456994569
}
9457094570
}
9457194571
}
94572-
if (!(lookedUpPrimaryKey && inputs.skipRestoreOnHitPrimaryKey)) {
94572+
if (!(lookedUpPrimaryKey || inputs.skipRestoreOnHitPrimaryKey)) {
9457394573
restoredKeys.push(...(yield restore.restoreAllMatches()));
9457494574
}
9457594575
restoredKey !== null && restoredKey !== void 0 ? restoredKey : (restoredKey = "");

dist/restore/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94537,7 +94537,7 @@ function restoreImpl(stateProvider, earlyExit) {
9453794537
}
9453894538
let hitFirstMatch = false;
9453994539
if (inputs.restorePrefixesFirstMatch.length > 0 &&
94540-
!(lookedUpPrimaryKey && inputs.skipRestoreOnHitPrimaryKey)) {
94540+
!(lookedUpPrimaryKey || inputs.skipRestoreOnHitPrimaryKey)) {
9454194541
utils.info(`
9454294542
Searching for a cache using the "${constants_1.Inputs.RestorePrefixesFirstMatch}":
9454394543
${JSON.stringify(inputs.restorePrefixesFirstMatch)}
@@ -94569,7 +94569,7 @@ function restoreImpl(stateProvider, earlyExit) {
9456994569
}
9457094570
}
9457194571
}
94572-
if (!(lookedUpPrimaryKey && inputs.skipRestoreOnHitPrimaryKey)) {
94572+
if (!(lookedUpPrimaryKey || inputs.skipRestoreOnHitPrimaryKey)) {
9457394573
restoredKeys.push(...(yield restore.restoreAllMatches()));
9457494574
}
9457594575
restoredKey !== null && restoredKey !== void 0 ? restoredKey : (restoredKey = "");

restore/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The restore action restores a cache. It works similarly to the `cache` action ex
1313
| `primary-key` | <ul> <li>When a non-empty string, the action uses this key for restoring a cache.</li> <li>Otherwise, the action fails.</li> </ul> | `true` | `""` |
1414
| `restore-prefixes-first-match` | <ul> <li>When a newline-separated non-empty list of non-empty key prefixes, when there's a miss on the <code>primary-key</code>, the action searches in this list for the first prefix for which there exists a cache with a matching key and the action tries to restore that cache.</li> <li>Otherwise, this input has no effect.</li> </ul> | `false` | `""` |
1515
| `restore-prefixes-all-matches` | <ul> <li>When a newline-separated non-empty list of non-empty key prefixes, the action tries to restore all caches whose keys match these prefixes.</li> <li>Tries caches across all refs to make use of caches created on the current, base, and default branches (see <a href="https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache">docs</a>).</li> <li>Otherwise, this input has no effect.</li> </ul> | `false` | `""` |
16-
| `skip-restore-on-hit-primary-key` | <ul> <li>Can have an effect only when <code>restore-prefixes-first-match</code> has no effect.</li> <li>When <code>true</code>, when there's a hit on the <code>primary-key</code>, the action doesn't restore caches.</li> <li>Otherwise, this input has no effect.</li> </ul> | `false` | `false` |
16+
| `skip-restore-on-hit-primary-key` | <ul> <li>Can have an effect only when <code>restore-prefixes-first-match</code> has no effect.</li> <li>When <code>true</code>, when there's a hit on the <code>primary-key</code>, the action doesn't restore caches.</li> <li>Otherwise, the action restores caches.</li> </ul> | `false` | `false` |
1717
| `fail-on` | <ul> <li>Input form: <code>&lt;key type&gt;.&lt;result&gt;</code>.</li> <li><code>&lt;key type&gt;</code> options: <code>primary-key</code>, <code>first-match</code>.</li> <li><code>&lt;result&gt;</code> options: <code>miss</code>, <code>not-restored</code>.</li> <li>When the input satisfies the input form, when the event described in the input happens, the action fails.</li> <li>Example:<ul> <li>Input: <code>primary-key.not-restored</code>.</li> <li>Event: a cache could not be restored via the <code>primary-key</code>.</li></ul></li> <li>Otherwise, this input has no effect.</li> </ul> | `false` | `""` |
1818
| `nix` | <ul> <li>Can have an effect only when the action runs on a <code>Linux</code> or a <code>macOS</code> runner.</li> <li>When <code>true</code>, the action can do Nix-specific things.</li> <li>Otherwise, the action doesn't do them.</li> </ul> | `false` | `true` |
1919
| `save` | <ul> <li>When <code>true</code>, the action can save a cache with the <code>primary-key</code>.</li> <li>Otherwise, the action can't save a cache.</li> </ul> | `false` | `true` |

restore/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ inputs:
2929
description: |
3030
- Can have an effect only when `restore-prefixes-first-match` has no effect.
3131
- When `true`, when there's a hit on the `primary-key`, the action doesn't restore caches.
32-
- Otherwise, this input has no effect.
32+
- Otherwise, the action restores caches.
3333
default: "false"
3434

3535
fail-on:

src/restoreImpl.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export async function restoreImpl(
9292

9393
if (
9494
inputs.restorePrefixesFirstMatch.length > 0 &&
95-
!(lookedUpPrimaryKey && inputs.skipRestoreOnHitPrimaryKey)
95+
!(lookedUpPrimaryKey || inputs.skipRestoreOnHitPrimaryKey)
9696
) {
9797
utils.info(
9898
`
@@ -136,7 +136,7 @@ export async function restoreImpl(
136136
}
137137
}
138138

139-
if (!(lookedUpPrimaryKey && inputs.skipRestoreOnHitPrimaryKey)) {
139+
if (!(lookedUpPrimaryKey || inputs.skipRestoreOnHitPrimaryKey)) {
140140
restoredKeys.push(...(await restore.restoreAllMatches()));
141141
}
142142

0 commit comments

Comments
 (0)