Compare commits

..
Author SHA1 Message Date
dependabot[bot] 745332c95a build(deps): bump github/codeql-action from 3 to 4
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3 to 4.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/v3...v4)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: '4'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
2026-03-02 22:54:22 +00:00
53 changed files with 185414 additions and 219050 deletions
+3 -3
View File
@@ -20,7 +20,7 @@ jobs:
# Initializes the CodeQL tools for scanning. # Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL - name: Initialize CodeQL
uses: github/codeql-action/init@v3 uses: github/codeql-action/init@v4
# Override language selection by uncommenting this and choosing your languages # Override language selection by uncommenting this and choosing your languages
# with: # with:
# languages: go, javascript, csharp, python, cpp, java, ruby # languages: go, javascript, csharp, python, cpp, java, ruby
@@ -28,7 +28,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below). # If this step fails, then you should remove it and run the build manually (see below).
- name: Autobuild - name: Autobuild
uses: github/codeql-action/autobuild@v3 uses: github/codeql-action/autobuild@v4
# ℹ️ Command-line programs to run using the OS shell. # ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -42,4 +42,4 @@ jobs:
# make release # make release
- name: Perform CodeQL Analysis - name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3 uses: github/codeql-action/analyze@v4
+1 -1
View File
@@ -1,6 +1,6 @@
--- ---
name: "@actions/cache" name: "@actions/cache"
version: 6.1.0 version: 5.0.5
type: npm type: npm
summary: Actions cache lib summary: Actions cache lib
homepage: https://github.com/actions/toolkit/tree/main/packages/cache homepage: https://github.com/actions/toolkit/tree/main/packages/cache
+1 -1
View File
@@ -1,6 +1,6 @@
--- ---
name: "@actions/core" name: "@actions/core"
version: 3.0.1 version: 2.0.3
type: npm type: npm
summary: Actions core lib summary: Actions core lib
homepage: https://github.com/actions/toolkit/tree/main/packages/core homepage: https://github.com/actions/toolkit/tree/main/packages/core
+1 -1
View File
@@ -1,6 +1,6 @@
--- ---
name: "@actions/exec" name: "@actions/exec"
version: 3.0.0 version: 2.0.0
type: npm type: npm
summary: Actions exec lib summary: Actions exec lib
homepage: https://github.com/actions/toolkit/tree/main/packages/exec homepage: https://github.com/actions/toolkit/tree/main/packages/exec
+1 -1
View File
@@ -1,6 +1,6 @@
--- ---
name: "@actions/glob" name: "@actions/glob"
version: 0.6.1 version: 0.5.1
type: npm type: npm
summary: Actions glob lib summary: Actions glob lib
homepage: https://github.com/actions/toolkit/tree/main/packages/glob homepage: https://github.com/actions/toolkit/tree/main/packages/glob
+1 -1
View File
@@ -1,6 +1,6 @@
--- ---
name: "@actions/http-client" name: "@actions/http-client"
version: 4.0.1 version: 3.0.2
type: npm type: npm
summary: Actions Http Client summary: Actions Http Client
homepage: https://github.com/actions/toolkit/tree/main/packages/http-client homepage: https://github.com/actions/toolkit/tree/main/packages/http-client
+1 -1
View File
@@ -1,6 +1,6 @@
--- ---
name: "@actions/io" name: "@actions/io"
version: 3.0.2 version: 2.0.0
type: npm type: npm
summary: Actions io lib summary: Actions io lib
homepage: https://github.com/actions/toolkit/tree/main/packages/io homepage: https://github.com/actions/toolkit/tree/main/packages/io
@@ -1,16 +1,16 @@
--- ---
name: path-expression-matcher name: "@azure/abort-controller"
version: 1.5.0 version: 1.1.0
type: npm type: npm
summary: Efficient path tracking and pattern matching for XML/JSON parsers summary: Microsoft Azure SDK for JavaScript - Aborter
homepage: https://github.com/NaturalIntelligence/path-expression-matcher#readme homepage: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/abort-controller/README.md
license: mit license: mit
licenses: licenses:
- sources: LICENSE - sources: LICENSE
text: | text: |
MIT License The MIT License (MIT)
Copyright (c) 2024 Copyright (c) 2020 Microsoft
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
+1 -1
View File
@@ -1,6 +1,6 @@
--- ---
name: "@azure/core-client" name: "@azure/core-client"
version: 1.10.2 version: 1.10.1
type: npm type: npm
summary: Core library for interfacing with AutoRest generated code summary: Core library for interfacing with AutoRest generated code
homepage: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/core/core-client/ homepage: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/core/core-client/
+1 -1
View File
@@ -1,6 +1,6 @@
--- ---
name: "@azure/core-http-compat" name: "@azure/core-http-compat"
version: 2.4.0 version: 2.3.1
type: npm type: npm
summary: Core HTTP Compatibility Library to bridge the gap between Core V1 & V2 packages. summary: Core HTTP Compatibility Library to bridge the gap between Core V1 & V2 packages.
homepage: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/core/core-compat/ homepage: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/core/core-compat/
+2 -2
View File
@@ -1,9 +1,9 @@
--- ---
name: "@azure/core-rest-pipeline" name: "@azure/core-rest-pipeline"
version: 1.24.0 version: 1.22.2
type: npm type: npm
summary: Isomorphic client library for making HTTP requests in node.js and browser. summary: Isomorphic client library for making HTTP requests in node.js and browser.
homepage: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/core-rest-pipeline/README.md homepage: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/core/core-rest-pipeline/
license: mit license: mit
licenses: licenses:
- sources: LICENSE - sources: LICENSE
+1 -1
View File
@@ -1,6 +1,6 @@
--- ---
name: "@azure/core-xml" name: "@azure/core-xml"
version: 1.5.1 version: 1.5.0
type: npm type: npm
summary: Core library for interacting with XML payloads summary: Core library for interacting with XML payloads
homepage: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/core/core-xml/ homepage: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/core/core-xml/
+2 -2
View File
@@ -1,9 +1,9 @@
--- ---
name: "@azure/storage-blob" name: "@azure/storage-blob"
version: 12.32.0 version: 12.30.0
type: npm type: npm
summary: Microsoft Azure Storage SDK for JavaScript - Blob summary: Microsoft Azure Storage SDK for JavaScript - Blob
homepage: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/storage/storage-blob/README.md homepage: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/storage-blob/
license: mit license: mit
licenses: licenses:
- sources: LICENSE - sources: LICENSE
+2 -2
View File
@@ -1,9 +1,9 @@
--- ---
name: "@azure/storage-common" name: "@azure/storage-common"
version: 12.4.0 version: 12.2.0
type: npm type: npm
summary: Azure Storage Common Client Library for JavaScript summary: Azure Storage Common Client Library for JavaScript
homepage: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/storage/storage-common/README.md homepage: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/storage-internal-avro/
license: mit license: mit
licenses: licenses:
- sources: LICENSE - sources: LICENSE
-11
View File
@@ -1,11 +0,0 @@
---
name: "@nodable/entities"
version: 2.2.0
type: npm
summary: Entity parser for XML, HTML, External entites with security and NCR control
homepage:
license: mit
licenses:
- sources: README.md
text: MIT
notices: []
+2 -2
View File
@@ -1,9 +1,9 @@
--- ---
name: "@typespec/ts-http-runtime" name: "@typespec/ts-http-runtime"
version: 0.3.6 version: 0.3.2
type: npm type: npm
summary: Isomorphic client library for making HTTP requests in node.js and browser. summary: Isomorphic client library for making HTTP requests in node.js and browser.
homepage: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/ts-http-runtime/README.md homepage: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/core/ts-http-runtime/
license: mit license: mit
licenses: licenses:
- sources: LICENSE - sources: LICENSE
-35
View File
@@ -1,35 +0,0 @@
---
name: anynum
version: 1.0.1
type: npm
summary: Normalize all Unicode decimal digits (Devanagari, Arabic, Thai, etc.) to
ASCII numerals. Zero dependencies, performance-first.
homepage:
license: mit
licenses:
- sources: LICENSE
text: |
MIT License
Copyright (c) 2026 Natural Intelligence
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
- sources: README.md
text: MIT
notices: []
-32
View File
@@ -1,32 +0,0 @@
---
name: fast-xml-builder
version: 1.2.0
type: npm
summary: Build XML from JSON without C/C++ based libraries
homepage:
license: mit
licenses:
- sources: LICENSE
text: |
MIT License
Copyright (c) 2026 Natural Intelligence
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
notices: []
+1 -1
View File
@@ -1,6 +1,6 @@
--- ---
name: fast-xml-parser name: fast-xml-parser
version: 5.9.2 version: 5.3.3
type: npm type: npm
summary: Validate XML, Parse XML, Build XML without C/C++ based libraries summary: Validate XML, Parse XML, Build XML without C/C++ based libraries
homepage: homepage:
-35
View File
@@ -1,35 +0,0 @@
---
name: is-unsafe
version: 1.0.1
type: npm
summary: Zero-dependency, DOM-free, pure predicate for detecting unsafe strings across
HTML, XML, SVG, SQL, SHELL, and REGEX contexts
homepage:
license: mit
licenses:
- sources: LICENSE
text: |
MIT License
Copyright (c) 2026 Natural Intelligence
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
- sources: README.md
text: MIT
notices: []
+1 -1
View File
@@ -1,6 +1,6 @@
--- ---
name: minimatch name: minimatch
version: 3.1.5 version: 3.1.2
type: npm type: npm
summary: a glob matcher in javascript summary: a glob matcher in javascript
homepage: homepage:
+1 -1
View File
@@ -1,6 +1,6 @@
--- ---
name: semver name: semver
version: 7.8.5 version: 6.3.1
type: npm type: npm
summary: The semantic version parser used by npm. summary: The semantic version parser used by npm.
homepage: homepage:
+1 -1
View File
@@ -1,6 +1,6 @@
--- ---
name: strnum name: strnum
version: 2.4.1 version: 2.1.2
type: npm type: npm
summary: Parse String to Number based on configuration summary: Parse String to Number based on configuration
homepage: homepage:
+1 -1
View File
@@ -1,6 +1,6 @@
--- ---
name: undici name: undici
version: 6.27.0 version: 6.23.0
type: npm type: npm
summary: An HTTP/1.1 client, written from scratch for Node.js summary: An HTTP/1.1 client, written from scratch for Node.js
homepage: https://undici.nodejs.org homepage: https://undici.nodejs.org
-12
View File
@@ -1,12 +0,0 @@
---
name: xml-naming
version: 0.1.0
type: npm
summary: Validates XML name productions — Name, NCName, QName, NMToken, NMTokens —
for XML 1.0 and 1.1
homepage:
license: mit
licenses:
- sources: README.md
text: MIT
notices: []
+9 -22
View File
@@ -38,11 +38,6 @@ Upgrading to the recommended versions will not break your workflows.
Read more about the change & access the migration guide: [reference to the announcement](https://github.com/actions/cache/discussions/1510). Read more about the change & access the migration guide: [reference to the announcement](https://github.com/actions/cache/discussions/1510).
### v6
* Updated `@actions/cache`, `@actions/core`, `@actions/exec` to latest major versions
* Migrated to ESM module system
### v5 ### v5
* Updated to node 24 * Updated to node 24
@@ -114,14 +109,6 @@ The cache is scoped to the key, [version](#cache-version), and branch. The defau
See [Matching a cache key](https://help.github.com/en/actions/configuring-and-managing-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key) for more info. See [Matching a cache key](https://help.github.com/en/actions/configuring-and-managing-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key) for more info.
### Read-only access
Some workflow runs only have read-only access to the cache. A common case is a workflow triggered by a pull request from a fork: such runs can **restore** existing caches but may not be permitted to **save** new ones.
When the cache token is read-only, the save step does not fail the job. Instead, `@actions/cache` reports the denial once as a warning (for example, `Failed to save: ... cache write denied: ...`) and the step completes successfully without writing a cache entry. Restores in the same run continue to work as usual.
> **Note** This applies to the action's normal save path as well as the standalone [Save action](./save/README.md). If you intentionally want a restore-only setup, see [Make cache read only / Reuse cache from centralized job](./caching-strategies.md#make-cache-read-only--reuse-cache-from-centralized-job).
### Example cache workflow ### Example cache workflow
#### Restoring and saving cache using a single action #### Restoring and saving cache using a single action
@@ -140,7 +127,7 @@ jobs:
- name: Cache Primes - name: Cache Primes
id: cache-primes id: cache-primes
uses: actions/cache@v6 uses: actions/cache@v5
with: with:
path: prime-numbers path: prime-numbers
key: ${{ runner.os }}-primes key: ${{ runner.os }}-primes
@@ -171,7 +158,7 @@ jobs:
- name: Restore cached Primes - name: Restore cached Primes
id: cache-primes-restore id: cache-primes-restore
uses: actions/cache/restore@v6 uses: actions/cache/restore@v5
with: with:
path: | path: |
path/to/dependencies path/to/dependencies
@@ -182,7 +169,7 @@ jobs:
. .
- name: Save Primes - name: Save Primes
id: cache-primes-save id: cache-primes-save
uses: actions/cache/save@v6 uses: actions/cache/save@v5
with: with:
path: | path: |
path/to/dependencies path/to/dependencies
@@ -237,7 +224,7 @@ A cache key can include any of the contexts, functions, literals, and operators
For example, using the [`hashFiles`](https://docs.github.com/en/actions/learn-github-actions/expressions#hashfiles) function allows you to create a new cache when dependencies change. For example, using the [`hashFiles`](https://docs.github.com/en/actions/learn-github-actions/expressions#hashfiles) function allows you to create a new cache when dependencies change.
```yaml ```yaml
- uses: actions/cache@v6 - uses: actions/cache@v5
with: with:
path: | path: |
path/to/dependencies path/to/dependencies
@@ -255,7 +242,7 @@ Additionally, you can use arbitrary command output in a cache key, such as a dat
echo "date=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_OUTPUT echo "date=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_OUTPUT
shell: bash shell: bash
- uses: actions/cache@v6 - uses: actions/cache@v5
with: with:
path: path/to/dependencies path: path/to/dependencies
key: ${{ runner.os }}-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/lockfiles') }} key: ${{ runner.os }}-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/lockfiles') }}
@@ -277,7 +264,7 @@ Example:
steps: steps:
- uses: actions/checkout@v6 - uses: actions/checkout@v6
- uses: actions/cache@v6 - uses: actions/cache@v5
id: cache id: cache
with: with:
path: path/to/dependencies path: path/to/dependencies
@@ -309,7 +296,7 @@ jobs:
- name: Cache Primes - name: Cache Primes
id: cache-primes id: cache-primes
uses: actions/cache@v6 uses: actions/cache@v5
with: with:
path: prime-numbers path: prime-numbers
key: primes key: primes
@@ -320,7 +307,7 @@ jobs:
- name: Cache Numbers - name: Cache Numbers
id: cache-numbers id: cache-numbers
uses: actions/cache@v6 uses: actions/cache@v5
with: with:
path: numbers path: numbers
key: primes key: primes
@@ -336,7 +323,7 @@ jobs:
- name: Cache Primes - name: Cache Primes
id: cache-primes id: cache-primes
uses: actions/cache@v6 uses: actions/cache@v5
with: with:
path: prime-numbers path: prime-numbers
key: primes key: primes
-17
View File
@@ -25,23 +25,6 @@
## Changelog ## Changelog
### 6.1.0
- Bump `@actions/cache` to v6.1.0 to pick up [actions/toolkit#2435 Handle cache write error due to read-only token](https://github.com/actions/toolkit/pull/2435)
- Switch redundant "Cache save failed" warning to debug log in save-only
### 6.0.0
- Updated `@actions/cache` to ^6.0.1, `@actions/core` to ^3.0.1, `@actions/exec` to ^3.0.0, `@actions/io` to ^3.0.2
- Migrated to ESM module system
- Upgraded Jest to v30 and test infrastructure to be ESM compatible
### 5.0.4
- Bump `minimatch` to v3.1.5 (fixes ReDoS via globstar patterns)
- Bump `undici` to v6.24.1 (WebSocket decompression bomb protection, header validation fixes)
- Bump `fast-xml-parser` to v5.5.6
### 5.0.3 ### 5.0.3
- Bump `@actions/cache` to v5.0.5 (Resolves: https://github.com/actions/cache/security/dependabot/33) - Bump `@actions/cache` to v5.0.5 (Resolves: https://github.com/actions/cache/security/dependabot/33)
+73 -83
View File
@@ -1,66 +1,25 @@
import { afterAll, beforeEach, expect, jest, test } from "@jest/globals"; import * as cache from "@actions/cache";
import * as core from "@actions/core";
// Mock @actions/core import { Events, RefKey } from "../src/constants";
jest.unstable_mockModule("@actions/core", () => ({ import * as actionUtils from "../src/utils/actionUtils";
getInput: jest.fn((name: string, options?: { required?: boolean }) => { import * as testUtils from "../src/utils/testUtils";
const val =
process.env[`INPUT_${name.replace(/ /g, "_").toUpperCase()}`] || "";
if (options && options.required && !val) {
throw new Error(`Input required and not supplied: ${name}`);
}
return val.trim();
}),
setOutput: jest.fn(),
setFailed: jest.fn(),
info: jest.fn(),
warning: jest.fn(),
debug: jest.fn(),
error: jest.fn(),
saveState: jest.fn(),
getState: jest.fn(() => ""),
isDebug: jest.fn(() => false),
exportVariable: jest.fn(),
addPath: jest.fn(),
group: jest.fn((name: string, fn: () => Promise<unknown>) => fn()),
startGroup: jest.fn(),
endGroup: jest.fn()
}));
// Mock @actions/cache jest.mock("@actions/core");
jest.unstable_mockModule("@actions/cache", () => ({ jest.mock("@actions/cache");
restoreCache: jest.fn(),
saveCache: jest.fn(),
isFeatureAvailable: jest.fn(() => true),
ReserveCacheError: class ReserveCacheError extends Error {
constructor(message: string) {
super(message);
this.name = "ReserveCacheError";
}
}
}));
const core = await import("@actions/core");
const cache = await import("@actions/cache");
const { Events, RefKey } = await import("../src/constants");
const actionUtils = await import("../src/utils/actionUtils");
const testUtils = await import("../src/utils/testUtils");
let pristineEnv: NodeJS.ProcessEnv; let pristineEnv: NodeJS.ProcessEnv;
beforeAll(() => {
pristineEnv = process.env;
jest.spyOn(core, "getInput").mockImplementation((name, options) => {
return jest.requireActual("@actions/core").getInput(name, options);
});
});
beforeEach(() => { beforeEach(() => {
pristineEnv = { ...process.env }; jest.resetModules();
jest.clearAllMocks(); process.env = pristineEnv;
jest.mocked(core.getInput).mockImplementation(
(name: string, options?: { required?: boolean }) => {
const val =
process.env[`INPUT_${name.replace(/ /g, "_").toUpperCase()}`] ||
"";
if (options && options.required && !val) {
throw new Error(`Input required and not supplied: ${name}`);
}
return val.trim();
}
);
delete process.env[Events.Key]; delete process.env[Events.Key];
delete process.env[RefKey]; delete process.env[RefKey];
}); });
@@ -88,46 +47,74 @@ test("isGhes returns false when server url is github.com", () => {
}); });
test("isExactKeyMatch with undefined cache key returns false", () => { test("isExactKeyMatch with undefined cache key returns false", () => {
expect(actionUtils.isExactKeyMatch("linux-rust", undefined)).toBe(false); const key = "linux-rust";
const cacheKey = undefined;
expect(actionUtils.isExactKeyMatch(key, cacheKey)).toBe(false);
}); });
test("isExactKeyMatch with empty cache key returns false", () => { test("isExactKeyMatch with empty cache key returns false", () => {
expect(actionUtils.isExactKeyMatch("linux-rust", "")).toBe(false); const key = "linux-rust";
const cacheKey = "";
expect(actionUtils.isExactKeyMatch(key, cacheKey)).toBe(false);
}); });
test("isExactKeyMatch with different keys returns false", () => { test("isExactKeyMatch with different keys returns false", () => {
expect(actionUtils.isExactKeyMatch("linux-rust", "linux-")).toBe(false); const key = "linux-rust";
const cacheKey = "linux-";
expect(actionUtils.isExactKeyMatch(key, cacheKey)).toBe(false);
}); });
test("isExactKeyMatch with different key accents returns false", () => { test("isExactKeyMatch with different key accents returns false", () => {
expect(actionUtils.isExactKeyMatch("linux-áccent", "linux-accent")).toBe( const key = "linux-áccent";
false const cacheKey = "linux-accent";
);
expect(actionUtils.isExactKeyMatch(key, cacheKey)).toBe(false);
}); });
test("isExactKeyMatch with same key returns true", () => { test("isExactKeyMatch with same key returns true", () => {
expect(actionUtils.isExactKeyMatch("linux-rust", "linux-rust")).toBe(true); const key = "linux-rust";
const cacheKey = "linux-rust";
expect(actionUtils.isExactKeyMatch(key, cacheKey)).toBe(true);
}); });
test("isExactKeyMatch with same key and different casing returns true", () => { test("isExactKeyMatch with same key and different casing returns true", () => {
expect(actionUtils.isExactKeyMatch("linux-rust", "LINUX-RUST")).toBe(true); const key = "linux-rust";
const cacheKey = "LINUX-RUST";
expect(actionUtils.isExactKeyMatch(key, cacheKey)).toBe(true);
}); });
test("logWarning logs a message with a warning prefix", () => { test("logWarning logs a message with a warning prefix", () => {
const message = "A warning occurred."; const message = "A warning occurred.";
const infoMock = jest.spyOn(core, "info");
actionUtils.logWarning(message); actionUtils.logWarning(message);
expect(core.info).toHaveBeenCalledWith(`[warning]${message}`);
expect(infoMock).toHaveBeenCalledWith(`[warning]${message}`);
}); });
test("isValidEvent returns false for event that does not have a branch or tag", () => { test("isValidEvent returns false for event that does not have a branch or tag", () => {
process.env[Events.Key] = "foo"; const event = "foo";
expect(actionUtils.isValidEvent()).toBe(false); process.env[Events.Key] = event;
const isValidEvent = actionUtils.isValidEvent();
expect(isValidEvent).toBe(false);
}); });
test("isValidEvent returns true for event that has a ref", () => { test("isValidEvent returns true for event that has a ref", () => {
process.env[Events.Key] = Events.Push; const event = Events.Push;
process.env[Events.Key] = event;
process.env[RefKey] = "ref/heads/feature"; process.env[RefKey] = "ref/heads/feature";
expect(actionUtils.isValidEvent()).toBe(true);
const isValidEvent = actionUtils.isValidEvent();
expect(isValidEvent).toBe(true);
}); });
test("getInputAsArray returns empty array if not required and missing", () => { test("getInputAsArray returns empty array if not required and missing", () => {
@@ -137,7 +124,7 @@ test("getInputAsArray returns empty array if not required and missing", () => {
test("getInputAsArray throws error if required and missing", () => { test("getInputAsArray throws error if required and missing", () => {
expect(() => expect(() =>
actionUtils.getInputAsArray("foo", { required: true }) actionUtils.getInputAsArray("foo", { required: true })
).toThrow(); ).toThrowError();
}); });
test("getInputAsArray handles single line correctly", () => { test("getInputAsArray handles single line correctly", () => {
@@ -193,7 +180,7 @@ test("getInputAsInt returns undefined if input is invalid or NaN", () => {
test("getInputAsInt throws if required and value missing", () => { test("getInputAsInt throws if required and value missing", () => {
expect(() => expect(() =>
actionUtils.getInputAsInt("undefined", { required: true }) actionUtils.getInputAsInt("undefined", { required: true })
).toThrow(); ).toThrowError();
}); });
test("getInputAsBool returns false if input not set", () => { test("getInputAsBool returns false if input not set", () => {
@@ -213,65 +200,68 @@ test("getInputAsBool returns false if input is invalid or NaN", () => {
test("getInputAsBool throws if required and value missing", () => { test("getInputAsBool throws if required and value missing", () => {
expect(() => expect(() =>
actionUtils.getInputAsBool("undefined2", { required: true }) actionUtils.getInputAsBool("undefined2", { required: true })
).toThrow(); ).toThrowError();
}); });
test("isCacheFeatureAvailable for ac enabled", () => { test("isCacheFeatureAvailable for ac enabled", () => {
jest.mocked(cache.isFeatureAvailable).mockReturnValue(true); jest.spyOn(cache, "isFeatureAvailable").mockImplementation(() => true);
expect(actionUtils.isCacheFeatureAvailable()).toBe(true); expect(actionUtils.isCacheFeatureAvailable()).toBe(true);
}); });
test("isCacheFeatureAvailable for ac disabled on GHES", () => { test("isCacheFeatureAvailable for ac disabled on GHES", () => {
jest.mocked(cache.isFeatureAvailable).mockReturnValue(false); jest.spyOn(cache, "isFeatureAvailable").mockImplementation(() => false);
const message = `Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not. const message = `Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.
Otherwise please upgrade to GHES version >= 3.5 and If you are also using Github Connect, please unretire the actions/cache namespace before upgrade (see https://docs.github.com/en/[email protected]/admin/github-actions/managing-access-to-actions-from-githubcom/enabling-automatic-access-to-githubcom-actions-using-github-connect#automatic-retirement-of-namespaces-for-actions-accessed-on-githubcom)`; Otherwise please upgrade to GHES version >= 3.5 and If you are also using Github Connect, please unretire the actions/cache namespace before upgrade (see https://docs.github.com/en/[email protected]/admin/github-actions/managing-access-to-actions-from-githubcom/enabling-automatic-access-to-githubcom-actions-using-github-connect#automatic-retirement-of-namespaces-for-actions-accessed-on-githubcom)`;
const infoMock = jest.spyOn(core, "info");
try { try {
process.env["GITHUB_SERVER_URL"] = "http://example.com"; process.env["GITHUB_SERVER_URL"] = "http://example.com";
expect(actionUtils.isCacheFeatureAvailable()).toBe(false); expect(actionUtils.isCacheFeatureAvailable()).toBe(false);
expect(core.info).toHaveBeenCalledWith(`[warning]${message}`); expect(infoMock).toHaveBeenCalledWith(`[warning]${message}`);
} finally { } finally {
delete process.env["GITHUB_SERVER_URL"]; delete process.env["GITHUB_SERVER_URL"];
} }
}); });
test("isCacheFeatureAvailable for ac disabled on dotcom", () => { test("isCacheFeatureAvailable for ac disabled on dotcom", () => {
jest.mocked(cache.isFeatureAvailable).mockReturnValue(false); jest.spyOn(cache, "isFeatureAvailable").mockImplementation(() => false);
const message = const message =
"An internal error has occurred in cache backend. Please check https://www.githubstatus.com/ for any ongoing issue in actions."; "An internal error has occurred in cache backend. Please check https://www.githubstatus.com/ for any ongoing issue in actions.";
const infoMock = jest.spyOn(core, "info");
try { try {
process.env["GITHUB_SERVER_URL"] = "http://github.com"; process.env["GITHUB_SERVER_URL"] = "http://github.com";
expect(actionUtils.isCacheFeatureAvailable()).toBe(false); expect(actionUtils.isCacheFeatureAvailable()).toBe(false);
expect(core.info).toHaveBeenCalledWith(`[warning]${message}`); expect(infoMock).toHaveBeenCalledWith(`[warning]${message}`);
} finally { } finally {
delete process.env["GITHUB_SERVER_URL"]; delete process.env["GITHUB_SERVER_URL"];
} }
}); });
test("isGhes returns false when the GITHUB_SERVER_URL environment variable is not defined", () => { test("isGhes returns false when the GITHUB_SERVER_URL environment variable is not defined", async () => {
delete process.env["GITHUB_SERVER_URL"]; delete process.env["GITHUB_SERVER_URL"];
expect(actionUtils.isGhes()).toBeFalsy(); expect(actionUtils.isGhes()).toBeFalsy();
}); });
test("isGhes returns false when the GITHUB_SERVER_URL environment variable is set to github.com", () => { test("isGhes returns false when the GITHUB_SERVER_URL environment variable is set to github.com", async () => {
process.env["GITHUB_SERVER_URL"] = "https://github.com"; process.env["GITHUB_SERVER_URL"] = "https://github.com";
expect(actionUtils.isGhes()).toBeFalsy(); expect(actionUtils.isGhes()).toBeFalsy();
}); });
test("isGhes returns false when the GITHUB_SERVER_URL environment variable is set to a GitHub Enterprise Cloud-style URL", () => { test("isGhes returns false when the GITHUB_SERVER_URL environment variable is set to a GitHub Enterprise Cloud-style URL", async () => {
process.env["GITHUB_SERVER_URL"] = "https://contoso.ghe.com"; process.env["GITHUB_SERVER_URL"] = "https://contoso.ghe.com";
expect(actionUtils.isGhes()).toBeFalsy(); expect(actionUtils.isGhes()).toBeFalsy();
}); });
test("isGhes returns false when the GITHUB_SERVER_URL environment variable has a .localhost suffix", () => { test("isGhes returns false when the GITHUB_SERVER_URL environment variable has a .localhost suffix", async () => {
process.env["GITHUB_SERVER_URL"] = "https://mock-github.localhost"; process.env["GITHUB_SERVER_URL"] = "https://mock-github.localhost";
expect(actionUtils.isGhes()).toBeFalsy(); expect(actionUtils.isGhes()).toBeFalsy();
}); });
test("isGhes returns true when the GITHUB_SERVER_URL environment variable is set to some other URL", () => { test("isGhes returns true when the GITHUB_SERVER_URL environment variable is set to some other URL", async () => {
process.env["GITHUB_SERVER_URL"] = "https://src.onpremise.fabrikam.com"; process.env["GITHUB_SERVER_URL"] = "https://src.onpremise.fabrikam.com";
expect(actionUtils.isGhes()).toBeTruthy(); expect(actionUtils.isGhes()).toBeTruthy();
}); });
+197 -110
View File
@@ -1,66 +1,50 @@
import { afterEach, beforeEach, expect, jest, test } from "@jest/globals"; import * as cache from "@actions/cache";
import * as core from "@actions/core";
// Mock @actions/core import { Events, RefKey } from "../src/constants";
jest.unstable_mockModule("@actions/core", () => ({ import { restoreRun } from "../src/restoreImpl";
getInput: jest.fn((name: string, options?: { required?: boolean }) => { import * as actionUtils from "../src/utils/actionUtils";
const val = import * as testUtils from "../src/utils/testUtils";
process.env[`INPUT_${name.replace(/ /g, "_").toUpperCase()}`] || "";
if (options && options.required && !val) {
throw new Error(`Input required and not supplied: ${name}`);
}
return val.trim();
}),
setOutput: jest.fn(),
setFailed: jest.fn(),
info: jest.fn(),
warning: jest.fn(),
debug: jest.fn(),
error: jest.fn(),
saveState: jest.fn(),
getState: jest.fn(() => ""),
isDebug: jest.fn(() => false),
exportVariable: jest.fn(),
addPath: jest.fn(),
group: jest.fn((name: string, fn: () => Promise<unknown>) => fn()),
startGroup: jest.fn(),
endGroup: jest.fn()
}));
// Mock @actions/cache jest.mock("../src/utils/actionUtils");
jest.unstable_mockModule("@actions/cache", () => ({
restoreCache: jest.fn(),
saveCache: jest.fn(),
isFeatureAvailable: jest.fn(() => true),
ReserveCacheError: class ReserveCacheError extends Error {
constructor(message: string) {
super(message);
this.name = "ReserveCacheError";
}
}
}));
const core = await import("@actions/core"); beforeAll(() => {
const cache = await import("@actions/cache"); jest.spyOn(actionUtils, "isExactKeyMatch").mockImplementation(
const { Events, RefKey } = await import("../src/constants"); (key, cacheResult) => {
const { restoreRun } = await import("../src/restoreImpl"); const actualUtils = jest.requireActual("../src/utils/actionUtils");
const testUtils = await import("../src/utils/testUtils"); return actualUtils.isExactKeyMatch(key, cacheResult);
beforeEach(() => {
jest.clearAllMocks();
(core.getInput as jest.Mock).mockImplementation(
(name: string, options?: { required?: boolean }) => {
const val =
process.env[`INPUT_${name.replace(/ /g, "_").toUpperCase()}`] ||
"";
if (options && options.required && !val) {
throw new Error(`Input required and not supplied: ${name}`);
}
return val.trim();
} }
); );
(cache.isFeatureAvailable as jest.Mock).mockReturnValue(true);
jest.spyOn(actionUtils, "isValidEvent").mockImplementation(() => {
const actualUtils = jest.requireActual("../src/utils/actionUtils");
return actualUtils.isValidEvent();
});
jest.spyOn(actionUtils, "getInputAsArray").mockImplementation(
(name, options) => {
const actualUtils = jest.requireActual("../src/utils/actionUtils");
return actualUtils.getInputAsArray(name, options);
}
);
jest.spyOn(actionUtils, "getInputAsBool").mockImplementation(
(name, options) => {
const actualUtils = jest.requireActual("../src/utils/actionUtils");
return actualUtils.getInputAsBool(name, options);
}
);
});
beforeEach(() => {
jest.restoreAllMocks();
process.env[Events.Key] = Events.Push; process.env[Events.Key] = Events.Push;
process.env[RefKey] = "refs/heads/feature-branch"; process.env[RefKey] = "refs/heads/feature-branch";
jest.spyOn(actionUtils, "isGhes").mockImplementation(() => false);
jest.spyOn(actionUtils, "isCacheFeatureAvailable").mockImplementation(
() => true
);
}); });
afterEach(() => { afterEach(() => {
@@ -78,12 +62,19 @@ test("restore with no cache found", async () => {
enableCrossOsArchive: false enableCrossOsArchive: false
}); });
(cache.restoreCache as jest.Mock).mockResolvedValue(undefined); const infoMock = jest.spyOn(core, "info");
const failedMock = jest.spyOn(core, "setFailed");
const stateMock = jest.spyOn(core, "saveState");
const restoreCacheMock = jest
.spyOn(cache, "restoreCache")
.mockImplementationOnce(() => {
return Promise.resolve(undefined);
});
await restoreRun(); await restoreRun();
expect(cache.restoreCache).toHaveBeenCalledTimes(1); expect(restoreCacheMock).toHaveBeenCalledTimes(1);
expect(cache.restoreCache).toHaveBeenCalledWith( expect(restoreCacheMock).toHaveBeenCalledWith(
[path], [path],
key, key,
[], [],
@@ -93,10 +84,12 @@ test("restore with no cache found", async () => {
false false
); );
expect(core.saveState).toHaveBeenCalledWith("CACHE_KEY", key); expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
expect(core.saveState).toHaveBeenCalledTimes(1); expect(stateMock).toHaveBeenCalledTimes(1);
expect(core.setFailed).toHaveBeenCalledTimes(0);
expect(core.info).toHaveBeenCalledWith( expect(failedMock).toHaveBeenCalledTimes(0);
expect(infoMock).toHaveBeenCalledWith(
`Cache not found for input keys: ${key}` `Cache not found for input keys: ${key}`
); );
}); });
@@ -112,12 +105,19 @@ test("restore with restore keys and no cache found", async () => {
enableCrossOsArchive: false enableCrossOsArchive: false
}); });
(cache.restoreCache as jest.Mock).mockResolvedValue(undefined); const infoMock = jest.spyOn(core, "info");
const failedMock = jest.spyOn(core, "setFailed");
const stateMock = jest.spyOn(core, "saveState");
const restoreCacheMock = jest
.spyOn(cache, "restoreCache")
.mockImplementationOnce(() => {
return Promise.resolve(undefined);
});
await restoreRun(); await restoreRun();
expect(cache.restoreCache).toHaveBeenCalledTimes(1); expect(restoreCacheMock).toHaveBeenCalledTimes(1);
expect(cache.restoreCache).toHaveBeenCalledWith( expect(restoreCacheMock).toHaveBeenCalledWith(
[path], [path],
key, key,
[restoreKey], [restoreKey],
@@ -127,10 +127,12 @@ test("restore with restore keys and no cache found", async () => {
false false
); );
expect(core.saveState).toHaveBeenCalledWith("CACHE_KEY", key); expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
expect(core.saveState).toHaveBeenCalledTimes(1); expect(stateMock).toHaveBeenCalledTimes(1);
expect(core.setFailed).toHaveBeenCalledTimes(0);
expect(core.info).toHaveBeenCalledWith( expect(failedMock).toHaveBeenCalledTimes(0);
expect(infoMock).toHaveBeenCalledWith(
`Cache not found for input keys: ${key}, ${restoreKey}` `Cache not found for input keys: ${key}, ${restoreKey}`
); );
}); });
@@ -144,12 +146,20 @@ test("restore with cache found for key", async () => {
enableCrossOsArchive: false enableCrossOsArchive: false
}); });
(cache.restoreCache as jest.Mock).mockResolvedValue(key); const infoMock = jest.spyOn(core, "info");
const failedMock = jest.spyOn(core, "setFailed");
const stateMock = jest.spyOn(core, "saveState");
const setCacheHitOutputMock = jest.spyOn(core, "setOutput");
const restoreCacheMock = jest
.spyOn(cache, "restoreCache")
.mockImplementationOnce(() => {
return Promise.resolve(key);
});
await restoreRun(); await restoreRun();
expect(cache.restoreCache).toHaveBeenCalledTimes(1); expect(restoreCacheMock).toHaveBeenCalledTimes(1);
expect(cache.restoreCache).toHaveBeenCalledWith( expect(restoreCacheMock).toHaveBeenCalledWith(
[path], [path],
key, key,
[], [],
@@ -159,13 +169,15 @@ test("restore with cache found for key", async () => {
false false
); );
expect(core.saveState).toHaveBeenCalledWith("CACHE_KEY", key); expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
expect(core.saveState).toHaveBeenCalledWith("CACHE_RESULT", key); expect(stateMock).toHaveBeenCalledWith("CACHE_RESULT", key);
expect(core.saveState).toHaveBeenCalledTimes(2); expect(stateMock).toHaveBeenCalledTimes(2);
expect(core.setOutput).toHaveBeenCalledTimes(1);
expect(core.setOutput).toHaveBeenCalledWith("cache-hit", "true"); expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
expect(core.info).toHaveBeenCalledWith(`Cache restored from key: ${key}`); expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "true");
expect(core.setFailed).toHaveBeenCalledTimes(0);
expect(infoMock).toHaveBeenCalledWith(`Cache restored from key: ${key}`);
expect(failedMock).toHaveBeenCalledTimes(0);
}); });
test("restore with cache found for restore key", async () => { test("restore with cache found for restore key", async () => {
@@ -179,20 +191,39 @@ test("restore with cache found for restore key", async () => {
enableCrossOsArchive: false enableCrossOsArchive: false
}); });
(cache.restoreCache as jest.Mock).mockResolvedValue(restoreKey); const infoMock = jest.spyOn(core, "info");
const failedMock = jest.spyOn(core, "setFailed");
const stateMock = jest.spyOn(core, "saveState");
const setCacheHitOutputMock = jest.spyOn(core, "setOutput");
const restoreCacheMock = jest
.spyOn(cache, "restoreCache")
.mockImplementationOnce(() => {
return Promise.resolve(restoreKey);
});
await restoreRun(); await restoreRun();
expect(cache.restoreCache).toHaveBeenCalledTimes(1); expect(restoreCacheMock).toHaveBeenCalledTimes(1);
expect(core.saveState).toHaveBeenCalledWith("CACHE_KEY", key); expect(restoreCacheMock).toHaveBeenCalledWith(
expect(core.saveState).toHaveBeenCalledWith("CACHE_RESULT", restoreKey); [path],
expect(core.saveState).toHaveBeenCalledTimes(2); key,
expect(core.setOutput).toHaveBeenCalledTimes(1); [restoreKey],
expect(core.setOutput).toHaveBeenCalledWith("cache-hit", "false"); {
expect(core.info).toHaveBeenCalledWith( lookupOnly: false
},
false
);
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
expect(stateMock).toHaveBeenCalledWith("CACHE_RESULT", restoreKey);
expect(stateMock).toHaveBeenCalledTimes(2);
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "false");
expect(infoMock).toHaveBeenCalledWith(
`Cache restored from key: ${restoreKey}` `Cache restored from key: ${restoreKey}`
); );
expect(core.setFailed).toHaveBeenCalledTimes(0); expect(failedMock).toHaveBeenCalledTimes(0);
}); });
test("Fail restore when fail on cache miss is enabled and primary + restore keys not found", async () => { test("Fail restore when fail on cache miss is enabled and primary + restore keys not found", async () => {
@@ -206,17 +237,35 @@ test("Fail restore when fail on cache miss is enabled and primary + restore keys
failOnCacheMiss: true failOnCacheMiss: true
}); });
(cache.restoreCache as jest.Mock).mockResolvedValue(undefined); const failedMock = jest.spyOn(core, "setFailed");
const stateMock = jest.spyOn(core, "saveState");
const setCacheHitOutputMock = jest.spyOn(core, "setOutput");
const restoreCacheMock = jest
.spyOn(cache, "restoreCache")
.mockImplementationOnce(() => {
return Promise.resolve(undefined);
});
await restoreRun(); await restoreRun();
expect(cache.restoreCache).toHaveBeenCalledTimes(1); expect(restoreCacheMock).toHaveBeenCalledTimes(1);
expect(core.saveState).toHaveBeenCalledWith("CACHE_KEY", key); expect(restoreCacheMock).toHaveBeenCalledWith(
expect(core.setOutput).toHaveBeenCalledTimes(0); [path],
expect(core.setFailed).toHaveBeenCalledWith( key,
[restoreKey],
{
lookupOnly: false
},
false
);
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(0);
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}`
); );
expect(core.setFailed).toHaveBeenCalledTimes(1); expect(failedMock).toHaveBeenCalledTimes(1);
}); });
test("restore when fail on cache miss is enabled and primary key doesn't match restored key", async () => { test("restore when fail on cache miss is enabled and primary key doesn't match restored key", async () => {
@@ -230,20 +279,40 @@ test("restore when fail on cache miss is enabled and primary key doesn't match r
failOnCacheMiss: true failOnCacheMiss: true
}); });
(cache.restoreCache as jest.Mock).mockResolvedValue(restoreKey); const infoMock = jest.spyOn(core, "info");
const failedMock = jest.spyOn(core, "setFailed");
const stateMock = jest.spyOn(core, "saveState");
const setCacheHitOutputMock = jest.spyOn(core, "setOutput");
const restoreCacheMock = jest
.spyOn(cache, "restoreCache")
.mockImplementationOnce(() => {
return Promise.resolve(restoreKey);
});
await restoreRun(); await restoreRun();
expect(cache.restoreCache).toHaveBeenCalledTimes(1); expect(restoreCacheMock).toHaveBeenCalledTimes(1);
expect(core.saveState).toHaveBeenCalledWith("CACHE_KEY", key); expect(restoreCacheMock).toHaveBeenCalledWith(
expect(core.saveState).toHaveBeenCalledWith("CACHE_RESULT", restoreKey); [path],
expect(core.saveState).toHaveBeenCalledTimes(2); key,
expect(core.setOutput).toHaveBeenCalledTimes(1); [restoreKey],
expect(core.setOutput).toHaveBeenCalledWith("cache-hit", "false"); {
expect(core.info).toHaveBeenCalledWith( lookupOnly: false
},
false
);
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
expect(stateMock).toHaveBeenCalledWith("CACHE_RESULT", restoreKey);
expect(stateMock).toHaveBeenCalledTimes(2);
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "false");
expect(infoMock).toHaveBeenCalledWith(
`Cache restored from key: ${restoreKey}` `Cache restored from key: ${restoreKey}`
); );
expect(core.setFailed).toHaveBeenCalledTimes(0); expect(failedMock).toHaveBeenCalledTimes(0);
}); });
test("restore with fail on cache miss disabled and no cache found", async () => { test("restore with fail on cache miss disabled and no cache found", async () => {
@@ -257,15 +326,33 @@ test("restore with fail on cache miss disabled and no cache found", async () =>
failOnCacheMiss: false failOnCacheMiss: false
}); });
(cache.restoreCache as jest.Mock).mockResolvedValue(undefined); const infoMock = jest.spyOn(core, "info");
const failedMock = jest.spyOn(core, "setFailed");
const stateMock = jest.spyOn(core, "saveState");
const restoreCacheMock = jest
.spyOn(cache, "restoreCache")
.mockImplementationOnce(() => {
return Promise.resolve(undefined);
});
await restoreRun(); await restoreRun();
expect(cache.restoreCache).toHaveBeenCalledTimes(1); expect(restoreCacheMock).toHaveBeenCalledTimes(1);
expect(core.saveState).toHaveBeenCalledWith("CACHE_KEY", key); expect(restoreCacheMock).toHaveBeenCalledWith(
expect(core.saveState).toHaveBeenCalledTimes(1); [path],
expect(core.info).toHaveBeenCalledWith( key,
[restoreKey],
{
lookupOnly: false
},
false
);
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
expect(stateMock).toHaveBeenCalledTimes(1);
expect(infoMock).toHaveBeenCalledWith(
`Cache not found for input keys: ${key}, ${restoreKey}` `Cache not found for input keys: ${key}, ${restoreKey}`
); );
expect(core.setFailed).toHaveBeenCalledTimes(0); expect(failedMock).toHaveBeenCalledTimes(0);
}); });

Some files were not shown because too many files have changed in this diff Show More