Compare commits

...

8 Commits

Author SHA1 Message Date
K.B.Dharun Krishna
6e054c87ac
Merge f5f477ac75 into 40c3b67b29 2024-08-03 12:02:00 +01:00
r4mimu
40c3b67b29
Fix cache-hit output when cache missed (#1404)
* fix: cache-hit output

* fix: Output chache hit timing

* fix: Output chache hit timing

---------

Co-authored-by: Josh Gross <joshmgross@github.com>
2024-07-31 16:56:48 +00:00
Oleg A.
e47d9f9ec8
Explicit use bash for Windows (#1377)
Co-authored-by: Josh Gross <joshmgross@github.com>
2024-07-31 16:52:21 +00:00
P. Ottlinger
4a28cbc054
Update README.md and use v4 of checkout action (#1437)
Update examples to use latest available checkout action v4.
2024-07-29 16:07:30 -04:00
K.B.Dharun Krishna
f5f477ac75
revert: bump to setup-node
Co-authored-by: Yukai Chou <muzimuzhi@gmail.com>
2024-02-02 09:23:54 +05:30
K.B.Dharun Krishna
dbe5320346
Merge branch 'main' into main 2024-02-02 08:11:15 +05:30
K.B.Dharun Krishna
0ccaf0fa01
Merge branch 'main' into main 2023-10-24 22:55:24 +05:30
K.B.Dharun Krishna
8070854e57
feat: bump to use node20 runtime, actions/checkout to v4 2023-09-05 09:48:13 +05:30
13 changed files with 30 additions and 26 deletions

View File

@ -17,7 +17,7 @@ jobs:
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v3 uses: actions/checkout@v4
# Initializes the CodeQL tools for scanning. # Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL - name: Initialize CodeQL

View File

@ -20,7 +20,7 @@ jobs:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
- name: Setup Node.js 20.x - name: Setup Node.js 20.x
uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
@ -43,7 +43,7 @@ jobs:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
- name: Generate files in working directory - name: Generate files in working directory
shell: bash shell: bash
run: __tests__/create-cache-files.sh ${{ runner.os }} test-cache run: __tests__/create-cache-files.sh ${{ runner.os }} test-cache
@ -66,7 +66,7 @@ jobs:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
- name: Restore cache - name: Restore cache
uses: ./ uses: ./
with: with:
@ -96,7 +96,7 @@ jobs:
https_proxy: http://squid-proxy:3128 https_proxy: http://squid-proxy:3128
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
- name: Generate files - name: Generate files
run: __tests__/create-cache-files.sh proxy test-cache run: __tests__/create-cache-files.sh proxy test-cache
- name: Save cache - name: Save cache
@ -119,7 +119,7 @@ jobs:
https_proxy: http://squid-proxy:3128 https_proxy: http://squid-proxy:3128
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
- name: Restore cache - name: Restore cache
uses: ./ uses: ./
with: with:

View File

@ -91,7 +91,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- name: Cache Primes - name: Cache Primes
id: cache-primes id: cache-primes
@ -122,7 +122,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- name: Restore cached Primes - name: Restore cached Primes
id: cache-primes-restore id: cache-primes-restore
@ -229,7 +229,7 @@ Example:
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- uses: actions/cache@v4 - uses: actions/cache@v4
id: cache id: cache
@ -259,7 +259,7 @@ jobs:
build-linux: build-linux:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- name: Cache Primes - name: Cache Primes
id: cache-primes id: cache-primes
@ -286,7 +286,7 @@ jobs:
build-windows: build-windows:
runs-on: windows-latest runs-on: windows-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- name: Cache Primes - name: Cache Primes
id: cache-primes id: cache-primes

View File

@ -260,7 +260,7 @@ test("Fail restore when fail on cache miss is enabled and primary + restore keys
); );
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key); expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(0); expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
expect(failedMock).toHaveBeenCalledWith( expect(failedMock).toHaveBeenCalledWith(
`Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: ${key}` `Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: ${key}`

View File

@ -86,7 +86,8 @@ test("restore with no cache found", async () => {
); );
expect(outputMock).toHaveBeenCalledWith("cache-primary-key", key); expect(outputMock).toHaveBeenCalledWith("cache-primary-key", key);
expect(outputMock).toHaveBeenCalledTimes(1); expect(outputMock).toHaveBeenCalledWith("cache-hit", "false");
expect(outputMock).toHaveBeenCalledTimes(2);
expect(failedMock).toHaveBeenCalledTimes(0); expect(failedMock).toHaveBeenCalledTimes(0);
expect(infoMock).toHaveBeenCalledWith( expect(infoMock).toHaveBeenCalledWith(

View File

@ -146,7 +146,7 @@ In case you are using a centralized job to create and save your cache that can b
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- uses: actions/cache/restore@v3 - uses: actions/cache/restore@v3
id: cache id: cache
@ -171,7 +171,7 @@ You can use the output of this action to exit the workflow on cache miss. This w
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- uses: actions/cache/restore@v3 - uses: actions/cache/restore@v3
id: cache id: cache
@ -249,7 +249,7 @@ Similarly, `actions/cache/save` action can be conditionally used based on the ou
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
. .
. // restore if need be . // restore if need be
. .
@ -270,7 +270,7 @@ In case of multi-module projects, where the built artifact of one project needs
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- name: Build - name: Build
run: ./build-parent-module.sh run: ./build-parent-module.sh
@ -286,7 +286,7 @@ steps:
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- uses: actions/cache/restore@v3 - uses: actions/cache/restore@v3
id: cache id: cache

View File

@ -59415,6 +59415,7 @@ function restoreImpl(stateProvider, earlyExit) {
const lookupOnly = utils.getInputAsBool(constants_1.Inputs.LookupOnly); const lookupOnly = utils.getInputAsBool(constants_1.Inputs.LookupOnly);
const cacheKey = yield cache.restoreCache(cachePaths, primaryKey, restoreKeys, { lookupOnly: lookupOnly }, enableCrossOsArchive); const cacheKey = yield cache.restoreCache(cachePaths, primaryKey, restoreKeys, { lookupOnly: lookupOnly }, enableCrossOsArchive);
if (!cacheKey) { if (!cacheKey) {
core.setOutput(constants_1.Outputs.CacheHit, false.toString());
if (failOnCacheMiss) { if (failOnCacheMiss) {
throw new Error(`Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: ${primaryKey}`); throw new Error(`Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: ${primaryKey}`);
} }

View File

@ -59415,6 +59415,7 @@ function restoreImpl(stateProvider, earlyExit) {
const lookupOnly = utils.getInputAsBool(constants_1.Inputs.LookupOnly); const lookupOnly = utils.getInputAsBool(constants_1.Inputs.LookupOnly);
const cacheKey = yield cache.restoreCache(cachePaths, primaryKey, restoreKeys, { lookupOnly: lookupOnly }, enableCrossOsArchive); const cacheKey = yield cache.restoreCache(cachePaths, primaryKey, restoreKeys, { lookupOnly: lookupOnly }, enableCrossOsArchive);
if (!cacheKey) { if (!cacheKey) {
core.setOutput(constants_1.Outputs.CacheHit, false.toString());
if (failOnCacheMiss) { if (failOnCacheMiss) {
throw new Error(`Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: ${primaryKey}`); throw new Error(`Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: ${primaryKey}`);
} }

View File

@ -513,6 +513,7 @@ jobs:
```yaml ```yaml
- name: Get pip cache dir - name: Get pip cache dir
id: pip-cache id: pip-cache
shell: bash
run: | run: |
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT

View File

@ -35,7 +35,7 @@ If you are using separate jobs to create and save your cache(s) to be reused by
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- uses: actions/cache/restore@v3 - uses: actions/cache/restore@v3
id: cache id: cache
@ -64,7 +64,7 @@ In case of multi-module projects, where the built artifact of one project needs
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- name: Build - name: Build
run: /build-parent-module.sh run: /build-parent-module.sh
@ -80,7 +80,7 @@ steps:
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- uses: actions/cache/restore@v3 - uses: actions/cache/restore@v3
id: cache id: cache
@ -107,7 +107,7 @@ To fail if there is no cache hit for the primary key, leave `restore-keys` empty
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- uses: actions/cache/restore@v3 - uses: actions/cache/restore@v3
id: cache id: cache

View File

@ -23,7 +23,7 @@ If you are using separate jobs for generating common artifacts and sharing them
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- name: Install Dependencies - name: Install Dependencies
run: /install.sh run: /install.sh
@ -74,7 +74,7 @@ There are instances where some flaky test cases would fail the entire workflow a
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
. .
. // restore if need be . // restore if need be
. .

View File

@ -51,6 +51,7 @@ export async function restoreImpl(
); );
if (!cacheKey) { if (!cacheKey) {
core.setOutput(Outputs.CacheHit, false.toString());
if (failOnCacheMiss) { if (failOnCacheMiss) {
throw new Error( throw new Error(
`Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: ${primaryKey}` `Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: ${primaryKey}`
@ -62,7 +63,6 @@ export async function restoreImpl(
...restoreKeys ...restoreKeys
].join(", ")}` ].join(", ")}`
); );
return; return;
} }

View File

@ -61,7 +61,7 @@ jobs:
contents: read contents: read
steps: steps:
- name: Check out code - name: Check out code
uses: actions/checkout@v3 uses: actions/checkout@v4
- name: Cleanup - name: Cleanup
run: | run: |