mirror of
				https://github.com/actions/cache.git
				synced 2025-11-04 17:06:38 +07:00 
			
		
		
		
	Compare commits
	
		
			21 Commits
		
	
	
		
			phantsure/
			...
			phantsure/
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 4a39428162 | |||
| a88f332eb2 | |||
| 94407e72c8 | |||
| 48a27058cf | |||
| 2637f06e5f | |||
| 1f414295fe | |||
| af9067e3c7 | |||
| 5e66b6cac9 | |||
| 365406cb70 | |||
| d6217569d5 | |||
| 84e54000da | |||
| 4723a57e26 | |||
| d1507cccba | |||
| 3337563725 | |||
| 60c7666709 | |||
| b053f2b699 | |||
| 501277cfd7 | |||
| c1a5de879e | |||
| 9b0be58822 | |||
| 35f35f44e8 | |||
| ca1c035094 | 
							
								
								
									
										36
									
								
								.github/workflows/codeql.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										36
									
								
								.github/workflows/codeql.yml
									
									
									
									
										vendored
									
									
								
							@ -8,45 +8,39 @@ on:
 | 
			
		||||
 | 
			
		||||
jobs:
 | 
			
		||||
  CodeQL-Build:
 | 
			
		||||
 | 
			
		||||
    # CodeQL runs on ubuntu-latest and windows-latest
 | 
			
		||||
    # CodeQL runs on ubuntu-latest, windows-latest, and macos-latest
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
 | 
			
		||||
    permissions:
 | 
			
		||||
      # required for all workflows
 | 
			
		||||
      security-events: write
 | 
			
		||||
 | 
			
		||||
    steps:
 | 
			
		||||
    - name: Checkout repository
 | 
			
		||||
      uses: actions/checkout@v3
 | 
			
		||||
      with:
 | 
			
		||||
        # We must fetch at least the immediate parents so that if this is
 | 
			
		||||
        # a pull request then we can checkout the head.
 | 
			
		||||
        fetch-depth: 2
 | 
			
		||||
 | 
			
		||||
    # If this run was triggered by a pull request event, then checkout
 | 
			
		||||
    # the head of the pull request instead of the merge commit.
 | 
			
		||||
    - run: git checkout HEAD^2
 | 
			
		||||
      if: ${{ github.event_name == 'pull_request' }}
 | 
			
		||||
 | 
			
		||||
    # Initializes the CodeQL tools for scanning.
 | 
			
		||||
    - name: Initialize CodeQL
 | 
			
		||||
      uses: github/codeql-action/init@v1
 | 
			
		||||
      uses: github/codeql-action/init@v2
 | 
			
		||||
      # Override language selection by uncommenting this and choosing your languages
 | 
			
		||||
      # with:
 | 
			
		||||
      #   languages: go, javascript, csharp, python, cpp, java
 | 
			
		||||
      #   languages: go, javascript, csharp, python, cpp, java, ruby
 | 
			
		||||
 | 
			
		||||
    # Autobuild attempts to build any compiled languages  (C/C++, C#, or Java).
 | 
			
		||||
    # If this step fails, then you should remove it and run the build manually (see below)
 | 
			
		||||
    # 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).
 | 
			
		||||
    - name: Autobuild
 | 
			
		||||
      uses: github/codeql-action/autobuild@v1
 | 
			
		||||
      uses: github/codeql-action/autobuild@v2
 | 
			
		||||
 | 
			
		||||
    # ℹ️ Command-line programs to run using the OS shell.
 | 
			
		||||
    # 📚 https://git.io/JvXDl
 | 
			
		||||
    # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
 | 
			
		||||
 | 
			
		||||
    # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
 | 
			
		||||
    #    and modify them (or add more) to build your code if your project
 | 
			
		||||
    #    uses a compiled language
 | 
			
		||||
    # ✏️ If the Autobuild fails above, remove it and uncomment the following
 | 
			
		||||
    #    three lines and modify them (or add more) to build your code if your
 | 
			
		||||
    #    project uses a compiled language
 | 
			
		||||
 | 
			
		||||
    #- run: |
 | 
			
		||||
    #     make bootstrap
 | 
			
		||||
    #     make release
 | 
			
		||||
 | 
			
		||||
    - name: Perform CodeQL Analysis
 | 
			
		||||
      uses: github/codeql-action/analyze@v1
 | 
			
		||||
      uses: github/codeql-action/analyze@v2
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										2
									
								
								.licenses/npm/@actions/cache.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								.licenses/npm/@actions/cache.dep.yml
									
									
									
										generated
									
									
									
								
							@ -1,6 +1,6 @@
 | 
			
		||||
---
 | 
			
		||||
name: "@actions/cache"
 | 
			
		||||
version: 3.0.6
 | 
			
		||||
version: 3.1.2
 | 
			
		||||
type: npm
 | 
			
		||||
summary:
 | 
			
		||||
homepage:
 | 
			
		||||
 | 
			
		||||
@ -45,7 +45,7 @@ If you are using this inside a container, a POSIX-compliant `tar` needs to be in
 | 
			
		||||
* `restore-keys` - An ordered list of prefix-matched keys to use for restoring stale cache if no cache hit occurred for key.
 | 
			
		||||
 | 
			
		||||
#### Environment Variables
 | 
			
		||||
* `SEGMENT_DOWNLOAD_TIMEOUT_MINS` - Segment download timeout (in minutes, default `60`) to abort download of the segment if not completed in the defined number of minutes. [Read more](https://github.com/actions/cache/blob/main/workarounds.md#cache-segment-restore-timeout)
 | 
			
		||||
* `SEGMENT_DOWNLOAD_TIMEOUT_MINS` - Segment download timeout (in minutes, default `60`) to abort download of the segment if not completed in the defined number of minutes. [Read more](https://github.com/actions/cache/blob/main/tips-and-workarounds.md#cache-segment-restore-timeout)
 | 
			
		||||
 | 
			
		||||
### Outputs
 | 
			
		||||
 | 
			
		||||
@ -121,6 +121,7 @@ See [Examples](examples.md) for a list of `actions/cache` implementations for us
 | 
			
		||||
- [Swift, Objective-C - Carthage](./examples.md#swift-objective-c---carthage)
 | 
			
		||||
- [Swift, Objective-C - CocoaPods](./examples.md#swift-objective-c---cocoapods)
 | 
			
		||||
- [Swift - Swift Package Manager](./examples.md#swift---swift-package-manager)
 | 
			
		||||
- [Swift - Mint](./examples.md#swift---mint)
 | 
			
		||||
 | 
			
		||||
## Creating a cache key
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -55,3 +55,11 @@
 | 
			
		||||
 | 
			
		||||
### 3.2.0
 | 
			
		||||
- Released the two new actions - [restore](restore/action.yml) and [save](save/action.yml) for granular control on cache
 | 
			
		||||
 | 
			
		||||
### 3.2.1
 | 
			
		||||
- Update `@actions/cache` on windows to use gnu tar and zstd by default and fallback to bsdtar and zstd if gnu tar is not available. ([issue](https://github.com/actions/cache/issues/984))
 | 
			
		||||
- Added support for fallback to gzip to restore old caches on windows.
 | 
			
		||||
- Added logs for cache version in case of a cache miss.
 | 
			
		||||
 | 
			
		||||
### 3.2.2
 | 
			
		||||
- Reverted the changes made in 3.2.1 to use gnu tar and zstd by default on windows.
 | 
			
		||||
@ -174,6 +174,26 @@ test("getInputAsInt throws if required and value missing", () => {
 | 
			
		||||
    ).toThrowError();
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
test("getInputAsBool returns false if input not set", () => {
 | 
			
		||||
    expect(actionUtils.getInputAsBool("undefined")).toBe(false);
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
test("getInputAsBool returns value if input is valid", () => {
 | 
			
		||||
    testUtils.setInput("foo", "true");
 | 
			
		||||
    expect(actionUtils.getInputAsBool("foo")).toBe(true);
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
test("getInputAsBool returns false if input is invalid or NaN", () => {
 | 
			
		||||
    testUtils.setInput("foo", "bar");
 | 
			
		||||
    expect(actionUtils.getInputAsBool("foo")).toBe(false);
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
test("getInputAsBool throws if required and value missing", () => {
 | 
			
		||||
    expect(() =>
 | 
			
		||||
        actionUtils.getInputAsBool("undefined2", { required: true })
 | 
			
		||||
    ).toThrowError();
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
test("isCacheFeatureAvailable for ac enabled", () => {
 | 
			
		||||
    jest.spyOn(cache, "isFeatureAvailable").mockImplementation(() => true);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -27,9 +27,17 @@ beforeAll(() => {
 | 
			
		||||
            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[RefKey] = "refs/heads/feature-branch";
 | 
			
		||||
 | 
			
		||||
@ -50,7 +58,8 @@ test("restore with no cache found", async () => {
 | 
			
		||||
    const key = "node-test";
 | 
			
		||||
    testUtils.setInputs({
 | 
			
		||||
        path: path,
 | 
			
		||||
        key
 | 
			
		||||
        key,
 | 
			
		||||
        enableCrossOsArchive: false
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    const infoMock = jest.spyOn(core, "info");
 | 
			
		||||
@ -65,7 +74,7 @@ test("restore with no cache found", async () => {
 | 
			
		||||
    await run();
 | 
			
		||||
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledTimes(1);
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledWith([path], key, []);
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [], {}, false);
 | 
			
		||||
 | 
			
		||||
    expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
 | 
			
		||||
    expect(stateMock).toHaveBeenCalledTimes(1);
 | 
			
		||||
@ -84,7 +93,8 @@ test("restore with restore keys and no cache found", async () => {
 | 
			
		||||
    testUtils.setInputs({
 | 
			
		||||
        path: path,
 | 
			
		||||
        key,
 | 
			
		||||
        restoreKeys: [restoreKey]
 | 
			
		||||
        restoreKeys: [restoreKey],
 | 
			
		||||
        enableCrossOsArchive: false
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    const infoMock = jest.spyOn(core, "info");
 | 
			
		||||
@ -99,7 +109,13 @@ test("restore with restore keys and no cache found", async () => {
 | 
			
		||||
    await run();
 | 
			
		||||
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledTimes(1);
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [restoreKey]);
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledWith(
 | 
			
		||||
        [path],
 | 
			
		||||
        key,
 | 
			
		||||
        [restoreKey],
 | 
			
		||||
        {},
 | 
			
		||||
        false
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
 | 
			
		||||
    expect(stateMock).toHaveBeenCalledTimes(1);
 | 
			
		||||
@ -116,7 +132,8 @@ test("restore with cache found for key", async () => {
 | 
			
		||||
    const key = "node-test";
 | 
			
		||||
    testUtils.setInputs({
 | 
			
		||||
        path: path,
 | 
			
		||||
        key
 | 
			
		||||
        key,
 | 
			
		||||
        enableCrossOsArchive: false
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    const infoMock = jest.spyOn(core, "info");
 | 
			
		||||
@ -132,7 +149,7 @@ test("restore with cache found for key", async () => {
 | 
			
		||||
    await run();
 | 
			
		||||
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledTimes(1);
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledWith([path], key, []);
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [], {}, false);
 | 
			
		||||
 | 
			
		||||
    expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
 | 
			
		||||
    expect(stateMock).toHaveBeenCalledWith("CACHE_RESULT", key);
 | 
			
		||||
@ -152,7 +169,8 @@ test("restore with cache found for restore key", async () => {
 | 
			
		||||
    testUtils.setInputs({
 | 
			
		||||
        path: path,
 | 
			
		||||
        key,
 | 
			
		||||
        restoreKeys: [restoreKey]
 | 
			
		||||
        restoreKeys: [restoreKey],
 | 
			
		||||
        enableCrossOsArchive: false
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    const infoMock = jest.spyOn(core, "info");
 | 
			
		||||
@ -168,7 +186,13 @@ test("restore with cache found for restore key", async () => {
 | 
			
		||||
    await run();
 | 
			
		||||
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledTimes(1);
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [restoreKey]);
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledWith(
 | 
			
		||||
        [path],
 | 
			
		||||
        key,
 | 
			
		||||
        [restoreKey],
 | 
			
		||||
        {},
 | 
			
		||||
        false
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
 | 
			
		||||
    expect(stateMock).toHaveBeenCalledWith("CACHE_RESULT", restoreKey);
 | 
			
		||||
 | 
			
		||||
@ -28,9 +28,17 @@ beforeAll(() => {
 | 
			
		||||
            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[RefKey] = "refs/heads/feature-branch";
 | 
			
		||||
 | 
			
		||||
@ -97,7 +105,8 @@ test("restore on GHES with AC available ", async () => {
 | 
			
		||||
    const key = "node-test";
 | 
			
		||||
    testUtils.setInputs({
 | 
			
		||||
        path: path,
 | 
			
		||||
        key
 | 
			
		||||
        key,
 | 
			
		||||
        enableCrossOsArchive: false
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    const infoMock = jest.spyOn(core, "info");
 | 
			
		||||
@ -113,7 +122,7 @@ test("restore on GHES with AC available ", async () => {
 | 
			
		||||
    await run(new StateProvider());
 | 
			
		||||
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledTimes(1);
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledWith([path], key, []);
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [], {}, false);
 | 
			
		||||
 | 
			
		||||
    expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
 | 
			
		||||
    expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
 | 
			
		||||
@ -152,13 +161,20 @@ test("restore with too many keys should fail", async () => {
 | 
			
		||||
    testUtils.setInputs({
 | 
			
		||||
        path: path,
 | 
			
		||||
        key,
 | 
			
		||||
        restoreKeys
 | 
			
		||||
        restoreKeys,
 | 
			
		||||
        enableCrossOsArchive: false
 | 
			
		||||
    });
 | 
			
		||||
    const failedMock = jest.spyOn(core, "setFailed");
 | 
			
		||||
    const restoreCacheMock = jest.spyOn(cache, "restoreCache");
 | 
			
		||||
    await run(new StateProvider());
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledTimes(1);
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledWith([path], key, restoreKeys);
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledWith(
 | 
			
		||||
        [path],
 | 
			
		||||
        key,
 | 
			
		||||
        restoreKeys,
 | 
			
		||||
        {},
 | 
			
		||||
        false
 | 
			
		||||
    );
 | 
			
		||||
    expect(failedMock).toHaveBeenCalledWith(
 | 
			
		||||
        `Key Validation Error: Keys are limited to a maximum of 10.`
 | 
			
		||||
    );
 | 
			
		||||
@ -169,13 +185,14 @@ test("restore with large key should fail", async () => {
 | 
			
		||||
    const key = "foo".repeat(512); // Over the 512 character limit
 | 
			
		||||
    testUtils.setInputs({
 | 
			
		||||
        path: path,
 | 
			
		||||
        key
 | 
			
		||||
        key,
 | 
			
		||||
        enableCrossOsArchive: false
 | 
			
		||||
    });
 | 
			
		||||
    const failedMock = jest.spyOn(core, "setFailed");
 | 
			
		||||
    const restoreCacheMock = jest.spyOn(cache, "restoreCache");
 | 
			
		||||
    await run(new StateProvider());
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledTimes(1);
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledWith([path], key, []);
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [], {}, false);
 | 
			
		||||
    expect(failedMock).toHaveBeenCalledWith(
 | 
			
		||||
        `Key Validation Error: ${key} cannot be larger than 512 characters.`
 | 
			
		||||
    );
 | 
			
		||||
@ -186,13 +203,14 @@ test("restore with invalid key should fail", async () => {
 | 
			
		||||
    const key = "comma,comma";
 | 
			
		||||
    testUtils.setInputs({
 | 
			
		||||
        path: path,
 | 
			
		||||
        key
 | 
			
		||||
        key,
 | 
			
		||||
        enableCrossOsArchive: false
 | 
			
		||||
    });
 | 
			
		||||
    const failedMock = jest.spyOn(core, "setFailed");
 | 
			
		||||
    const restoreCacheMock = jest.spyOn(cache, "restoreCache");
 | 
			
		||||
    await run(new StateProvider());
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledTimes(1);
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledWith([path], key, []);
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [], {}, false);
 | 
			
		||||
    expect(failedMock).toHaveBeenCalledWith(
 | 
			
		||||
        `Key Validation Error: ${key} cannot contain commas.`
 | 
			
		||||
    );
 | 
			
		||||
@ -203,7 +221,8 @@ test("restore with no cache found", async () => {
 | 
			
		||||
    const key = "node-test";
 | 
			
		||||
    testUtils.setInputs({
 | 
			
		||||
        path: path,
 | 
			
		||||
        key
 | 
			
		||||
        key,
 | 
			
		||||
        enableCrossOsArchive: false
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    const infoMock = jest.spyOn(core, "info");
 | 
			
		||||
@ -218,7 +237,7 @@ test("restore with no cache found", async () => {
 | 
			
		||||
    await run(new StateProvider());
 | 
			
		||||
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledTimes(1);
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledWith([path], key, []);
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [], {}, false);
 | 
			
		||||
 | 
			
		||||
    expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
 | 
			
		||||
    expect(failedMock).toHaveBeenCalledTimes(0);
 | 
			
		||||
@ -235,7 +254,8 @@ test("restore with restore keys and no cache found", async () => {
 | 
			
		||||
    testUtils.setInputs({
 | 
			
		||||
        path: path,
 | 
			
		||||
        key,
 | 
			
		||||
        restoreKeys: [restoreKey]
 | 
			
		||||
        restoreKeys: [restoreKey],
 | 
			
		||||
        enableCrossOsArchive: false
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    const infoMock = jest.spyOn(core, "info");
 | 
			
		||||
@ -250,7 +270,13 @@ test("restore with restore keys and no cache found", async () => {
 | 
			
		||||
    await run(new StateProvider());
 | 
			
		||||
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledTimes(1);
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [restoreKey]);
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledWith(
 | 
			
		||||
        [path],
 | 
			
		||||
        key,
 | 
			
		||||
        [restoreKey],
 | 
			
		||||
        {},
 | 
			
		||||
        false
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
 | 
			
		||||
    expect(failedMock).toHaveBeenCalledTimes(0);
 | 
			
		||||
@ -265,7 +291,8 @@ test("restore with cache found for key", async () => {
 | 
			
		||||
    const key = "node-test";
 | 
			
		||||
    testUtils.setInputs({
 | 
			
		||||
        path: path,
 | 
			
		||||
        key
 | 
			
		||||
        key,
 | 
			
		||||
        enableCrossOsArchive: false
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    const infoMock = jest.spyOn(core, "info");
 | 
			
		||||
@ -281,7 +308,7 @@ test("restore with cache found for key", async () => {
 | 
			
		||||
    await run(new StateProvider());
 | 
			
		||||
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledTimes(1);
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledWith([path], key, []);
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [], {}, false);
 | 
			
		||||
 | 
			
		||||
    expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
 | 
			
		||||
    expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
 | 
			
		||||
@ -298,7 +325,8 @@ test("restore with cache found for restore key", async () => {
 | 
			
		||||
    testUtils.setInputs({
 | 
			
		||||
        path: path,
 | 
			
		||||
        key,
 | 
			
		||||
        restoreKeys: [restoreKey]
 | 
			
		||||
        restoreKeys: [restoreKey],
 | 
			
		||||
        enableCrossOsArchive: false
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    const infoMock = jest.spyOn(core, "info");
 | 
			
		||||
@ -314,7 +342,13 @@ test("restore with cache found for restore key", async () => {
 | 
			
		||||
    await run(new StateProvider());
 | 
			
		||||
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledTimes(1);
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [restoreKey]);
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledWith(
 | 
			
		||||
        [path],
 | 
			
		||||
        key,
 | 
			
		||||
        [restoreKey],
 | 
			
		||||
        {},
 | 
			
		||||
        false
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
 | 
			
		||||
    expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
 | 
			
		||||
 | 
			
		||||
@ -27,9 +27,18 @@ beforeAll(() => {
 | 
			
		||||
            return actualUtils.getInputAsArray(name, options);
 | 
			
		||||
        }
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    jest.spyOn(actionUtils, "getInputAsBool").mockImplementation(
 | 
			
		||||
        (name, options) => {
 | 
			
		||||
            return jest
 | 
			
		||||
                .requireActual("../src/utils/actionUtils")
 | 
			
		||||
                .getInputAsBool(name, options);
 | 
			
		||||
        }
 | 
			
		||||
    );
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
beforeEach(() => {
 | 
			
		||||
    jest.restoreAllMocks();
 | 
			
		||||
    process.env[Events.Key] = Events.Push;
 | 
			
		||||
    process.env[RefKey] = "refs/heads/feature-branch";
 | 
			
		||||
 | 
			
		||||
@ -50,7 +59,8 @@ test("restore with no cache found", async () => {
 | 
			
		||||
    const key = "node-test";
 | 
			
		||||
    testUtils.setInputs({
 | 
			
		||||
        path: path,
 | 
			
		||||
        key
 | 
			
		||||
        key,
 | 
			
		||||
        enableCrossOsArchive: false
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    const infoMock = jest.spyOn(core, "info");
 | 
			
		||||
@ -65,7 +75,7 @@ test("restore with no cache found", async () => {
 | 
			
		||||
    await run();
 | 
			
		||||
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledTimes(1);
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledWith([path], key, []);
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [], {}, false);
 | 
			
		||||
 | 
			
		||||
    expect(outputMock).toHaveBeenCalledWith("cache-primary-key", key);
 | 
			
		||||
    expect(outputMock).toHaveBeenCalledTimes(1);
 | 
			
		||||
@ -83,7 +93,8 @@ test("restore with restore keys and no cache found", async () => {
 | 
			
		||||
    testUtils.setInputs({
 | 
			
		||||
        path: path,
 | 
			
		||||
        key,
 | 
			
		||||
        restoreKeys: [restoreKey]
 | 
			
		||||
        restoreKeys: [restoreKey],
 | 
			
		||||
        enableCrossOsArchive: false
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    const infoMock = jest.spyOn(core, "info");
 | 
			
		||||
@ -98,7 +109,13 @@ test("restore with restore keys and no cache found", async () => {
 | 
			
		||||
    await run();
 | 
			
		||||
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledTimes(1);
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [restoreKey]);
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledWith(
 | 
			
		||||
        [path],
 | 
			
		||||
        key,
 | 
			
		||||
        [restoreKey],
 | 
			
		||||
        {},
 | 
			
		||||
        false
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    expect(outputMock).toHaveBeenCalledWith("cache-primary-key", key);
 | 
			
		||||
    expect(failedMock).toHaveBeenCalledTimes(0);
 | 
			
		||||
@ -113,7 +130,8 @@ test("restore with cache found for key", async () => {
 | 
			
		||||
    const key = "node-test";
 | 
			
		||||
    testUtils.setInputs({
 | 
			
		||||
        path: path,
 | 
			
		||||
        key
 | 
			
		||||
        key,
 | 
			
		||||
        enableCrossOsArchive: false
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    const infoMock = jest.spyOn(core, "info");
 | 
			
		||||
@ -128,7 +146,7 @@ test("restore with cache found for key", async () => {
 | 
			
		||||
    await run();
 | 
			
		||||
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledTimes(1);
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledWith([path], key, []);
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [], {}, false);
 | 
			
		||||
 | 
			
		||||
    expect(outputMock).toHaveBeenCalledWith("cache-primary-key", key);
 | 
			
		||||
    expect(outputMock).toHaveBeenCalledWith("cache-hit", "true");
 | 
			
		||||
@ -147,7 +165,8 @@ test("restore with cache found for restore key", async () => {
 | 
			
		||||
    testUtils.setInputs({
 | 
			
		||||
        path: path,
 | 
			
		||||
        key,
 | 
			
		||||
        restoreKeys: [restoreKey]
 | 
			
		||||
        restoreKeys: [restoreKey],
 | 
			
		||||
        enableCrossOsArchive: false
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    const infoMock = jest.spyOn(core, "info");
 | 
			
		||||
@ -162,7 +181,13 @@ test("restore with cache found for restore key", async () => {
 | 
			
		||||
    await run();
 | 
			
		||||
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledTimes(1);
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [restoreKey]);
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledWith(
 | 
			
		||||
        [path],
 | 
			
		||||
        key,
 | 
			
		||||
        [restoreKey],
 | 
			
		||||
        {},
 | 
			
		||||
        false
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    expect(outputMock).toHaveBeenCalledWith("cache-primary-key", key);
 | 
			
		||||
    expect(outputMock).toHaveBeenCalledWith("cache-hit", "false");
 | 
			
		||||
 | 
			
		||||
@ -35,6 +35,14 @@ beforeAll(() => {
 | 
			
		||||
        }
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    jest.spyOn(actionUtils, "getInputAsBool").mockImplementation(
 | 
			
		||||
        (name, options) => {
 | 
			
		||||
            return jest
 | 
			
		||||
                .requireActual("../src/utils/actionUtils")
 | 
			
		||||
                .getInputAsBool(name, options);
 | 
			
		||||
        }
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    jest.spyOn(actionUtils, "isExactKeyMatch").mockImplementation(
 | 
			
		||||
        (key, cacheResult) => {
 | 
			
		||||
            return jest
 | 
			
		||||
@ -95,9 +103,14 @@ test("save with valid inputs uploads a cache", async () => {
 | 
			
		||||
    await run();
 | 
			
		||||
 | 
			
		||||
    expect(saveCacheMock).toHaveBeenCalledTimes(1);
 | 
			
		||||
    expect(saveCacheMock).toHaveBeenCalledWith([inputPath], primaryKey, {
 | 
			
		||||
    expect(saveCacheMock).toHaveBeenCalledWith(
 | 
			
		||||
        [inputPath],
 | 
			
		||||
        primaryKey,
 | 
			
		||||
        {
 | 
			
		||||
            uploadChunkSize: 4000000
 | 
			
		||||
    });
 | 
			
		||||
        },
 | 
			
		||||
        false
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    expect(failedMock).toHaveBeenCalledTimes(0);
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
@ -32,6 +32,14 @@ beforeAll(() => {
 | 
			
		||||
        }
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    jest.spyOn(actionUtils, "getInputAsBool").mockImplementation(
 | 
			
		||||
        (name, options) => {
 | 
			
		||||
            return jest
 | 
			
		||||
                .requireActual("../src/utils/actionUtils")
 | 
			
		||||
                .getInputAsBool(name, options);
 | 
			
		||||
        }
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    jest.spyOn(actionUtils, "isExactKeyMatch").mockImplementation(
 | 
			
		||||
        (key, cacheResult) => {
 | 
			
		||||
            return jest
 | 
			
		||||
@ -47,6 +55,7 @@ beforeAll(() => {
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
beforeEach(() => {
 | 
			
		||||
    jest.restoreAllMocks();
 | 
			
		||||
    process.env[Events.Key] = Events.Push;
 | 
			
		||||
    process.env[RefKey] = "refs/heads/feature-branch";
 | 
			
		||||
 | 
			
		||||
@ -155,9 +164,14 @@ test("save on GHES with AC available", async () => {
 | 
			
		||||
    await run(new StateProvider());
 | 
			
		||||
 | 
			
		||||
    expect(saveCacheMock).toHaveBeenCalledTimes(1);
 | 
			
		||||
    expect(saveCacheMock).toHaveBeenCalledWith([inputPath], primaryKey, {
 | 
			
		||||
    expect(saveCacheMock).toHaveBeenCalledWith(
 | 
			
		||||
        [inputPath],
 | 
			
		||||
        primaryKey,
 | 
			
		||||
        {
 | 
			
		||||
            uploadChunkSize: 4000000
 | 
			
		||||
    });
 | 
			
		||||
        },
 | 
			
		||||
        false
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    expect(failedMock).toHaveBeenCalledTimes(0);
 | 
			
		||||
});
 | 
			
		||||
@ -251,7 +265,8 @@ test("save with large cache outputs warning", async () => {
 | 
			
		||||
    expect(saveCacheMock).toHaveBeenCalledWith(
 | 
			
		||||
        [inputPath],
 | 
			
		||||
        primaryKey,
 | 
			
		||||
        expect.anything()
 | 
			
		||||
        expect.anything(),
 | 
			
		||||
        false
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    expect(logWarningMock).toHaveBeenCalledTimes(1);
 | 
			
		||||
@ -297,7 +312,8 @@ test("save with reserve cache failure outputs warning", async () => {
 | 
			
		||||
    expect(saveCacheMock).toHaveBeenCalledWith(
 | 
			
		||||
        [inputPath],
 | 
			
		||||
        primaryKey,
 | 
			
		||||
        expect.anything()
 | 
			
		||||
        expect.anything(),
 | 
			
		||||
        false
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    expect(logWarningMock).toHaveBeenCalledWith(
 | 
			
		||||
@ -339,7 +355,8 @@ test("save with server error outputs warning", async () => {
 | 
			
		||||
    expect(saveCacheMock).toHaveBeenCalledWith(
 | 
			
		||||
        [inputPath],
 | 
			
		||||
        primaryKey,
 | 
			
		||||
        expect.anything()
 | 
			
		||||
        expect.anything(),
 | 
			
		||||
        false
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    expect(logWarningMock).toHaveBeenCalledTimes(1);
 | 
			
		||||
@ -378,9 +395,14 @@ test("save with valid inputs uploads a cache", async () => {
 | 
			
		||||
    await run(new StateProvider());
 | 
			
		||||
 | 
			
		||||
    expect(saveCacheMock).toHaveBeenCalledTimes(1);
 | 
			
		||||
    expect(saveCacheMock).toHaveBeenCalledWith([inputPath], primaryKey, {
 | 
			
		||||
    expect(saveCacheMock).toHaveBeenCalledWith(
 | 
			
		||||
        [inputPath],
 | 
			
		||||
        primaryKey,
 | 
			
		||||
        {
 | 
			
		||||
            uploadChunkSize: 4000000
 | 
			
		||||
    });
 | 
			
		||||
        },
 | 
			
		||||
        false
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    expect(failedMock).toHaveBeenCalledTimes(0);
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
@ -35,6 +35,14 @@ beforeAll(() => {
 | 
			
		||||
        }
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    jest.spyOn(actionUtils, "getInputAsBool").mockImplementation(
 | 
			
		||||
        (name, options) => {
 | 
			
		||||
            return jest
 | 
			
		||||
                .requireActual("../src/utils/actionUtils")
 | 
			
		||||
                .getInputAsBool(name, options);
 | 
			
		||||
        }
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    jest.spyOn(actionUtils, "isExactKeyMatch").mockImplementation(
 | 
			
		||||
        (key, cacheResult) => {
 | 
			
		||||
            return jest
 | 
			
		||||
@ -85,9 +93,14 @@ test("save with valid inputs uploads a cache", async () => {
 | 
			
		||||
    await run();
 | 
			
		||||
 | 
			
		||||
    expect(saveCacheMock).toHaveBeenCalledTimes(1);
 | 
			
		||||
    expect(saveCacheMock).toHaveBeenCalledWith([inputPath], primaryKey, {
 | 
			
		||||
    expect(saveCacheMock).toHaveBeenCalledWith(
 | 
			
		||||
        [inputPath],
 | 
			
		||||
        primaryKey,
 | 
			
		||||
        {
 | 
			
		||||
            uploadChunkSize: 4000000
 | 
			
		||||
    });
 | 
			
		||||
        },
 | 
			
		||||
        false
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    expect(failedMock).toHaveBeenCalledTimes(0);
 | 
			
		||||
});
 | 
			
		||||
@ -112,9 +125,14 @@ test("save failing logs the warning message", async () => {
 | 
			
		||||
    await run();
 | 
			
		||||
 | 
			
		||||
    expect(saveCacheMock).toHaveBeenCalledTimes(1);
 | 
			
		||||
    expect(saveCacheMock).toHaveBeenCalledWith([inputPath], primaryKey, {
 | 
			
		||||
    expect(saveCacheMock).toHaveBeenCalledWith(
 | 
			
		||||
        [inputPath],
 | 
			
		||||
        primaryKey,
 | 
			
		||||
        {
 | 
			
		||||
            uploadChunkSize: 4000000
 | 
			
		||||
    });
 | 
			
		||||
        },
 | 
			
		||||
        false
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    expect(warningMock).toHaveBeenCalledTimes(1);
 | 
			
		||||
    expect(warningMock).toHaveBeenCalledWith("Cache save failed.");
 | 
			
		||||
 | 
			
		||||
@ -14,6 +14,10 @@ inputs:
 | 
			
		||||
  upload-chunk-size:
 | 
			
		||||
    description: 'The chunk size used to split up large files during upload, in bytes'
 | 
			
		||||
    required: false
 | 
			
		||||
  enableCrossOsArchive:
 | 
			
		||||
    description: 'An optional boolean when enabled, allows windows runners to save or restore caches that can be restored or saved respectively on other platforms'
 | 
			
		||||
    default: 'false'
 | 
			
		||||
    required: false
 | 
			
		||||
outputs:
 | 
			
		||||
  cache-hit:
 | 
			
		||||
    description: 'A boolean value to indicate an exact match was found for the primary key'
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										331
									
								
								dist/restore-only/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										331
									
								
								dist/restore-only/index.js
									
									
									
									
										vendored
									
									
								
							@ -1177,10 +1177,6 @@ function getVersion(app) {
 | 
			
		||||
// Use zstandard if possible to maximize cache performance
 | 
			
		||||
function getCompressionMethod() {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        if (process.platform === 'win32' && !(yield isGnuTarInstalled())) {
 | 
			
		||||
            // Disable zstd due to bug https://github.com/actions/cache/issues/301
 | 
			
		||||
            return constants_1.CompressionMethod.Gzip;
 | 
			
		||||
        }
 | 
			
		||||
        const versionOutput = yield getVersion('zstd');
 | 
			
		||||
        const version = semver.clean(versionOutput);
 | 
			
		||||
        if (!versionOutput.toLowerCase().includes('zstd command line interface')) {
 | 
			
		||||
@ -1204,13 +1200,16 @@ function getCacheFileName(compressionMethod) {
 | 
			
		||||
        : constants_1.CacheFilename.Zstd;
 | 
			
		||||
}
 | 
			
		||||
exports.getCacheFileName = getCacheFileName;
 | 
			
		||||
function isGnuTarInstalled() {
 | 
			
		||||
function getGnuTarPathOnWindows() {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        if (fs.existsSync(constants_1.GnuTarPathOnWindows)) {
 | 
			
		||||
            return constants_1.GnuTarPathOnWindows;
 | 
			
		||||
        }
 | 
			
		||||
        const versionOutput = yield getVersion('tar');
 | 
			
		||||
        return versionOutput.toLowerCase().includes('gnu tar');
 | 
			
		||||
        return versionOutput.toLowerCase().includes('gnu tar') ? io.which('tar') : '';
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
exports.isGnuTarInstalled = isGnuTarInstalled;
 | 
			
		||||
exports.getGnuTarPathOnWindows = getGnuTarPathOnWindows;
 | 
			
		||||
function assertDefined(name, value) {
 | 
			
		||||
    if (value === undefined) {
 | 
			
		||||
        throw Error(`Expected ${name} but value was undefiend`);
 | 
			
		||||
@ -3384,7 +3383,6 @@ const crypto = __importStar(__webpack_require__(417));
 | 
			
		||||
const fs = __importStar(__webpack_require__(747));
 | 
			
		||||
const url_1 = __webpack_require__(414);
 | 
			
		||||
const utils = __importStar(__webpack_require__(15));
 | 
			
		||||
const constants_1 = __webpack_require__(931);
 | 
			
		||||
const downloadUtils_1 = __webpack_require__(251);
 | 
			
		||||
const options_1 = __webpack_require__(538);
 | 
			
		||||
const requestUtils_1 = __webpack_require__(899);
 | 
			
		||||
@ -3414,10 +3412,17 @@ function createHttpClient() {
 | 
			
		||||
    const bearerCredentialHandler = new auth_1.BearerCredentialHandler(token);
 | 
			
		||||
    return new http_client_1.HttpClient('actions/cache', [bearerCredentialHandler], getRequestOptions());
 | 
			
		||||
}
 | 
			
		||||
function getCacheVersion(paths, compressionMethod) {
 | 
			
		||||
    const components = paths.concat(!compressionMethod || compressionMethod === constants_1.CompressionMethod.Gzip
 | 
			
		||||
        ? []
 | 
			
		||||
        : [compressionMethod]);
 | 
			
		||||
function getCacheVersion(paths, compressionMethod, enableCrossOsArchive = false) {
 | 
			
		||||
    const components = paths;
 | 
			
		||||
    // Add compression method to cache version to restore
 | 
			
		||||
    // compressed cache as per compression method
 | 
			
		||||
    if (compressionMethod) {
 | 
			
		||||
        components.push(compressionMethod);
 | 
			
		||||
    }
 | 
			
		||||
    // Only check for windows platforms if enableCrossOsArchive is false
 | 
			
		||||
    if (process.platform === 'win32' && !enableCrossOsArchive) {
 | 
			
		||||
        components.push('windows-only');
 | 
			
		||||
    }
 | 
			
		||||
    // Add salt to cache version to support breaking changes in cache entry
 | 
			
		||||
    components.push(versionSalt);
 | 
			
		||||
    return crypto
 | 
			
		||||
@ -3429,10 +3434,15 @@ exports.getCacheVersion = getCacheVersion;
 | 
			
		||||
function getCacheEntry(keys, paths, options) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        const httpClient = createHttpClient();
 | 
			
		||||
        const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod);
 | 
			
		||||
        const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod, options === null || options === void 0 ? void 0 : options.enableCrossOsArchive);
 | 
			
		||||
        const resource = `cache?keys=${encodeURIComponent(keys.join(','))}&version=${version}`;
 | 
			
		||||
        const response = yield requestUtils_1.retryTypedResponse('getCacheEntry', () => __awaiter(this, void 0, void 0, function* () { return httpClient.getJson(getCacheApiUrl(resource)); }));
 | 
			
		||||
        // Cache not found
 | 
			
		||||
        if (response.statusCode === 204) {
 | 
			
		||||
            // List cache for primary key only if cache miss occurs
 | 
			
		||||
            if (core.isDebug()) {
 | 
			
		||||
                yield printCachesListForDiagnostics(keys[0], httpClient, version);
 | 
			
		||||
            }
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
        if (!requestUtils_1.isSuccessStatusCode(response.statusCode)) {
 | 
			
		||||
@ -3441,6 +3451,7 @@ function getCacheEntry(keys, paths, options) {
 | 
			
		||||
        const cacheResult = response.result;
 | 
			
		||||
        const cacheDownloadUrl = cacheResult === null || cacheResult === void 0 ? void 0 : cacheResult.archiveLocation;
 | 
			
		||||
        if (!cacheDownloadUrl) {
 | 
			
		||||
            // Cache achiveLocation not found. This should never happen, and hence bail out.
 | 
			
		||||
            throw new Error('Cache not found.');
 | 
			
		||||
        }
 | 
			
		||||
        core.setSecret(cacheDownloadUrl);
 | 
			
		||||
@ -3450,6 +3461,22 @@ function getCacheEntry(keys, paths, options) {
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
exports.getCacheEntry = getCacheEntry;
 | 
			
		||||
function printCachesListForDiagnostics(key, httpClient, version) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        const resource = `caches?key=${encodeURIComponent(key)}`;
 | 
			
		||||
        const response = yield requestUtils_1.retryTypedResponse('listCache', () => __awaiter(this, void 0, void 0, function* () { return httpClient.getJson(getCacheApiUrl(resource)); }));
 | 
			
		||||
        if (response.statusCode === 200) {
 | 
			
		||||
            const cacheListResult = response.result;
 | 
			
		||||
            const totalCount = cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.totalCount;
 | 
			
		||||
            if (totalCount && totalCount > 0) {
 | 
			
		||||
                core.debug(`No matching cache found for cache key '${key}', version '${version} and scope ${process.env['GITHUB_REF']}. There exist one or more cache(s) with similar key but they have different version or scope. See more info on cache matching here: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key \nOther caches with similar key:`);
 | 
			
		||||
                for (const cacheEntry of (cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.artifactCaches) || []) {
 | 
			
		||||
                    core.debug(`Cache Key: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheKey}, Cache Version: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheVersion}, Cache Scope: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.scope}, Cache Created: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.creationTime}`);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
function downloadCache(archiveLocation, archivePath, options) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        const archiveUrl = new url_1.URL(archiveLocation);
 | 
			
		||||
@ -3470,7 +3497,7 @@ exports.downloadCache = downloadCache;
 | 
			
		||||
function reserveCache(key, paths, options) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        const httpClient = createHttpClient();
 | 
			
		||||
        const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod);
 | 
			
		||||
        const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod, options === null || options === void 0 ? void 0 : options.enableCrossOsArchive);
 | 
			
		||||
        const reserveCacheRequest = {
 | 
			
		||||
            key,
 | 
			
		||||
            version,
 | 
			
		||||
@ -4950,7 +4977,8 @@ var Inputs;
 | 
			
		||||
    Inputs["Key"] = "key";
 | 
			
		||||
    Inputs["Path"] = "path";
 | 
			
		||||
    Inputs["RestoreKeys"] = "restore-keys";
 | 
			
		||||
    Inputs["UploadChunkSize"] = "upload-chunk-size"; // Input for cache, save action
 | 
			
		||||
    Inputs["UploadChunkSize"] = "upload-chunk-size";
 | 
			
		||||
    Inputs["EnableCrossOsArchive"] = "enableCrossOsArchive"; // Input for cache, restore, save action
 | 
			
		||||
})(Inputs = exports.Inputs || (exports.Inputs = {}));
 | 
			
		||||
var Outputs;
 | 
			
		||||
(function (Outputs) {
 | 
			
		||||
@ -10046,7 +10074,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
 | 
			
		||||
    return result;
 | 
			
		||||
};
 | 
			
		||||
Object.defineProperty(exports, "__esModule", { value: true });
 | 
			
		||||
exports.isCacheFeatureAvailable = exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.isExactKeyMatch = exports.isGhes = void 0;
 | 
			
		||||
exports.isCacheFeatureAvailable = exports.getInputAsBool = exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.isExactKeyMatch = exports.isGhes = void 0;
 | 
			
		||||
const cache = __importStar(__webpack_require__(692));
 | 
			
		||||
const core = __importStar(__webpack_require__(470));
 | 
			
		||||
const constants_1 = __webpack_require__(196);
 | 
			
		||||
@ -10089,6 +10117,11 @@ function getInputAsInt(name, options) {
 | 
			
		||||
    return value;
 | 
			
		||||
}
 | 
			
		||||
exports.getInputAsInt = getInputAsInt;
 | 
			
		||||
function getInputAsBool(name, options) {
 | 
			
		||||
    const result = core.getInput(name, options);
 | 
			
		||||
    return result.toLowerCase() === "true";
 | 
			
		||||
}
 | 
			
		||||
exports.getInputAsBool = getInputAsBool;
 | 
			
		||||
function isCacheFeatureAvailable() {
 | 
			
		||||
    if (cache.isFeatureAvailable()) {
 | 
			
		||||
        return true;
 | 
			
		||||
@ -38196,27 +38229,27 @@ var __importStar = (this && this.__importStar) || function (mod) {
 | 
			
		||||
};
 | 
			
		||||
Object.defineProperty(exports, "__esModule", { value: true });
 | 
			
		||||
const exec_1 = __webpack_require__(986);
 | 
			
		||||
const core_1 = __webpack_require__(470);
 | 
			
		||||
const io = __importStar(__webpack_require__(1));
 | 
			
		||||
const fs_1 = __webpack_require__(747);
 | 
			
		||||
const path = __importStar(__webpack_require__(622));
 | 
			
		||||
const utils = __importStar(__webpack_require__(15));
 | 
			
		||||
const constants_1 = __webpack_require__(931);
 | 
			
		||||
const IS_WINDOWS = process.platform === 'win32';
 | 
			
		||||
function getTarPath(args, compressionMethod) {
 | 
			
		||||
core_1.exportVariable('MSYS', 'winsymlinks:nativestrict');
 | 
			
		||||
// Returns tar path and type: BSD or GNU
 | 
			
		||||
function getTarPath() {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        switch (process.platform) {
 | 
			
		||||
            case 'win32': {
 | 
			
		||||
                const systemTar = `${process.env['windir']}\\System32\\tar.exe`;
 | 
			
		||||
                if (compressionMethod !== constants_1.CompressionMethod.Gzip) {
 | 
			
		||||
                    // We only use zstandard compression on windows when gnu tar is installed due to
 | 
			
		||||
                    // a bug with compressing large files with bsdtar + zstd
 | 
			
		||||
                    args.push('--force-local');
 | 
			
		||||
                const gnuTar = yield utils.getGnuTarPathOnWindows();
 | 
			
		||||
                const systemTar = constants_1.SystemTarPathOnWindows;
 | 
			
		||||
                if (gnuTar) {
 | 
			
		||||
                    // Use GNUtar as default on windows
 | 
			
		||||
                    return { path: gnuTar, type: constants_1.ArchiveToolType.GNU };
 | 
			
		||||
                }
 | 
			
		||||
                else if (fs_1.existsSync(systemTar)) {
 | 
			
		||||
                    return systemTar;
 | 
			
		||||
                }
 | 
			
		||||
                else if (yield utils.isGnuTarInstalled()) {
 | 
			
		||||
                    args.push('--force-local');
 | 
			
		||||
                    return { path: systemTar, type: constants_1.ArchiveToolType.BSD };
 | 
			
		||||
                }
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
@ -38224,25 +38257,92 @@ function getTarPath(args, compressionMethod) {
 | 
			
		||||
                const gnuTar = yield io.which('gtar', false);
 | 
			
		||||
                if (gnuTar) {
 | 
			
		||||
                    // fix permission denied errors when extracting BSD tar archive with GNU tar - https://github.com/actions/cache/issues/527
 | 
			
		||||
                    args.push('--delay-directory-restore');
 | 
			
		||||
                    return gnuTar;
 | 
			
		||||
                    return { path: gnuTar, type: constants_1.ArchiveToolType.GNU };
 | 
			
		||||
                }
 | 
			
		||||
                else {
 | 
			
		||||
                    return {
 | 
			
		||||
                        path: yield io.which('tar', true),
 | 
			
		||||
                        type: constants_1.ArchiveToolType.BSD
 | 
			
		||||
                    };
 | 
			
		||||
                }
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
            default:
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
        return yield io.which('tar', true);
 | 
			
		||||
        // Default assumption is GNU tar is present in path
 | 
			
		||||
        return {
 | 
			
		||||
            path: yield io.which('tar', true),
 | 
			
		||||
            type: constants_1.ArchiveToolType.GNU
 | 
			
		||||
        };
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
function execTar(args, compressionMethod, cwd) {
 | 
			
		||||
// Return arguments for tar as per tarPath, compressionMethod, method type and os
 | 
			
		||||
function getTarArgs(tarPath, compressionMethod, type, archivePath = '') {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        try {
 | 
			
		||||
            yield exec_1.exec(`"${yield getTarPath(args, compressionMethod)}"`, args, { cwd });
 | 
			
		||||
        const args = [`"${tarPath.path}"`];
 | 
			
		||||
        const cacheFileName = utils.getCacheFileName(compressionMethod);
 | 
			
		||||
        const tarFile = 'cache.tar';
 | 
			
		||||
        const workingDirectory = getWorkingDirectory();
 | 
			
		||||
        // Speficic args for BSD tar on windows for workaround
 | 
			
		||||
        const BSD_TAR_ZSTD = tarPath.type === constants_1.ArchiveToolType.BSD &&
 | 
			
		||||
            compressionMethod !== constants_1.CompressionMethod.Gzip &&
 | 
			
		||||
            IS_WINDOWS;
 | 
			
		||||
        // Method specific args
 | 
			
		||||
        switch (type) {
 | 
			
		||||
            case 'create':
 | 
			
		||||
                args.push('--posix', '-cf', BSD_TAR_ZSTD
 | 
			
		||||
                    ? tarFile
 | 
			
		||||
                    : cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '--exclude', BSD_TAR_ZSTD
 | 
			
		||||
                    ? tarFile
 | 
			
		||||
                    : cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '-P', '-C', workingDirectory.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '--files-from', constants_1.ManifestFilename);
 | 
			
		||||
                break;
 | 
			
		||||
            case 'extract':
 | 
			
		||||
                args.push('-xf', BSD_TAR_ZSTD
 | 
			
		||||
                    ? tarFile
 | 
			
		||||
                    : archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '-P', '-C', workingDirectory.replace(new RegExp(`\\${path.sep}`, 'g'), '/'));
 | 
			
		||||
                break;
 | 
			
		||||
            case 'list':
 | 
			
		||||
                args.push('-tf', BSD_TAR_ZSTD
 | 
			
		||||
                    ? tarFile
 | 
			
		||||
                    : archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '-P');
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
        catch (error) {
 | 
			
		||||
            throw new Error(`Tar failed with error: ${error === null || error === void 0 ? void 0 : error.message}`);
 | 
			
		||||
        // Platform specific args
 | 
			
		||||
        if (tarPath.type === constants_1.ArchiveToolType.GNU) {
 | 
			
		||||
            switch (process.platform) {
 | 
			
		||||
                case 'win32':
 | 
			
		||||
                    args.push('--force-local');
 | 
			
		||||
                    break;
 | 
			
		||||
                case 'darwin':
 | 
			
		||||
                    args.push('--delay-directory-restore');
 | 
			
		||||
                    break;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return args;
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
// Returns commands to run tar and compression program
 | 
			
		||||
function getCommands(compressionMethod, type, archivePath = '') {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        let args;
 | 
			
		||||
        const tarPath = yield getTarPath();
 | 
			
		||||
        const tarArgs = yield getTarArgs(tarPath, compressionMethod, type, archivePath);
 | 
			
		||||
        const compressionArgs = type !== 'create'
 | 
			
		||||
            ? yield getDecompressionProgram(tarPath, compressionMethod, archivePath)
 | 
			
		||||
            : yield getCompressionProgram(tarPath, compressionMethod);
 | 
			
		||||
        const BSD_TAR_ZSTD = tarPath.type === constants_1.ArchiveToolType.BSD &&
 | 
			
		||||
            compressionMethod !== constants_1.CompressionMethod.Gzip &&
 | 
			
		||||
            IS_WINDOWS;
 | 
			
		||||
        if (BSD_TAR_ZSTD && type !== 'create') {
 | 
			
		||||
            args = [[...compressionArgs].join(' '), [...tarArgs].join(' ')];
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            args = [[...tarArgs].join(' '), [...compressionArgs].join(' ')];
 | 
			
		||||
        }
 | 
			
		||||
        if (BSD_TAR_ZSTD) {
 | 
			
		||||
            return args;
 | 
			
		||||
        }
 | 
			
		||||
        return [args.join(' ')];
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
function getWorkingDirectory() {
 | 
			
		||||
@ -38250,91 +38350,116 @@ function getWorkingDirectory() {
 | 
			
		||||
    return (_a = process.env['GITHUB_WORKSPACE']) !== null && _a !== void 0 ? _a : process.cwd();
 | 
			
		||||
}
 | 
			
		||||
// Common function for extractTar and listTar to get the compression method
 | 
			
		||||
function getCompressionProgram(compressionMethod) {
 | 
			
		||||
function getDecompressionProgram(tarPath, compressionMethod, archivePath) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        // -d: Decompress.
 | 
			
		||||
        // unzstd is equivalent to 'zstd -d'
 | 
			
		||||
        // --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit.
 | 
			
		||||
        // Using 30 here because we also support 32-bit self-hosted runners.
 | 
			
		||||
        const BSD_TAR_ZSTD = tarPath.type === constants_1.ArchiveToolType.BSD &&
 | 
			
		||||
            compressionMethod !== constants_1.CompressionMethod.Gzip &&
 | 
			
		||||
            IS_WINDOWS;
 | 
			
		||||
        switch (compressionMethod) {
 | 
			
		||||
            case constants_1.CompressionMethod.Zstd:
 | 
			
		||||
            return [
 | 
			
		||||
                return BSD_TAR_ZSTD
 | 
			
		||||
                    ? [
 | 
			
		||||
                        'zstd -d --long=30 --force -o',
 | 
			
		||||
                        constants_1.TarFilename,
 | 
			
		||||
                        archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/')
 | 
			
		||||
                    ]
 | 
			
		||||
                    : [
 | 
			
		||||
                        '--use-compress-program',
 | 
			
		||||
                IS_WINDOWS ? 'zstd -d --long=30' : 'unzstd --long=30'
 | 
			
		||||
                        IS_WINDOWS ? '"zstd -d --long=30"' : 'unzstd --long=30'
 | 
			
		||||
                    ];
 | 
			
		||||
            case constants_1.CompressionMethod.ZstdWithoutLong:
 | 
			
		||||
            return ['--use-compress-program', IS_WINDOWS ? 'zstd -d' : 'unzstd'];
 | 
			
		||||
                return BSD_TAR_ZSTD
 | 
			
		||||
                    ? [
 | 
			
		||||
                        'zstd -d --force -o',
 | 
			
		||||
                        constants_1.TarFilename,
 | 
			
		||||
                        archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/')
 | 
			
		||||
                    ]
 | 
			
		||||
                    : ['--use-compress-program', IS_WINDOWS ? '"zstd -d"' : 'unzstd'];
 | 
			
		||||
            default:
 | 
			
		||||
                return ['-z'];
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
// Used for creating the archive
 | 
			
		||||
// -T#: Compress using # working thread. If # is 0, attempt to detect and use the number of physical CPU cores.
 | 
			
		||||
// zstdmt is equivalent to 'zstd -T0'
 | 
			
		||||
// --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit.
 | 
			
		||||
// Using 30 here because we also support 32-bit self-hosted runners.
 | 
			
		||||
// Long range mode is added to zstd in v1.3.2 release, so we will not use --long in older version of zstd.
 | 
			
		||||
function getCompressionProgram(tarPath, compressionMethod) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        const cacheFileName = utils.getCacheFileName(compressionMethod);
 | 
			
		||||
        const BSD_TAR_ZSTD = tarPath.type === constants_1.ArchiveToolType.BSD &&
 | 
			
		||||
            compressionMethod !== constants_1.CompressionMethod.Gzip &&
 | 
			
		||||
            IS_WINDOWS;
 | 
			
		||||
        switch (compressionMethod) {
 | 
			
		||||
            case constants_1.CompressionMethod.Zstd:
 | 
			
		||||
                return BSD_TAR_ZSTD
 | 
			
		||||
                    ? [
 | 
			
		||||
                        'zstd -T0 --long=30 --force -o',
 | 
			
		||||
                        cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
 | 
			
		||||
                        constants_1.TarFilename
 | 
			
		||||
                    ]
 | 
			
		||||
                    : [
 | 
			
		||||
                        '--use-compress-program',
 | 
			
		||||
                        IS_WINDOWS ? '"zstd -T0 --long=30"' : 'zstdmt --long=30'
 | 
			
		||||
                    ];
 | 
			
		||||
            case constants_1.CompressionMethod.ZstdWithoutLong:
 | 
			
		||||
                return BSD_TAR_ZSTD
 | 
			
		||||
                    ? [
 | 
			
		||||
                        'zstd -T0 --force -o',
 | 
			
		||||
                        cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
 | 
			
		||||
                        constants_1.TarFilename
 | 
			
		||||
                    ]
 | 
			
		||||
                    : ['--use-compress-program', IS_WINDOWS ? '"zstd -T0"' : 'zstdmt'];
 | 
			
		||||
            default:
 | 
			
		||||
                return ['-z'];
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
// Executes all commands as separate processes
 | 
			
		||||
function execCommands(commands, cwd) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        for (const command of commands) {
 | 
			
		||||
            try {
 | 
			
		||||
                yield exec_1.exec(command, undefined, { cwd });
 | 
			
		||||
            }
 | 
			
		||||
            catch (error) {
 | 
			
		||||
                throw new Error(`${command.split(' ')[0]} failed with error: ${error === null || error === void 0 ? void 0 : error.message}`);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
// List the contents of a tar
 | 
			
		||||
function listTar(archivePath, compressionMethod) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        const args = [
 | 
			
		||||
            ...getCompressionProgram(compressionMethod),
 | 
			
		||||
            '-tf',
 | 
			
		||||
            archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
 | 
			
		||||
            '-P'
 | 
			
		||||
        ];
 | 
			
		||||
        yield execTar(args, compressionMethod);
 | 
			
		||||
        const commands = yield getCommands(compressionMethod, 'list', archivePath);
 | 
			
		||||
        yield execCommands(commands);
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
exports.listTar = listTar;
 | 
			
		||||
// Extract a tar
 | 
			
		||||
function extractTar(archivePath, compressionMethod) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        // Create directory to extract tar into
 | 
			
		||||
        const workingDirectory = getWorkingDirectory();
 | 
			
		||||
        yield io.mkdirP(workingDirectory);
 | 
			
		||||
        const args = [
 | 
			
		||||
            ...getCompressionProgram(compressionMethod),
 | 
			
		||||
            '-xf',
 | 
			
		||||
            archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
 | 
			
		||||
            '-P',
 | 
			
		||||
            '-C',
 | 
			
		||||
            workingDirectory.replace(new RegExp(`\\${path.sep}`, 'g'), '/')
 | 
			
		||||
        ];
 | 
			
		||||
        yield execTar(args, compressionMethod);
 | 
			
		||||
        const commands = yield getCommands(compressionMethod, 'extract', archivePath);
 | 
			
		||||
        yield execCommands(commands);
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
exports.extractTar = extractTar;
 | 
			
		||||
// Create a tar
 | 
			
		||||
function createTar(archiveFolder, sourceDirectories, compressionMethod) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        // Write source directories to manifest.txt to avoid command length limits
 | 
			
		||||
        const manifestFilename = 'manifest.txt';
 | 
			
		||||
        const cacheFileName = utils.getCacheFileName(compressionMethod);
 | 
			
		||||
        fs_1.writeFileSync(path.join(archiveFolder, manifestFilename), sourceDirectories.join('\n'));
 | 
			
		||||
        const workingDirectory = getWorkingDirectory();
 | 
			
		||||
        // -T#: Compress using # working thread. If # is 0, attempt to detect and use the number of physical CPU cores.
 | 
			
		||||
        // zstdmt is equivalent to 'zstd -T0'
 | 
			
		||||
        // --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit.
 | 
			
		||||
        // Using 30 here because we also support 32-bit self-hosted runners.
 | 
			
		||||
        // Long range mode is added to zstd in v1.3.2 release, so we will not use --long in older version of zstd.
 | 
			
		||||
        function getCompressionProgram() {
 | 
			
		||||
            switch (compressionMethod) {
 | 
			
		||||
                case constants_1.CompressionMethod.Zstd:
 | 
			
		||||
                    return [
 | 
			
		||||
                        '--use-compress-program',
 | 
			
		||||
                        IS_WINDOWS ? 'zstd -T0 --long=30' : 'zstdmt --long=30'
 | 
			
		||||
                    ];
 | 
			
		||||
                case constants_1.CompressionMethod.ZstdWithoutLong:
 | 
			
		||||
                    return ['--use-compress-program', IS_WINDOWS ? 'zstd -T0' : 'zstdmt'];
 | 
			
		||||
                default:
 | 
			
		||||
                    return ['-z'];
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        const args = [
 | 
			
		||||
            '--posix',
 | 
			
		||||
            ...getCompressionProgram(),
 | 
			
		||||
            '-cf',
 | 
			
		||||
            cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
 | 
			
		||||
            '--exclude',
 | 
			
		||||
            cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
 | 
			
		||||
            '-P',
 | 
			
		||||
            '-C',
 | 
			
		||||
            workingDirectory.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
 | 
			
		||||
            '--files-from',
 | 
			
		||||
            manifestFilename
 | 
			
		||||
        ];
 | 
			
		||||
        yield execTar(args, compressionMethod, archiveFolder);
 | 
			
		||||
        fs_1.writeFileSync(path.join(archiveFolder, constants_1.ManifestFilename), sourceDirectories.join('\n'));
 | 
			
		||||
        const commands = yield getCommands(compressionMethod, 'create');
 | 
			
		||||
        yield execCommands(commands, archiveFolder);
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
exports.createTar = createTar;
 | 
			
		||||
@ -47130,9 +47255,10 @@ exports.isFeatureAvailable = isFeatureAvailable;
 | 
			
		||||
 * @param primaryKey an explicit key for restoring the cache
 | 
			
		||||
 * @param restoreKeys an optional ordered list of keys to use for restoring the cache if no cache hit occurred for key
 | 
			
		||||
 * @param downloadOptions cache download options
 | 
			
		||||
 * @param enableCrossOsArchive an optional boolean enabled to restore on windows any cache created on any platform
 | 
			
		||||
 * @returns string returns the key for the cache hit, otherwise returns undefined
 | 
			
		||||
 */
 | 
			
		||||
function restoreCache(paths, primaryKey, restoreKeys, options) {
 | 
			
		||||
function restoreCache(paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        checkPaths(paths);
 | 
			
		||||
        restoreKeys = restoreKeys || [];
 | 
			
		||||
@ -47150,7 +47276,8 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
 | 
			
		||||
        try {
 | 
			
		||||
            // path are needed to compute version
 | 
			
		||||
            const cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, {
 | 
			
		||||
                compressionMethod
 | 
			
		||||
                compressionMethod,
 | 
			
		||||
                enableCrossOsArchive
 | 
			
		||||
            });
 | 
			
		||||
            if (!(cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.archiveLocation)) {
 | 
			
		||||
                // Cache not found
 | 
			
		||||
@ -47197,10 +47324,11 @@ exports.restoreCache = restoreCache;
 | 
			
		||||
 *
 | 
			
		||||
 * @param paths a list of file paths to be cached
 | 
			
		||||
 * @param key an explicit key for restoring the cache
 | 
			
		||||
 * @param enableCrossOsArchive an optional boolean enabled to save cache on windows which could be restored on any platform
 | 
			
		||||
 * @param options cache upload options
 | 
			
		||||
 * @returns number returns cacheId if the cache was saved successfully and throws an error if save fails
 | 
			
		||||
 */
 | 
			
		||||
function saveCache(paths, key, options) {
 | 
			
		||||
function saveCache(paths, key, options, enableCrossOsArchive = false) {
 | 
			
		||||
    var _a, _b, _c, _d, _e;
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        checkPaths(paths);
 | 
			
		||||
@ -47231,6 +47359,7 @@ function saveCache(paths, key, options) {
 | 
			
		||||
            core.debug('Reserving Cache');
 | 
			
		||||
            const reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, {
 | 
			
		||||
                compressionMethod,
 | 
			
		||||
                enableCrossOsArchive,
 | 
			
		||||
                cacheSize: archiveFileSize
 | 
			
		||||
            });
 | 
			
		||||
            if ((_a = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.result) === null || _a === void 0 ? void 0 : _a.cacheId) {
 | 
			
		||||
@ -50365,7 +50494,8 @@ function restoreImpl(stateProvider) {
 | 
			
		||||
            const cachePaths = utils.getInputAsArray(constants_1.Inputs.Path, {
 | 
			
		||||
                required: true
 | 
			
		||||
            });
 | 
			
		||||
            const cacheKey = yield cache.restoreCache(cachePaths, primaryKey, restoreKeys);
 | 
			
		||||
            const enableCrossOsArchive = utils.getInputAsBool(constants_1.Inputs.EnableCrossOsArchive);
 | 
			
		||||
            const cacheKey = yield cache.restoreCache(cachePaths, primaryKey, restoreKeys, {}, enableCrossOsArchive);
 | 
			
		||||
            if (!cacheKey) {
 | 
			
		||||
                core.info(`Cache not found for input keys: ${[
 | 
			
		||||
                    primaryKey,
 | 
			
		||||
@ -53235,6 +53365,11 @@ var CompressionMethod;
 | 
			
		||||
    CompressionMethod["ZstdWithoutLong"] = "zstd-without-long";
 | 
			
		||||
    CompressionMethod["Zstd"] = "zstd";
 | 
			
		||||
})(CompressionMethod = exports.CompressionMethod || (exports.CompressionMethod = {}));
 | 
			
		||||
var ArchiveToolType;
 | 
			
		||||
(function (ArchiveToolType) {
 | 
			
		||||
    ArchiveToolType["GNU"] = "gnu";
 | 
			
		||||
    ArchiveToolType["BSD"] = "bsd";
 | 
			
		||||
})(ArchiveToolType = exports.ArchiveToolType || (exports.ArchiveToolType = {}));
 | 
			
		||||
// The default number of retry attempts.
 | 
			
		||||
exports.DefaultRetryAttempts = 2;
 | 
			
		||||
// The default delay in milliseconds between retry attempts.
 | 
			
		||||
@ -53243,6 +53378,12 @@ exports.DefaultRetryDelay = 5000;
 | 
			
		||||
// over the socket during this period, the socket is destroyed and the download
 | 
			
		||||
// is aborted.
 | 
			
		||||
exports.SocketTimeout = 5000;
 | 
			
		||||
// The default path of GNUtar on hosted Windows runners
 | 
			
		||||
exports.GnuTarPathOnWindows = `${process.env['PROGRAMFILES']}\\Git\\usr\\bin\\tar.exe`;
 | 
			
		||||
// The default path of BSDtar on hosted Windows runners
 | 
			
		||||
exports.SystemTarPathOnWindows = `${process.env['SYSTEMDRIVE']}\\Windows\\System32\\tar.exe`;
 | 
			
		||||
exports.TarFilename = 'cache.tar';
 | 
			
		||||
exports.ManifestFilename = 'manifest.txt';
 | 
			
		||||
//# sourceMappingURL=constants.js.map
 | 
			
		||||
 | 
			
		||||
/***/ }),
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										331
									
								
								dist/restore/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										331
									
								
								dist/restore/index.js
									
									
									
									
										vendored
									
									
								
							@ -1177,10 +1177,6 @@ function getVersion(app) {
 | 
			
		||||
// Use zstandard if possible to maximize cache performance
 | 
			
		||||
function getCompressionMethod() {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        if (process.platform === 'win32' && !(yield isGnuTarInstalled())) {
 | 
			
		||||
            // Disable zstd due to bug https://github.com/actions/cache/issues/301
 | 
			
		||||
            return constants_1.CompressionMethod.Gzip;
 | 
			
		||||
        }
 | 
			
		||||
        const versionOutput = yield getVersion('zstd');
 | 
			
		||||
        const version = semver.clean(versionOutput);
 | 
			
		||||
        if (!versionOutput.toLowerCase().includes('zstd command line interface')) {
 | 
			
		||||
@ -1204,13 +1200,16 @@ function getCacheFileName(compressionMethod) {
 | 
			
		||||
        : constants_1.CacheFilename.Zstd;
 | 
			
		||||
}
 | 
			
		||||
exports.getCacheFileName = getCacheFileName;
 | 
			
		||||
function isGnuTarInstalled() {
 | 
			
		||||
function getGnuTarPathOnWindows() {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        if (fs.existsSync(constants_1.GnuTarPathOnWindows)) {
 | 
			
		||||
            return constants_1.GnuTarPathOnWindows;
 | 
			
		||||
        }
 | 
			
		||||
        const versionOutput = yield getVersion('tar');
 | 
			
		||||
        return versionOutput.toLowerCase().includes('gnu tar');
 | 
			
		||||
        return versionOutput.toLowerCase().includes('gnu tar') ? io.which('tar') : '';
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
exports.isGnuTarInstalled = isGnuTarInstalled;
 | 
			
		||||
exports.getGnuTarPathOnWindows = getGnuTarPathOnWindows;
 | 
			
		||||
function assertDefined(name, value) {
 | 
			
		||||
    if (value === undefined) {
 | 
			
		||||
        throw Error(`Expected ${name} but value was undefiend`);
 | 
			
		||||
@ -3384,7 +3383,6 @@ const crypto = __importStar(__webpack_require__(417));
 | 
			
		||||
const fs = __importStar(__webpack_require__(747));
 | 
			
		||||
const url_1 = __webpack_require__(414);
 | 
			
		||||
const utils = __importStar(__webpack_require__(15));
 | 
			
		||||
const constants_1 = __webpack_require__(931);
 | 
			
		||||
const downloadUtils_1 = __webpack_require__(251);
 | 
			
		||||
const options_1 = __webpack_require__(538);
 | 
			
		||||
const requestUtils_1 = __webpack_require__(899);
 | 
			
		||||
@ -3414,10 +3412,17 @@ function createHttpClient() {
 | 
			
		||||
    const bearerCredentialHandler = new auth_1.BearerCredentialHandler(token);
 | 
			
		||||
    return new http_client_1.HttpClient('actions/cache', [bearerCredentialHandler], getRequestOptions());
 | 
			
		||||
}
 | 
			
		||||
function getCacheVersion(paths, compressionMethod) {
 | 
			
		||||
    const components = paths.concat(!compressionMethod || compressionMethod === constants_1.CompressionMethod.Gzip
 | 
			
		||||
        ? []
 | 
			
		||||
        : [compressionMethod]);
 | 
			
		||||
function getCacheVersion(paths, compressionMethod, enableCrossOsArchive = false) {
 | 
			
		||||
    const components = paths;
 | 
			
		||||
    // Add compression method to cache version to restore
 | 
			
		||||
    // compressed cache as per compression method
 | 
			
		||||
    if (compressionMethod) {
 | 
			
		||||
        components.push(compressionMethod);
 | 
			
		||||
    }
 | 
			
		||||
    // Only check for windows platforms if enableCrossOsArchive is false
 | 
			
		||||
    if (process.platform === 'win32' && !enableCrossOsArchive) {
 | 
			
		||||
        components.push('windows-only');
 | 
			
		||||
    }
 | 
			
		||||
    // Add salt to cache version to support breaking changes in cache entry
 | 
			
		||||
    components.push(versionSalt);
 | 
			
		||||
    return crypto
 | 
			
		||||
@ -3429,10 +3434,15 @@ exports.getCacheVersion = getCacheVersion;
 | 
			
		||||
function getCacheEntry(keys, paths, options) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        const httpClient = createHttpClient();
 | 
			
		||||
        const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod);
 | 
			
		||||
        const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod, options === null || options === void 0 ? void 0 : options.enableCrossOsArchive);
 | 
			
		||||
        const resource = `cache?keys=${encodeURIComponent(keys.join(','))}&version=${version}`;
 | 
			
		||||
        const response = yield requestUtils_1.retryTypedResponse('getCacheEntry', () => __awaiter(this, void 0, void 0, function* () { return httpClient.getJson(getCacheApiUrl(resource)); }));
 | 
			
		||||
        // Cache not found
 | 
			
		||||
        if (response.statusCode === 204) {
 | 
			
		||||
            // List cache for primary key only if cache miss occurs
 | 
			
		||||
            if (core.isDebug()) {
 | 
			
		||||
                yield printCachesListForDiagnostics(keys[0], httpClient, version);
 | 
			
		||||
            }
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
        if (!requestUtils_1.isSuccessStatusCode(response.statusCode)) {
 | 
			
		||||
@ -3441,6 +3451,7 @@ function getCacheEntry(keys, paths, options) {
 | 
			
		||||
        const cacheResult = response.result;
 | 
			
		||||
        const cacheDownloadUrl = cacheResult === null || cacheResult === void 0 ? void 0 : cacheResult.archiveLocation;
 | 
			
		||||
        if (!cacheDownloadUrl) {
 | 
			
		||||
            // Cache achiveLocation not found. This should never happen, and hence bail out.
 | 
			
		||||
            throw new Error('Cache not found.');
 | 
			
		||||
        }
 | 
			
		||||
        core.setSecret(cacheDownloadUrl);
 | 
			
		||||
@ -3450,6 +3461,22 @@ function getCacheEntry(keys, paths, options) {
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
exports.getCacheEntry = getCacheEntry;
 | 
			
		||||
function printCachesListForDiagnostics(key, httpClient, version) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        const resource = `caches?key=${encodeURIComponent(key)}`;
 | 
			
		||||
        const response = yield requestUtils_1.retryTypedResponse('listCache', () => __awaiter(this, void 0, void 0, function* () { return httpClient.getJson(getCacheApiUrl(resource)); }));
 | 
			
		||||
        if (response.statusCode === 200) {
 | 
			
		||||
            const cacheListResult = response.result;
 | 
			
		||||
            const totalCount = cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.totalCount;
 | 
			
		||||
            if (totalCount && totalCount > 0) {
 | 
			
		||||
                core.debug(`No matching cache found for cache key '${key}', version '${version} and scope ${process.env['GITHUB_REF']}. There exist one or more cache(s) with similar key but they have different version or scope. See more info on cache matching here: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key \nOther caches with similar key:`);
 | 
			
		||||
                for (const cacheEntry of (cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.artifactCaches) || []) {
 | 
			
		||||
                    core.debug(`Cache Key: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheKey}, Cache Version: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheVersion}, Cache Scope: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.scope}, Cache Created: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.creationTime}`);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
function downloadCache(archiveLocation, archivePath, options) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        const archiveUrl = new url_1.URL(archiveLocation);
 | 
			
		||||
@ -3470,7 +3497,7 @@ exports.downloadCache = downloadCache;
 | 
			
		||||
function reserveCache(key, paths, options) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        const httpClient = createHttpClient();
 | 
			
		||||
        const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod);
 | 
			
		||||
        const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod, options === null || options === void 0 ? void 0 : options.enableCrossOsArchive);
 | 
			
		||||
        const reserveCacheRequest = {
 | 
			
		||||
            key,
 | 
			
		||||
            version,
 | 
			
		||||
@ -4950,7 +4977,8 @@ var Inputs;
 | 
			
		||||
    Inputs["Key"] = "key";
 | 
			
		||||
    Inputs["Path"] = "path";
 | 
			
		||||
    Inputs["RestoreKeys"] = "restore-keys";
 | 
			
		||||
    Inputs["UploadChunkSize"] = "upload-chunk-size"; // Input for cache, save action
 | 
			
		||||
    Inputs["UploadChunkSize"] = "upload-chunk-size";
 | 
			
		||||
    Inputs["EnableCrossOsArchive"] = "enableCrossOsArchive"; // Input for cache, restore, save action
 | 
			
		||||
})(Inputs = exports.Inputs || (exports.Inputs = {}));
 | 
			
		||||
var Outputs;
 | 
			
		||||
(function (Outputs) {
 | 
			
		||||
@ -38109,27 +38137,27 @@ var __importStar = (this && this.__importStar) || function (mod) {
 | 
			
		||||
};
 | 
			
		||||
Object.defineProperty(exports, "__esModule", { value: true });
 | 
			
		||||
const exec_1 = __webpack_require__(986);
 | 
			
		||||
const core_1 = __webpack_require__(470);
 | 
			
		||||
const io = __importStar(__webpack_require__(1));
 | 
			
		||||
const fs_1 = __webpack_require__(747);
 | 
			
		||||
const path = __importStar(__webpack_require__(622));
 | 
			
		||||
const utils = __importStar(__webpack_require__(15));
 | 
			
		||||
const constants_1 = __webpack_require__(931);
 | 
			
		||||
const IS_WINDOWS = process.platform === 'win32';
 | 
			
		||||
function getTarPath(args, compressionMethod) {
 | 
			
		||||
core_1.exportVariable('MSYS', 'winsymlinks:nativestrict');
 | 
			
		||||
// Returns tar path and type: BSD or GNU
 | 
			
		||||
function getTarPath() {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        switch (process.platform) {
 | 
			
		||||
            case 'win32': {
 | 
			
		||||
                const systemTar = `${process.env['windir']}\\System32\\tar.exe`;
 | 
			
		||||
                if (compressionMethod !== constants_1.CompressionMethod.Gzip) {
 | 
			
		||||
                    // We only use zstandard compression on windows when gnu tar is installed due to
 | 
			
		||||
                    // a bug with compressing large files with bsdtar + zstd
 | 
			
		||||
                    args.push('--force-local');
 | 
			
		||||
                const gnuTar = yield utils.getGnuTarPathOnWindows();
 | 
			
		||||
                const systemTar = constants_1.SystemTarPathOnWindows;
 | 
			
		||||
                if (gnuTar) {
 | 
			
		||||
                    // Use GNUtar as default on windows
 | 
			
		||||
                    return { path: gnuTar, type: constants_1.ArchiveToolType.GNU };
 | 
			
		||||
                }
 | 
			
		||||
                else if (fs_1.existsSync(systemTar)) {
 | 
			
		||||
                    return systemTar;
 | 
			
		||||
                }
 | 
			
		||||
                else if (yield utils.isGnuTarInstalled()) {
 | 
			
		||||
                    args.push('--force-local');
 | 
			
		||||
                    return { path: systemTar, type: constants_1.ArchiveToolType.BSD };
 | 
			
		||||
                }
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
@ -38137,25 +38165,92 @@ function getTarPath(args, compressionMethod) {
 | 
			
		||||
                const gnuTar = yield io.which('gtar', false);
 | 
			
		||||
                if (gnuTar) {
 | 
			
		||||
                    // fix permission denied errors when extracting BSD tar archive with GNU tar - https://github.com/actions/cache/issues/527
 | 
			
		||||
                    args.push('--delay-directory-restore');
 | 
			
		||||
                    return gnuTar;
 | 
			
		||||
                    return { path: gnuTar, type: constants_1.ArchiveToolType.GNU };
 | 
			
		||||
                }
 | 
			
		||||
                else {
 | 
			
		||||
                    return {
 | 
			
		||||
                        path: yield io.which('tar', true),
 | 
			
		||||
                        type: constants_1.ArchiveToolType.BSD
 | 
			
		||||
                    };
 | 
			
		||||
                }
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
            default:
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
        return yield io.which('tar', true);
 | 
			
		||||
        // Default assumption is GNU tar is present in path
 | 
			
		||||
        return {
 | 
			
		||||
            path: yield io.which('tar', true),
 | 
			
		||||
            type: constants_1.ArchiveToolType.GNU
 | 
			
		||||
        };
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
function execTar(args, compressionMethod, cwd) {
 | 
			
		||||
// Return arguments for tar as per tarPath, compressionMethod, method type and os
 | 
			
		||||
function getTarArgs(tarPath, compressionMethod, type, archivePath = '') {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        try {
 | 
			
		||||
            yield exec_1.exec(`"${yield getTarPath(args, compressionMethod)}"`, args, { cwd });
 | 
			
		||||
        const args = [`"${tarPath.path}"`];
 | 
			
		||||
        const cacheFileName = utils.getCacheFileName(compressionMethod);
 | 
			
		||||
        const tarFile = 'cache.tar';
 | 
			
		||||
        const workingDirectory = getWorkingDirectory();
 | 
			
		||||
        // Speficic args for BSD tar on windows for workaround
 | 
			
		||||
        const BSD_TAR_ZSTD = tarPath.type === constants_1.ArchiveToolType.BSD &&
 | 
			
		||||
            compressionMethod !== constants_1.CompressionMethod.Gzip &&
 | 
			
		||||
            IS_WINDOWS;
 | 
			
		||||
        // Method specific args
 | 
			
		||||
        switch (type) {
 | 
			
		||||
            case 'create':
 | 
			
		||||
                args.push('--posix', '-cf', BSD_TAR_ZSTD
 | 
			
		||||
                    ? tarFile
 | 
			
		||||
                    : cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '--exclude', BSD_TAR_ZSTD
 | 
			
		||||
                    ? tarFile
 | 
			
		||||
                    : cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '-P', '-C', workingDirectory.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '--files-from', constants_1.ManifestFilename);
 | 
			
		||||
                break;
 | 
			
		||||
            case 'extract':
 | 
			
		||||
                args.push('-xf', BSD_TAR_ZSTD
 | 
			
		||||
                    ? tarFile
 | 
			
		||||
                    : archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '-P', '-C', workingDirectory.replace(new RegExp(`\\${path.sep}`, 'g'), '/'));
 | 
			
		||||
                break;
 | 
			
		||||
            case 'list':
 | 
			
		||||
                args.push('-tf', BSD_TAR_ZSTD
 | 
			
		||||
                    ? tarFile
 | 
			
		||||
                    : archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '-P');
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
        catch (error) {
 | 
			
		||||
            throw new Error(`Tar failed with error: ${error === null || error === void 0 ? void 0 : error.message}`);
 | 
			
		||||
        // Platform specific args
 | 
			
		||||
        if (tarPath.type === constants_1.ArchiveToolType.GNU) {
 | 
			
		||||
            switch (process.platform) {
 | 
			
		||||
                case 'win32':
 | 
			
		||||
                    args.push('--force-local');
 | 
			
		||||
                    break;
 | 
			
		||||
                case 'darwin':
 | 
			
		||||
                    args.push('--delay-directory-restore');
 | 
			
		||||
                    break;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return args;
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
// Returns commands to run tar and compression program
 | 
			
		||||
function getCommands(compressionMethod, type, archivePath = '') {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        let args;
 | 
			
		||||
        const tarPath = yield getTarPath();
 | 
			
		||||
        const tarArgs = yield getTarArgs(tarPath, compressionMethod, type, archivePath);
 | 
			
		||||
        const compressionArgs = type !== 'create'
 | 
			
		||||
            ? yield getDecompressionProgram(tarPath, compressionMethod, archivePath)
 | 
			
		||||
            : yield getCompressionProgram(tarPath, compressionMethod);
 | 
			
		||||
        const BSD_TAR_ZSTD = tarPath.type === constants_1.ArchiveToolType.BSD &&
 | 
			
		||||
            compressionMethod !== constants_1.CompressionMethod.Gzip &&
 | 
			
		||||
            IS_WINDOWS;
 | 
			
		||||
        if (BSD_TAR_ZSTD && type !== 'create') {
 | 
			
		||||
            args = [[...compressionArgs].join(' '), [...tarArgs].join(' ')];
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            args = [[...tarArgs].join(' '), [...compressionArgs].join(' ')];
 | 
			
		||||
        }
 | 
			
		||||
        if (BSD_TAR_ZSTD) {
 | 
			
		||||
            return args;
 | 
			
		||||
        }
 | 
			
		||||
        return [args.join(' ')];
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
function getWorkingDirectory() {
 | 
			
		||||
@ -38163,91 +38258,116 @@ function getWorkingDirectory() {
 | 
			
		||||
    return (_a = process.env['GITHUB_WORKSPACE']) !== null && _a !== void 0 ? _a : process.cwd();
 | 
			
		||||
}
 | 
			
		||||
// Common function for extractTar and listTar to get the compression method
 | 
			
		||||
function getCompressionProgram(compressionMethod) {
 | 
			
		||||
function getDecompressionProgram(tarPath, compressionMethod, archivePath) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        // -d: Decompress.
 | 
			
		||||
        // unzstd is equivalent to 'zstd -d'
 | 
			
		||||
        // --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit.
 | 
			
		||||
        // Using 30 here because we also support 32-bit self-hosted runners.
 | 
			
		||||
        const BSD_TAR_ZSTD = tarPath.type === constants_1.ArchiveToolType.BSD &&
 | 
			
		||||
            compressionMethod !== constants_1.CompressionMethod.Gzip &&
 | 
			
		||||
            IS_WINDOWS;
 | 
			
		||||
        switch (compressionMethod) {
 | 
			
		||||
            case constants_1.CompressionMethod.Zstd:
 | 
			
		||||
            return [
 | 
			
		||||
                return BSD_TAR_ZSTD
 | 
			
		||||
                    ? [
 | 
			
		||||
                        'zstd -d --long=30 --force -o',
 | 
			
		||||
                        constants_1.TarFilename,
 | 
			
		||||
                        archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/')
 | 
			
		||||
                    ]
 | 
			
		||||
                    : [
 | 
			
		||||
                        '--use-compress-program',
 | 
			
		||||
                IS_WINDOWS ? 'zstd -d --long=30' : 'unzstd --long=30'
 | 
			
		||||
                        IS_WINDOWS ? '"zstd -d --long=30"' : 'unzstd --long=30'
 | 
			
		||||
                    ];
 | 
			
		||||
            case constants_1.CompressionMethod.ZstdWithoutLong:
 | 
			
		||||
            return ['--use-compress-program', IS_WINDOWS ? 'zstd -d' : 'unzstd'];
 | 
			
		||||
                return BSD_TAR_ZSTD
 | 
			
		||||
                    ? [
 | 
			
		||||
                        'zstd -d --force -o',
 | 
			
		||||
                        constants_1.TarFilename,
 | 
			
		||||
                        archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/')
 | 
			
		||||
                    ]
 | 
			
		||||
                    : ['--use-compress-program', IS_WINDOWS ? '"zstd -d"' : 'unzstd'];
 | 
			
		||||
            default:
 | 
			
		||||
                return ['-z'];
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
// Used for creating the archive
 | 
			
		||||
// -T#: Compress using # working thread. If # is 0, attempt to detect and use the number of physical CPU cores.
 | 
			
		||||
// zstdmt is equivalent to 'zstd -T0'
 | 
			
		||||
// --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit.
 | 
			
		||||
// Using 30 here because we also support 32-bit self-hosted runners.
 | 
			
		||||
// Long range mode is added to zstd in v1.3.2 release, so we will not use --long in older version of zstd.
 | 
			
		||||
function getCompressionProgram(tarPath, compressionMethod) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        const cacheFileName = utils.getCacheFileName(compressionMethod);
 | 
			
		||||
        const BSD_TAR_ZSTD = tarPath.type === constants_1.ArchiveToolType.BSD &&
 | 
			
		||||
            compressionMethod !== constants_1.CompressionMethod.Gzip &&
 | 
			
		||||
            IS_WINDOWS;
 | 
			
		||||
        switch (compressionMethod) {
 | 
			
		||||
            case constants_1.CompressionMethod.Zstd:
 | 
			
		||||
                return BSD_TAR_ZSTD
 | 
			
		||||
                    ? [
 | 
			
		||||
                        'zstd -T0 --long=30 --force -o',
 | 
			
		||||
                        cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
 | 
			
		||||
                        constants_1.TarFilename
 | 
			
		||||
                    ]
 | 
			
		||||
                    : [
 | 
			
		||||
                        '--use-compress-program',
 | 
			
		||||
                        IS_WINDOWS ? '"zstd -T0 --long=30"' : 'zstdmt --long=30'
 | 
			
		||||
                    ];
 | 
			
		||||
            case constants_1.CompressionMethod.ZstdWithoutLong:
 | 
			
		||||
                return BSD_TAR_ZSTD
 | 
			
		||||
                    ? [
 | 
			
		||||
                        'zstd -T0 --force -o',
 | 
			
		||||
                        cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
 | 
			
		||||
                        constants_1.TarFilename
 | 
			
		||||
                    ]
 | 
			
		||||
                    : ['--use-compress-program', IS_WINDOWS ? '"zstd -T0"' : 'zstdmt'];
 | 
			
		||||
            default:
 | 
			
		||||
                return ['-z'];
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
// Executes all commands as separate processes
 | 
			
		||||
function execCommands(commands, cwd) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        for (const command of commands) {
 | 
			
		||||
            try {
 | 
			
		||||
                yield exec_1.exec(command, undefined, { cwd });
 | 
			
		||||
            }
 | 
			
		||||
            catch (error) {
 | 
			
		||||
                throw new Error(`${command.split(' ')[0]} failed with error: ${error === null || error === void 0 ? void 0 : error.message}`);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
// List the contents of a tar
 | 
			
		||||
function listTar(archivePath, compressionMethod) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        const args = [
 | 
			
		||||
            ...getCompressionProgram(compressionMethod),
 | 
			
		||||
            '-tf',
 | 
			
		||||
            archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
 | 
			
		||||
            '-P'
 | 
			
		||||
        ];
 | 
			
		||||
        yield execTar(args, compressionMethod);
 | 
			
		||||
        const commands = yield getCommands(compressionMethod, 'list', archivePath);
 | 
			
		||||
        yield execCommands(commands);
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
exports.listTar = listTar;
 | 
			
		||||
// Extract a tar
 | 
			
		||||
function extractTar(archivePath, compressionMethod) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        // Create directory to extract tar into
 | 
			
		||||
        const workingDirectory = getWorkingDirectory();
 | 
			
		||||
        yield io.mkdirP(workingDirectory);
 | 
			
		||||
        const args = [
 | 
			
		||||
            ...getCompressionProgram(compressionMethod),
 | 
			
		||||
            '-xf',
 | 
			
		||||
            archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
 | 
			
		||||
            '-P',
 | 
			
		||||
            '-C',
 | 
			
		||||
            workingDirectory.replace(new RegExp(`\\${path.sep}`, 'g'), '/')
 | 
			
		||||
        ];
 | 
			
		||||
        yield execTar(args, compressionMethod);
 | 
			
		||||
        const commands = yield getCommands(compressionMethod, 'extract', archivePath);
 | 
			
		||||
        yield execCommands(commands);
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
exports.extractTar = extractTar;
 | 
			
		||||
// Create a tar
 | 
			
		||||
function createTar(archiveFolder, sourceDirectories, compressionMethod) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        // Write source directories to manifest.txt to avoid command length limits
 | 
			
		||||
        const manifestFilename = 'manifest.txt';
 | 
			
		||||
        const cacheFileName = utils.getCacheFileName(compressionMethod);
 | 
			
		||||
        fs_1.writeFileSync(path.join(archiveFolder, manifestFilename), sourceDirectories.join('\n'));
 | 
			
		||||
        const workingDirectory = getWorkingDirectory();
 | 
			
		||||
        // -T#: Compress using # working thread. If # is 0, attempt to detect and use the number of physical CPU cores.
 | 
			
		||||
        // zstdmt is equivalent to 'zstd -T0'
 | 
			
		||||
        // --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit.
 | 
			
		||||
        // Using 30 here because we also support 32-bit self-hosted runners.
 | 
			
		||||
        // Long range mode is added to zstd in v1.3.2 release, so we will not use --long in older version of zstd.
 | 
			
		||||
        function getCompressionProgram() {
 | 
			
		||||
            switch (compressionMethod) {
 | 
			
		||||
                case constants_1.CompressionMethod.Zstd:
 | 
			
		||||
                    return [
 | 
			
		||||
                        '--use-compress-program',
 | 
			
		||||
                        IS_WINDOWS ? 'zstd -T0 --long=30' : 'zstdmt --long=30'
 | 
			
		||||
                    ];
 | 
			
		||||
                case constants_1.CompressionMethod.ZstdWithoutLong:
 | 
			
		||||
                    return ['--use-compress-program', IS_WINDOWS ? 'zstd -T0' : 'zstdmt'];
 | 
			
		||||
                default:
 | 
			
		||||
                    return ['-z'];
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        const args = [
 | 
			
		||||
            '--posix',
 | 
			
		||||
            ...getCompressionProgram(),
 | 
			
		||||
            '-cf',
 | 
			
		||||
            cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
 | 
			
		||||
            '--exclude',
 | 
			
		||||
            cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
 | 
			
		||||
            '-P',
 | 
			
		||||
            '-C',
 | 
			
		||||
            workingDirectory.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
 | 
			
		||||
            '--files-from',
 | 
			
		||||
            manifestFilename
 | 
			
		||||
        ];
 | 
			
		||||
        yield execTar(args, compressionMethod, archiveFolder);
 | 
			
		||||
        fs_1.writeFileSync(path.join(archiveFolder, constants_1.ManifestFilename), sourceDirectories.join('\n'));
 | 
			
		||||
        const commands = yield getCommands(compressionMethod, 'create');
 | 
			
		||||
        yield execCommands(commands, archiveFolder);
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
exports.createTar = createTar;
 | 
			
		||||
@ -38482,7 +38602,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
 | 
			
		||||
    return result;
 | 
			
		||||
};
 | 
			
		||||
Object.defineProperty(exports, "__esModule", { value: true });
 | 
			
		||||
exports.isCacheFeatureAvailable = exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.isExactKeyMatch = exports.isGhes = void 0;
 | 
			
		||||
exports.isCacheFeatureAvailable = exports.getInputAsBool = exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.isExactKeyMatch = exports.isGhes = void 0;
 | 
			
		||||
const cache = __importStar(__webpack_require__(692));
 | 
			
		||||
const core = __importStar(__webpack_require__(470));
 | 
			
		||||
const constants_1 = __webpack_require__(196);
 | 
			
		||||
@ -38525,6 +38645,11 @@ function getInputAsInt(name, options) {
 | 
			
		||||
    return value;
 | 
			
		||||
}
 | 
			
		||||
exports.getInputAsInt = getInputAsInt;
 | 
			
		||||
function getInputAsBool(name, options) {
 | 
			
		||||
    const result = core.getInput(name, options);
 | 
			
		||||
    return result.toLowerCase() === "true";
 | 
			
		||||
}
 | 
			
		||||
exports.getInputAsBool = getInputAsBool;
 | 
			
		||||
function isCacheFeatureAvailable() {
 | 
			
		||||
    if (cache.isFeatureAvailable()) {
 | 
			
		||||
        return true;
 | 
			
		||||
@ -47101,9 +47226,10 @@ exports.isFeatureAvailable = isFeatureAvailable;
 | 
			
		||||
 * @param primaryKey an explicit key for restoring the cache
 | 
			
		||||
 * @param restoreKeys an optional ordered list of keys to use for restoring the cache if no cache hit occurred for key
 | 
			
		||||
 * @param downloadOptions cache download options
 | 
			
		||||
 * @param enableCrossOsArchive an optional boolean enabled to restore on windows any cache created on any platform
 | 
			
		||||
 * @returns string returns the key for the cache hit, otherwise returns undefined
 | 
			
		||||
 */
 | 
			
		||||
function restoreCache(paths, primaryKey, restoreKeys, options) {
 | 
			
		||||
function restoreCache(paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        checkPaths(paths);
 | 
			
		||||
        restoreKeys = restoreKeys || [];
 | 
			
		||||
@ -47121,7 +47247,8 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
 | 
			
		||||
        try {
 | 
			
		||||
            // path are needed to compute version
 | 
			
		||||
            const cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, {
 | 
			
		||||
                compressionMethod
 | 
			
		||||
                compressionMethod,
 | 
			
		||||
                enableCrossOsArchive
 | 
			
		||||
            });
 | 
			
		||||
            if (!(cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.archiveLocation)) {
 | 
			
		||||
                // Cache not found
 | 
			
		||||
@ -47168,10 +47295,11 @@ exports.restoreCache = restoreCache;
 | 
			
		||||
 *
 | 
			
		||||
 * @param paths a list of file paths to be cached
 | 
			
		||||
 * @param key an explicit key for restoring the cache
 | 
			
		||||
 * @param enableCrossOsArchive an optional boolean enabled to save cache on windows which could be restored on any platform
 | 
			
		||||
 * @param options cache upload options
 | 
			
		||||
 * @returns number returns cacheId if the cache was saved successfully and throws an error if save fails
 | 
			
		||||
 */
 | 
			
		||||
function saveCache(paths, key, options) {
 | 
			
		||||
function saveCache(paths, key, options, enableCrossOsArchive = false) {
 | 
			
		||||
    var _a, _b, _c, _d, _e;
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        checkPaths(paths);
 | 
			
		||||
@ -47202,6 +47330,7 @@ function saveCache(paths, key, options) {
 | 
			
		||||
            core.debug('Reserving Cache');
 | 
			
		||||
            const reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, {
 | 
			
		||||
                compressionMethod,
 | 
			
		||||
                enableCrossOsArchive,
 | 
			
		||||
                cacheSize: archiveFileSize
 | 
			
		||||
            });
 | 
			
		||||
            if ((_a = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.result) === null || _a === void 0 ? void 0 : _a.cacheId) {
 | 
			
		||||
@ -50365,7 +50494,8 @@ function restoreImpl(stateProvider) {
 | 
			
		||||
            const cachePaths = utils.getInputAsArray(constants_1.Inputs.Path, {
 | 
			
		||||
                required: true
 | 
			
		||||
            });
 | 
			
		||||
            const cacheKey = yield cache.restoreCache(cachePaths, primaryKey, restoreKeys);
 | 
			
		||||
            const enableCrossOsArchive = utils.getInputAsBool(constants_1.Inputs.EnableCrossOsArchive);
 | 
			
		||||
            const cacheKey = yield cache.restoreCache(cachePaths, primaryKey, restoreKeys, {}, enableCrossOsArchive);
 | 
			
		||||
            if (!cacheKey) {
 | 
			
		||||
                core.info(`Cache not found for input keys: ${[
 | 
			
		||||
                    primaryKey,
 | 
			
		||||
@ -53235,6 +53365,11 @@ var CompressionMethod;
 | 
			
		||||
    CompressionMethod["ZstdWithoutLong"] = "zstd-without-long";
 | 
			
		||||
    CompressionMethod["Zstd"] = "zstd";
 | 
			
		||||
})(CompressionMethod = exports.CompressionMethod || (exports.CompressionMethod = {}));
 | 
			
		||||
var ArchiveToolType;
 | 
			
		||||
(function (ArchiveToolType) {
 | 
			
		||||
    ArchiveToolType["GNU"] = "gnu";
 | 
			
		||||
    ArchiveToolType["BSD"] = "bsd";
 | 
			
		||||
})(ArchiveToolType = exports.ArchiveToolType || (exports.ArchiveToolType = {}));
 | 
			
		||||
// The default number of retry attempts.
 | 
			
		||||
exports.DefaultRetryAttempts = 2;
 | 
			
		||||
// The default delay in milliseconds between retry attempts.
 | 
			
		||||
@ -53243,6 +53378,12 @@ exports.DefaultRetryDelay = 5000;
 | 
			
		||||
// over the socket during this period, the socket is destroyed and the download
 | 
			
		||||
// is aborted.
 | 
			
		||||
exports.SocketTimeout = 5000;
 | 
			
		||||
// The default path of GNUtar on hosted Windows runners
 | 
			
		||||
exports.GnuTarPathOnWindows = `${process.env['PROGRAMFILES']}\\Git\\usr\\bin\\tar.exe`;
 | 
			
		||||
// The default path of BSDtar on hosted Windows runners
 | 
			
		||||
exports.SystemTarPathOnWindows = `${process.env['SYSTEMDRIVE']}\\Windows\\System32\\tar.exe`;
 | 
			
		||||
exports.TarFilename = 'cache.tar';
 | 
			
		||||
exports.ManifestFilename = 'manifest.txt';
 | 
			
		||||
//# sourceMappingURL=constants.js.map
 | 
			
		||||
 | 
			
		||||
/***/ }),
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										333
									
								
								dist/save-only/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										333
									
								
								dist/save-only/index.js
									
									
									
									
										vendored
									
									
								
							@ -1233,10 +1233,6 @@ function getVersion(app) {
 | 
			
		||||
// Use zstandard if possible to maximize cache performance
 | 
			
		||||
function getCompressionMethod() {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        if (process.platform === 'win32' && !(yield isGnuTarInstalled())) {
 | 
			
		||||
            // Disable zstd due to bug https://github.com/actions/cache/issues/301
 | 
			
		||||
            return constants_1.CompressionMethod.Gzip;
 | 
			
		||||
        }
 | 
			
		||||
        const versionOutput = yield getVersion('zstd');
 | 
			
		||||
        const version = semver.clean(versionOutput);
 | 
			
		||||
        if (!versionOutput.toLowerCase().includes('zstd command line interface')) {
 | 
			
		||||
@ -1260,13 +1256,16 @@ function getCacheFileName(compressionMethod) {
 | 
			
		||||
        : constants_1.CacheFilename.Zstd;
 | 
			
		||||
}
 | 
			
		||||
exports.getCacheFileName = getCacheFileName;
 | 
			
		||||
function isGnuTarInstalled() {
 | 
			
		||||
function getGnuTarPathOnWindows() {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        if (fs.existsSync(constants_1.GnuTarPathOnWindows)) {
 | 
			
		||||
            return constants_1.GnuTarPathOnWindows;
 | 
			
		||||
        }
 | 
			
		||||
        const versionOutput = yield getVersion('tar');
 | 
			
		||||
        return versionOutput.toLowerCase().includes('gnu tar');
 | 
			
		||||
        return versionOutput.toLowerCase().includes('gnu tar') ? io.which('tar') : '';
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
exports.isGnuTarInstalled = isGnuTarInstalled;
 | 
			
		||||
exports.getGnuTarPathOnWindows = getGnuTarPathOnWindows;
 | 
			
		||||
function assertDefined(name, value) {
 | 
			
		||||
    if (value === undefined) {
 | 
			
		||||
        throw Error(`Expected ${name} but value was undefiend`);
 | 
			
		||||
@ -3440,7 +3439,6 @@ const crypto = __importStar(__webpack_require__(417));
 | 
			
		||||
const fs = __importStar(__webpack_require__(747));
 | 
			
		||||
const url_1 = __webpack_require__(835);
 | 
			
		||||
const utils = __importStar(__webpack_require__(15));
 | 
			
		||||
const constants_1 = __webpack_require__(931);
 | 
			
		||||
const downloadUtils_1 = __webpack_require__(251);
 | 
			
		||||
const options_1 = __webpack_require__(538);
 | 
			
		||||
const requestUtils_1 = __webpack_require__(899);
 | 
			
		||||
@ -3470,10 +3468,17 @@ function createHttpClient() {
 | 
			
		||||
    const bearerCredentialHandler = new auth_1.BearerCredentialHandler(token);
 | 
			
		||||
    return new http_client_1.HttpClient('actions/cache', [bearerCredentialHandler], getRequestOptions());
 | 
			
		||||
}
 | 
			
		||||
function getCacheVersion(paths, compressionMethod) {
 | 
			
		||||
    const components = paths.concat(!compressionMethod || compressionMethod === constants_1.CompressionMethod.Gzip
 | 
			
		||||
        ? []
 | 
			
		||||
        : [compressionMethod]);
 | 
			
		||||
function getCacheVersion(paths, compressionMethod, enableCrossOsArchive = false) {
 | 
			
		||||
    const components = paths;
 | 
			
		||||
    // Add compression method to cache version to restore
 | 
			
		||||
    // compressed cache as per compression method
 | 
			
		||||
    if (compressionMethod) {
 | 
			
		||||
        components.push(compressionMethod);
 | 
			
		||||
    }
 | 
			
		||||
    // Only check for windows platforms if enableCrossOsArchive is false
 | 
			
		||||
    if (process.platform === 'win32' && !enableCrossOsArchive) {
 | 
			
		||||
        components.push('windows-only');
 | 
			
		||||
    }
 | 
			
		||||
    // Add salt to cache version to support breaking changes in cache entry
 | 
			
		||||
    components.push(versionSalt);
 | 
			
		||||
    return crypto
 | 
			
		||||
@ -3485,10 +3490,15 @@ exports.getCacheVersion = getCacheVersion;
 | 
			
		||||
function getCacheEntry(keys, paths, options) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        const httpClient = createHttpClient();
 | 
			
		||||
        const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod);
 | 
			
		||||
        const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod, options === null || options === void 0 ? void 0 : options.enableCrossOsArchive);
 | 
			
		||||
        const resource = `cache?keys=${encodeURIComponent(keys.join(','))}&version=${version}`;
 | 
			
		||||
        const response = yield requestUtils_1.retryTypedResponse('getCacheEntry', () => __awaiter(this, void 0, void 0, function* () { return httpClient.getJson(getCacheApiUrl(resource)); }));
 | 
			
		||||
        // Cache not found
 | 
			
		||||
        if (response.statusCode === 204) {
 | 
			
		||||
            // List cache for primary key only if cache miss occurs
 | 
			
		||||
            if (core.isDebug()) {
 | 
			
		||||
                yield printCachesListForDiagnostics(keys[0], httpClient, version);
 | 
			
		||||
            }
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
        if (!requestUtils_1.isSuccessStatusCode(response.statusCode)) {
 | 
			
		||||
@ -3497,6 +3507,7 @@ function getCacheEntry(keys, paths, options) {
 | 
			
		||||
        const cacheResult = response.result;
 | 
			
		||||
        const cacheDownloadUrl = cacheResult === null || cacheResult === void 0 ? void 0 : cacheResult.archiveLocation;
 | 
			
		||||
        if (!cacheDownloadUrl) {
 | 
			
		||||
            // Cache achiveLocation not found. This should never happen, and hence bail out.
 | 
			
		||||
            throw new Error('Cache not found.');
 | 
			
		||||
        }
 | 
			
		||||
        core.setSecret(cacheDownloadUrl);
 | 
			
		||||
@ -3506,6 +3517,22 @@ function getCacheEntry(keys, paths, options) {
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
exports.getCacheEntry = getCacheEntry;
 | 
			
		||||
function printCachesListForDiagnostics(key, httpClient, version) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        const resource = `caches?key=${encodeURIComponent(key)}`;
 | 
			
		||||
        const response = yield requestUtils_1.retryTypedResponse('listCache', () => __awaiter(this, void 0, void 0, function* () { return httpClient.getJson(getCacheApiUrl(resource)); }));
 | 
			
		||||
        if (response.statusCode === 200) {
 | 
			
		||||
            const cacheListResult = response.result;
 | 
			
		||||
            const totalCount = cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.totalCount;
 | 
			
		||||
            if (totalCount && totalCount > 0) {
 | 
			
		||||
                core.debug(`No matching cache found for cache key '${key}', version '${version} and scope ${process.env['GITHUB_REF']}. There exist one or more cache(s) with similar key but they have different version or scope. See more info on cache matching here: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key \nOther caches with similar key:`);
 | 
			
		||||
                for (const cacheEntry of (cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.artifactCaches) || []) {
 | 
			
		||||
                    core.debug(`Cache Key: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheKey}, Cache Version: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheVersion}, Cache Scope: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.scope}, Cache Created: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.creationTime}`);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
function downloadCache(archiveLocation, archivePath, options) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        const archiveUrl = new url_1.URL(archiveLocation);
 | 
			
		||||
@ -3526,7 +3553,7 @@ exports.downloadCache = downloadCache;
 | 
			
		||||
function reserveCache(key, paths, options) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        const httpClient = createHttpClient();
 | 
			
		||||
        const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod);
 | 
			
		||||
        const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod, options === null || options === void 0 ? void 0 : options.enableCrossOsArchive);
 | 
			
		||||
        const reserveCacheRequest = {
 | 
			
		||||
            key,
 | 
			
		||||
            version,
 | 
			
		||||
@ -5006,7 +5033,8 @@ var Inputs;
 | 
			
		||||
    Inputs["Key"] = "key";
 | 
			
		||||
    Inputs["Path"] = "path";
 | 
			
		||||
    Inputs["RestoreKeys"] = "restore-keys";
 | 
			
		||||
    Inputs["UploadChunkSize"] = "upload-chunk-size"; // Input for cache, save action
 | 
			
		||||
    Inputs["UploadChunkSize"] = "upload-chunk-size";
 | 
			
		||||
    Inputs["EnableCrossOsArchive"] = "enableCrossOsArchive"; // Input for cache, restore, save action
 | 
			
		||||
})(Inputs = exports.Inputs || (exports.Inputs = {}));
 | 
			
		||||
var Outputs;
 | 
			
		||||
(function (Outputs) {
 | 
			
		||||
@ -38160,27 +38188,27 @@ var __importStar = (this && this.__importStar) || function (mod) {
 | 
			
		||||
};
 | 
			
		||||
Object.defineProperty(exports, "__esModule", { value: true });
 | 
			
		||||
const exec_1 = __webpack_require__(986);
 | 
			
		||||
const core_1 = __webpack_require__(470);
 | 
			
		||||
const io = __importStar(__webpack_require__(1));
 | 
			
		||||
const fs_1 = __webpack_require__(747);
 | 
			
		||||
const path = __importStar(__webpack_require__(622));
 | 
			
		||||
const utils = __importStar(__webpack_require__(15));
 | 
			
		||||
const constants_1 = __webpack_require__(931);
 | 
			
		||||
const IS_WINDOWS = process.platform === 'win32';
 | 
			
		||||
function getTarPath(args, compressionMethod) {
 | 
			
		||||
core_1.exportVariable('MSYS', 'winsymlinks:nativestrict');
 | 
			
		||||
// Returns tar path and type: BSD or GNU
 | 
			
		||||
function getTarPath() {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        switch (process.platform) {
 | 
			
		||||
            case 'win32': {
 | 
			
		||||
                const systemTar = `${process.env['windir']}\\System32\\tar.exe`;
 | 
			
		||||
                if (compressionMethod !== constants_1.CompressionMethod.Gzip) {
 | 
			
		||||
                    // We only use zstandard compression on windows when gnu tar is installed due to
 | 
			
		||||
                    // a bug with compressing large files with bsdtar + zstd
 | 
			
		||||
                    args.push('--force-local');
 | 
			
		||||
                const gnuTar = yield utils.getGnuTarPathOnWindows();
 | 
			
		||||
                const systemTar = constants_1.SystemTarPathOnWindows;
 | 
			
		||||
                if (gnuTar) {
 | 
			
		||||
                    // Use GNUtar as default on windows
 | 
			
		||||
                    return { path: gnuTar, type: constants_1.ArchiveToolType.GNU };
 | 
			
		||||
                }
 | 
			
		||||
                else if (fs_1.existsSync(systemTar)) {
 | 
			
		||||
                    return systemTar;
 | 
			
		||||
                }
 | 
			
		||||
                else if (yield utils.isGnuTarInstalled()) {
 | 
			
		||||
                    args.push('--force-local');
 | 
			
		||||
                    return { path: systemTar, type: constants_1.ArchiveToolType.BSD };
 | 
			
		||||
                }
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
@ -38188,25 +38216,92 @@ function getTarPath(args, compressionMethod) {
 | 
			
		||||
                const gnuTar = yield io.which('gtar', false);
 | 
			
		||||
                if (gnuTar) {
 | 
			
		||||
                    // fix permission denied errors when extracting BSD tar archive with GNU tar - https://github.com/actions/cache/issues/527
 | 
			
		||||
                    args.push('--delay-directory-restore');
 | 
			
		||||
                    return gnuTar;
 | 
			
		||||
                    return { path: gnuTar, type: constants_1.ArchiveToolType.GNU };
 | 
			
		||||
                }
 | 
			
		||||
                else {
 | 
			
		||||
                    return {
 | 
			
		||||
                        path: yield io.which('tar', true),
 | 
			
		||||
                        type: constants_1.ArchiveToolType.BSD
 | 
			
		||||
                    };
 | 
			
		||||
                }
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
            default:
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
        return yield io.which('tar', true);
 | 
			
		||||
        // Default assumption is GNU tar is present in path
 | 
			
		||||
        return {
 | 
			
		||||
            path: yield io.which('tar', true),
 | 
			
		||||
            type: constants_1.ArchiveToolType.GNU
 | 
			
		||||
        };
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
function execTar(args, compressionMethod, cwd) {
 | 
			
		||||
// Return arguments for tar as per tarPath, compressionMethod, method type and os
 | 
			
		||||
function getTarArgs(tarPath, compressionMethod, type, archivePath = '') {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        try {
 | 
			
		||||
            yield exec_1.exec(`"${yield getTarPath(args, compressionMethod)}"`, args, { cwd });
 | 
			
		||||
        const args = [`"${tarPath.path}"`];
 | 
			
		||||
        const cacheFileName = utils.getCacheFileName(compressionMethod);
 | 
			
		||||
        const tarFile = 'cache.tar';
 | 
			
		||||
        const workingDirectory = getWorkingDirectory();
 | 
			
		||||
        // Speficic args for BSD tar on windows for workaround
 | 
			
		||||
        const BSD_TAR_ZSTD = tarPath.type === constants_1.ArchiveToolType.BSD &&
 | 
			
		||||
            compressionMethod !== constants_1.CompressionMethod.Gzip &&
 | 
			
		||||
            IS_WINDOWS;
 | 
			
		||||
        // Method specific args
 | 
			
		||||
        switch (type) {
 | 
			
		||||
            case 'create':
 | 
			
		||||
                args.push('--posix', '-cf', BSD_TAR_ZSTD
 | 
			
		||||
                    ? tarFile
 | 
			
		||||
                    : cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '--exclude', BSD_TAR_ZSTD
 | 
			
		||||
                    ? tarFile
 | 
			
		||||
                    : cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '-P', '-C', workingDirectory.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '--files-from', constants_1.ManifestFilename);
 | 
			
		||||
                break;
 | 
			
		||||
            case 'extract':
 | 
			
		||||
                args.push('-xf', BSD_TAR_ZSTD
 | 
			
		||||
                    ? tarFile
 | 
			
		||||
                    : archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '-P', '-C', workingDirectory.replace(new RegExp(`\\${path.sep}`, 'g'), '/'));
 | 
			
		||||
                break;
 | 
			
		||||
            case 'list':
 | 
			
		||||
                args.push('-tf', BSD_TAR_ZSTD
 | 
			
		||||
                    ? tarFile
 | 
			
		||||
                    : archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '-P');
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
        catch (error) {
 | 
			
		||||
            throw new Error(`Tar failed with error: ${error === null || error === void 0 ? void 0 : error.message}`);
 | 
			
		||||
        // Platform specific args
 | 
			
		||||
        if (tarPath.type === constants_1.ArchiveToolType.GNU) {
 | 
			
		||||
            switch (process.platform) {
 | 
			
		||||
                case 'win32':
 | 
			
		||||
                    args.push('--force-local');
 | 
			
		||||
                    break;
 | 
			
		||||
                case 'darwin':
 | 
			
		||||
                    args.push('--delay-directory-restore');
 | 
			
		||||
                    break;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return args;
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
// Returns commands to run tar and compression program
 | 
			
		||||
function getCommands(compressionMethod, type, archivePath = '') {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        let args;
 | 
			
		||||
        const tarPath = yield getTarPath();
 | 
			
		||||
        const tarArgs = yield getTarArgs(tarPath, compressionMethod, type, archivePath);
 | 
			
		||||
        const compressionArgs = type !== 'create'
 | 
			
		||||
            ? yield getDecompressionProgram(tarPath, compressionMethod, archivePath)
 | 
			
		||||
            : yield getCompressionProgram(tarPath, compressionMethod);
 | 
			
		||||
        const BSD_TAR_ZSTD = tarPath.type === constants_1.ArchiveToolType.BSD &&
 | 
			
		||||
            compressionMethod !== constants_1.CompressionMethod.Gzip &&
 | 
			
		||||
            IS_WINDOWS;
 | 
			
		||||
        if (BSD_TAR_ZSTD && type !== 'create') {
 | 
			
		||||
            args = [[...compressionArgs].join(' '), [...tarArgs].join(' ')];
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            args = [[...tarArgs].join(' '), [...compressionArgs].join(' ')];
 | 
			
		||||
        }
 | 
			
		||||
        if (BSD_TAR_ZSTD) {
 | 
			
		||||
            return args;
 | 
			
		||||
        }
 | 
			
		||||
        return [args.join(' ')];
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
function getWorkingDirectory() {
 | 
			
		||||
@ -38214,91 +38309,116 @@ function getWorkingDirectory() {
 | 
			
		||||
    return (_a = process.env['GITHUB_WORKSPACE']) !== null && _a !== void 0 ? _a : process.cwd();
 | 
			
		||||
}
 | 
			
		||||
// Common function for extractTar and listTar to get the compression method
 | 
			
		||||
function getCompressionProgram(compressionMethod) {
 | 
			
		||||
function getDecompressionProgram(tarPath, compressionMethod, archivePath) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        // -d: Decompress.
 | 
			
		||||
        // unzstd is equivalent to 'zstd -d'
 | 
			
		||||
        // --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit.
 | 
			
		||||
        // Using 30 here because we also support 32-bit self-hosted runners.
 | 
			
		||||
        const BSD_TAR_ZSTD = tarPath.type === constants_1.ArchiveToolType.BSD &&
 | 
			
		||||
            compressionMethod !== constants_1.CompressionMethod.Gzip &&
 | 
			
		||||
            IS_WINDOWS;
 | 
			
		||||
        switch (compressionMethod) {
 | 
			
		||||
            case constants_1.CompressionMethod.Zstd:
 | 
			
		||||
            return [
 | 
			
		||||
                return BSD_TAR_ZSTD
 | 
			
		||||
                    ? [
 | 
			
		||||
                        'zstd -d --long=30 --force -o',
 | 
			
		||||
                        constants_1.TarFilename,
 | 
			
		||||
                        archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/')
 | 
			
		||||
                    ]
 | 
			
		||||
                    : [
 | 
			
		||||
                        '--use-compress-program',
 | 
			
		||||
                IS_WINDOWS ? 'zstd -d --long=30' : 'unzstd --long=30'
 | 
			
		||||
                        IS_WINDOWS ? '"zstd -d --long=30"' : 'unzstd --long=30'
 | 
			
		||||
                    ];
 | 
			
		||||
            case constants_1.CompressionMethod.ZstdWithoutLong:
 | 
			
		||||
            return ['--use-compress-program', IS_WINDOWS ? 'zstd -d' : 'unzstd'];
 | 
			
		||||
                return BSD_TAR_ZSTD
 | 
			
		||||
                    ? [
 | 
			
		||||
                        'zstd -d --force -o',
 | 
			
		||||
                        constants_1.TarFilename,
 | 
			
		||||
                        archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/')
 | 
			
		||||
                    ]
 | 
			
		||||
                    : ['--use-compress-program', IS_WINDOWS ? '"zstd -d"' : 'unzstd'];
 | 
			
		||||
            default:
 | 
			
		||||
                return ['-z'];
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
// Used for creating the archive
 | 
			
		||||
// -T#: Compress using # working thread. If # is 0, attempt to detect and use the number of physical CPU cores.
 | 
			
		||||
// zstdmt is equivalent to 'zstd -T0'
 | 
			
		||||
// --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit.
 | 
			
		||||
// Using 30 here because we also support 32-bit self-hosted runners.
 | 
			
		||||
// Long range mode is added to zstd in v1.3.2 release, so we will not use --long in older version of zstd.
 | 
			
		||||
function getCompressionProgram(tarPath, compressionMethod) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        const cacheFileName = utils.getCacheFileName(compressionMethod);
 | 
			
		||||
        const BSD_TAR_ZSTD = tarPath.type === constants_1.ArchiveToolType.BSD &&
 | 
			
		||||
            compressionMethod !== constants_1.CompressionMethod.Gzip &&
 | 
			
		||||
            IS_WINDOWS;
 | 
			
		||||
        switch (compressionMethod) {
 | 
			
		||||
            case constants_1.CompressionMethod.Zstd:
 | 
			
		||||
                return BSD_TAR_ZSTD
 | 
			
		||||
                    ? [
 | 
			
		||||
                        'zstd -T0 --long=30 --force -o',
 | 
			
		||||
                        cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
 | 
			
		||||
                        constants_1.TarFilename
 | 
			
		||||
                    ]
 | 
			
		||||
                    : [
 | 
			
		||||
                        '--use-compress-program',
 | 
			
		||||
                        IS_WINDOWS ? '"zstd -T0 --long=30"' : 'zstdmt --long=30'
 | 
			
		||||
                    ];
 | 
			
		||||
            case constants_1.CompressionMethod.ZstdWithoutLong:
 | 
			
		||||
                return BSD_TAR_ZSTD
 | 
			
		||||
                    ? [
 | 
			
		||||
                        'zstd -T0 --force -o',
 | 
			
		||||
                        cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
 | 
			
		||||
                        constants_1.TarFilename
 | 
			
		||||
                    ]
 | 
			
		||||
                    : ['--use-compress-program', IS_WINDOWS ? '"zstd -T0"' : 'zstdmt'];
 | 
			
		||||
            default:
 | 
			
		||||
                return ['-z'];
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
// Executes all commands as separate processes
 | 
			
		||||
function execCommands(commands, cwd) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        for (const command of commands) {
 | 
			
		||||
            try {
 | 
			
		||||
                yield exec_1.exec(command, undefined, { cwd });
 | 
			
		||||
            }
 | 
			
		||||
            catch (error) {
 | 
			
		||||
                throw new Error(`${command.split(' ')[0]} failed with error: ${error === null || error === void 0 ? void 0 : error.message}`);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
// List the contents of a tar
 | 
			
		||||
function listTar(archivePath, compressionMethod) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        const args = [
 | 
			
		||||
            ...getCompressionProgram(compressionMethod),
 | 
			
		||||
            '-tf',
 | 
			
		||||
            archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
 | 
			
		||||
            '-P'
 | 
			
		||||
        ];
 | 
			
		||||
        yield execTar(args, compressionMethod);
 | 
			
		||||
        const commands = yield getCommands(compressionMethod, 'list', archivePath);
 | 
			
		||||
        yield execCommands(commands);
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
exports.listTar = listTar;
 | 
			
		||||
// Extract a tar
 | 
			
		||||
function extractTar(archivePath, compressionMethod) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        // Create directory to extract tar into
 | 
			
		||||
        const workingDirectory = getWorkingDirectory();
 | 
			
		||||
        yield io.mkdirP(workingDirectory);
 | 
			
		||||
        const args = [
 | 
			
		||||
            ...getCompressionProgram(compressionMethod),
 | 
			
		||||
            '-xf',
 | 
			
		||||
            archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
 | 
			
		||||
            '-P',
 | 
			
		||||
            '-C',
 | 
			
		||||
            workingDirectory.replace(new RegExp(`\\${path.sep}`, 'g'), '/')
 | 
			
		||||
        ];
 | 
			
		||||
        yield execTar(args, compressionMethod);
 | 
			
		||||
        const commands = yield getCommands(compressionMethod, 'extract', archivePath);
 | 
			
		||||
        yield execCommands(commands);
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
exports.extractTar = extractTar;
 | 
			
		||||
// Create a tar
 | 
			
		||||
function createTar(archiveFolder, sourceDirectories, compressionMethod) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        // Write source directories to manifest.txt to avoid command length limits
 | 
			
		||||
        const manifestFilename = 'manifest.txt';
 | 
			
		||||
        const cacheFileName = utils.getCacheFileName(compressionMethod);
 | 
			
		||||
        fs_1.writeFileSync(path.join(archiveFolder, manifestFilename), sourceDirectories.join('\n'));
 | 
			
		||||
        const workingDirectory = getWorkingDirectory();
 | 
			
		||||
        // -T#: Compress using # working thread. If # is 0, attempt to detect and use the number of physical CPU cores.
 | 
			
		||||
        // zstdmt is equivalent to 'zstd -T0'
 | 
			
		||||
        // --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit.
 | 
			
		||||
        // Using 30 here because we also support 32-bit self-hosted runners.
 | 
			
		||||
        // Long range mode is added to zstd in v1.3.2 release, so we will not use --long in older version of zstd.
 | 
			
		||||
        function getCompressionProgram() {
 | 
			
		||||
            switch (compressionMethod) {
 | 
			
		||||
                case constants_1.CompressionMethod.Zstd:
 | 
			
		||||
                    return [
 | 
			
		||||
                        '--use-compress-program',
 | 
			
		||||
                        IS_WINDOWS ? 'zstd -T0 --long=30' : 'zstdmt --long=30'
 | 
			
		||||
                    ];
 | 
			
		||||
                case constants_1.CompressionMethod.ZstdWithoutLong:
 | 
			
		||||
                    return ['--use-compress-program', IS_WINDOWS ? 'zstd -T0' : 'zstdmt'];
 | 
			
		||||
                default:
 | 
			
		||||
                    return ['-z'];
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        const args = [
 | 
			
		||||
            '--posix',
 | 
			
		||||
            ...getCompressionProgram(),
 | 
			
		||||
            '-cf',
 | 
			
		||||
            cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
 | 
			
		||||
            '--exclude',
 | 
			
		||||
            cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
 | 
			
		||||
            '-P',
 | 
			
		||||
            '-C',
 | 
			
		||||
            workingDirectory.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
 | 
			
		||||
            '--files-from',
 | 
			
		||||
            manifestFilename
 | 
			
		||||
        ];
 | 
			
		||||
        yield execTar(args, compressionMethod, archiveFolder);
 | 
			
		||||
        fs_1.writeFileSync(path.join(archiveFolder, constants_1.ManifestFilename), sourceDirectories.join('\n'));
 | 
			
		||||
        const commands = yield getCommands(compressionMethod, 'create');
 | 
			
		||||
        yield execCommands(commands, archiveFolder);
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
exports.createTar = createTar;
 | 
			
		||||
@ -38533,7 +38653,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
 | 
			
		||||
    return result;
 | 
			
		||||
};
 | 
			
		||||
Object.defineProperty(exports, "__esModule", { value: true });
 | 
			
		||||
exports.isCacheFeatureAvailable = exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.isExactKeyMatch = exports.isGhes = void 0;
 | 
			
		||||
exports.isCacheFeatureAvailable = exports.getInputAsBool = exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.isExactKeyMatch = exports.isGhes = void 0;
 | 
			
		||||
const cache = __importStar(__webpack_require__(692));
 | 
			
		||||
const core = __importStar(__webpack_require__(470));
 | 
			
		||||
const constants_1 = __webpack_require__(196);
 | 
			
		||||
@ -38576,6 +38696,11 @@ function getInputAsInt(name, options) {
 | 
			
		||||
    return value;
 | 
			
		||||
}
 | 
			
		||||
exports.getInputAsInt = getInputAsInt;
 | 
			
		||||
function getInputAsBool(name, options) {
 | 
			
		||||
    const result = core.getInput(name, options);
 | 
			
		||||
    return result.toLowerCase() === "true";
 | 
			
		||||
}
 | 
			
		||||
exports.getInputAsBool = getInputAsBool;
 | 
			
		||||
function isCacheFeatureAvailable() {
 | 
			
		||||
    if (cache.isFeatureAvailable()) {
 | 
			
		||||
        return true;
 | 
			
		||||
@ -41055,9 +41180,8 @@ function saveImpl(stateProvider) {
 | 
			
		||||
            const cachePaths = utils.getInputAsArray(constants_1.Inputs.Path, {
 | 
			
		||||
                required: true
 | 
			
		||||
            });
 | 
			
		||||
            cacheId = yield cache.saveCache(cachePaths, primaryKey, {
 | 
			
		||||
                uploadChunkSize: utils.getInputAsInt(constants_1.Inputs.UploadChunkSize)
 | 
			
		||||
            });
 | 
			
		||||
            const enableCrossOsArchive = utils.getInputAsBool(constants_1.Inputs.EnableCrossOsArchive);
 | 
			
		||||
            cacheId = yield cache.saveCache(cachePaths, primaryKey, { uploadChunkSize: utils.getInputAsInt(constants_1.Inputs.UploadChunkSize) }, enableCrossOsArchive);
 | 
			
		||||
            if (cacheId != -1) {
 | 
			
		||||
                core.info(`Cache saved with key: ${primaryKey}`);
 | 
			
		||||
            }
 | 
			
		||||
@ -47243,9 +47367,10 @@ exports.isFeatureAvailable = isFeatureAvailable;
 | 
			
		||||
 * @param primaryKey an explicit key for restoring the cache
 | 
			
		||||
 * @param restoreKeys an optional ordered list of keys to use for restoring the cache if no cache hit occurred for key
 | 
			
		||||
 * @param downloadOptions cache download options
 | 
			
		||||
 * @param enableCrossOsArchive an optional boolean enabled to restore on windows any cache created on any platform
 | 
			
		||||
 * @returns string returns the key for the cache hit, otherwise returns undefined
 | 
			
		||||
 */
 | 
			
		||||
function restoreCache(paths, primaryKey, restoreKeys, options) {
 | 
			
		||||
function restoreCache(paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        checkPaths(paths);
 | 
			
		||||
        restoreKeys = restoreKeys || [];
 | 
			
		||||
@ -47263,7 +47388,8 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
 | 
			
		||||
        try {
 | 
			
		||||
            // path are needed to compute version
 | 
			
		||||
            const cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, {
 | 
			
		||||
                compressionMethod
 | 
			
		||||
                compressionMethod,
 | 
			
		||||
                enableCrossOsArchive
 | 
			
		||||
            });
 | 
			
		||||
            if (!(cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.archiveLocation)) {
 | 
			
		||||
                // Cache not found
 | 
			
		||||
@ -47310,10 +47436,11 @@ exports.restoreCache = restoreCache;
 | 
			
		||||
 *
 | 
			
		||||
 * @param paths a list of file paths to be cached
 | 
			
		||||
 * @param key an explicit key for restoring the cache
 | 
			
		||||
 * @param enableCrossOsArchive an optional boolean enabled to save cache on windows which could be restored on any platform
 | 
			
		||||
 * @param options cache upload options
 | 
			
		||||
 * @returns number returns cacheId if the cache was saved successfully and throws an error if save fails
 | 
			
		||||
 */
 | 
			
		||||
function saveCache(paths, key, options) {
 | 
			
		||||
function saveCache(paths, key, options, enableCrossOsArchive = false) {
 | 
			
		||||
    var _a, _b, _c, _d, _e;
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        checkPaths(paths);
 | 
			
		||||
@ -47344,6 +47471,7 @@ function saveCache(paths, key, options) {
 | 
			
		||||
            core.debug('Reserving Cache');
 | 
			
		||||
            const reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, {
 | 
			
		||||
                compressionMethod,
 | 
			
		||||
                enableCrossOsArchive,
 | 
			
		||||
                cacheSize: archiveFileSize
 | 
			
		||||
            });
 | 
			
		||||
            if ((_a = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.result) === null || _a === void 0 ? void 0 : _a.cacheId) {
 | 
			
		||||
@ -53270,6 +53398,11 @@ var CompressionMethod;
 | 
			
		||||
    CompressionMethod["ZstdWithoutLong"] = "zstd-without-long";
 | 
			
		||||
    CompressionMethod["Zstd"] = "zstd";
 | 
			
		||||
})(CompressionMethod = exports.CompressionMethod || (exports.CompressionMethod = {}));
 | 
			
		||||
var ArchiveToolType;
 | 
			
		||||
(function (ArchiveToolType) {
 | 
			
		||||
    ArchiveToolType["GNU"] = "gnu";
 | 
			
		||||
    ArchiveToolType["BSD"] = "bsd";
 | 
			
		||||
})(ArchiveToolType = exports.ArchiveToolType || (exports.ArchiveToolType = {}));
 | 
			
		||||
// The default number of retry attempts.
 | 
			
		||||
exports.DefaultRetryAttempts = 2;
 | 
			
		||||
// The default delay in milliseconds between retry attempts.
 | 
			
		||||
@ -53278,6 +53411,12 @@ exports.DefaultRetryDelay = 5000;
 | 
			
		||||
// over the socket during this period, the socket is destroyed and the download
 | 
			
		||||
// is aborted.
 | 
			
		||||
exports.SocketTimeout = 5000;
 | 
			
		||||
// The default path of GNUtar on hosted Windows runners
 | 
			
		||||
exports.GnuTarPathOnWindows = `${process.env['PROGRAMFILES']}\\Git\\usr\\bin\\tar.exe`;
 | 
			
		||||
// The default path of BSDtar on hosted Windows runners
 | 
			
		||||
exports.SystemTarPathOnWindows = `${process.env['SYSTEMDRIVE']}\\Windows\\System32\\tar.exe`;
 | 
			
		||||
exports.TarFilename = 'cache.tar';
 | 
			
		||||
exports.ManifestFilename = 'manifest.txt';
 | 
			
		||||
//# sourceMappingURL=constants.js.map
 | 
			
		||||
 | 
			
		||||
/***/ }),
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										333
									
								
								dist/save/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										333
									
								
								dist/save/index.js
									
									
									
									
										vendored
									
									
								
							@ -1177,10 +1177,6 @@ function getVersion(app) {
 | 
			
		||||
// Use zstandard if possible to maximize cache performance
 | 
			
		||||
function getCompressionMethod() {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        if (process.platform === 'win32' && !(yield isGnuTarInstalled())) {
 | 
			
		||||
            // Disable zstd due to bug https://github.com/actions/cache/issues/301
 | 
			
		||||
            return constants_1.CompressionMethod.Gzip;
 | 
			
		||||
        }
 | 
			
		||||
        const versionOutput = yield getVersion('zstd');
 | 
			
		||||
        const version = semver.clean(versionOutput);
 | 
			
		||||
        if (!versionOutput.toLowerCase().includes('zstd command line interface')) {
 | 
			
		||||
@ -1204,13 +1200,16 @@ function getCacheFileName(compressionMethod) {
 | 
			
		||||
        : constants_1.CacheFilename.Zstd;
 | 
			
		||||
}
 | 
			
		||||
exports.getCacheFileName = getCacheFileName;
 | 
			
		||||
function isGnuTarInstalled() {
 | 
			
		||||
function getGnuTarPathOnWindows() {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        if (fs.existsSync(constants_1.GnuTarPathOnWindows)) {
 | 
			
		||||
            return constants_1.GnuTarPathOnWindows;
 | 
			
		||||
        }
 | 
			
		||||
        const versionOutput = yield getVersion('tar');
 | 
			
		||||
        return versionOutput.toLowerCase().includes('gnu tar');
 | 
			
		||||
        return versionOutput.toLowerCase().includes('gnu tar') ? io.which('tar') : '';
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
exports.isGnuTarInstalled = isGnuTarInstalled;
 | 
			
		||||
exports.getGnuTarPathOnWindows = getGnuTarPathOnWindows;
 | 
			
		||||
function assertDefined(name, value) {
 | 
			
		||||
    if (value === undefined) {
 | 
			
		||||
        throw Error(`Expected ${name} but value was undefiend`);
 | 
			
		||||
@ -3384,7 +3383,6 @@ const crypto = __importStar(__webpack_require__(417));
 | 
			
		||||
const fs = __importStar(__webpack_require__(747));
 | 
			
		||||
const url_1 = __webpack_require__(835);
 | 
			
		||||
const utils = __importStar(__webpack_require__(15));
 | 
			
		||||
const constants_1 = __webpack_require__(931);
 | 
			
		||||
const downloadUtils_1 = __webpack_require__(251);
 | 
			
		||||
const options_1 = __webpack_require__(538);
 | 
			
		||||
const requestUtils_1 = __webpack_require__(899);
 | 
			
		||||
@ -3414,10 +3412,17 @@ function createHttpClient() {
 | 
			
		||||
    const bearerCredentialHandler = new auth_1.BearerCredentialHandler(token);
 | 
			
		||||
    return new http_client_1.HttpClient('actions/cache', [bearerCredentialHandler], getRequestOptions());
 | 
			
		||||
}
 | 
			
		||||
function getCacheVersion(paths, compressionMethod) {
 | 
			
		||||
    const components = paths.concat(!compressionMethod || compressionMethod === constants_1.CompressionMethod.Gzip
 | 
			
		||||
        ? []
 | 
			
		||||
        : [compressionMethod]);
 | 
			
		||||
function getCacheVersion(paths, compressionMethod, enableCrossOsArchive = false) {
 | 
			
		||||
    const components = paths;
 | 
			
		||||
    // Add compression method to cache version to restore
 | 
			
		||||
    // compressed cache as per compression method
 | 
			
		||||
    if (compressionMethod) {
 | 
			
		||||
        components.push(compressionMethod);
 | 
			
		||||
    }
 | 
			
		||||
    // Only check for windows platforms if enableCrossOsArchive is false
 | 
			
		||||
    if (process.platform === 'win32' && !enableCrossOsArchive) {
 | 
			
		||||
        components.push('windows-only');
 | 
			
		||||
    }
 | 
			
		||||
    // Add salt to cache version to support breaking changes in cache entry
 | 
			
		||||
    components.push(versionSalt);
 | 
			
		||||
    return crypto
 | 
			
		||||
@ -3429,10 +3434,15 @@ exports.getCacheVersion = getCacheVersion;
 | 
			
		||||
function getCacheEntry(keys, paths, options) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        const httpClient = createHttpClient();
 | 
			
		||||
        const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod);
 | 
			
		||||
        const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod, options === null || options === void 0 ? void 0 : options.enableCrossOsArchive);
 | 
			
		||||
        const resource = `cache?keys=${encodeURIComponent(keys.join(','))}&version=${version}`;
 | 
			
		||||
        const response = yield requestUtils_1.retryTypedResponse('getCacheEntry', () => __awaiter(this, void 0, void 0, function* () { return httpClient.getJson(getCacheApiUrl(resource)); }));
 | 
			
		||||
        // Cache not found
 | 
			
		||||
        if (response.statusCode === 204) {
 | 
			
		||||
            // List cache for primary key only if cache miss occurs
 | 
			
		||||
            if (core.isDebug()) {
 | 
			
		||||
                yield printCachesListForDiagnostics(keys[0], httpClient, version);
 | 
			
		||||
            }
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
        if (!requestUtils_1.isSuccessStatusCode(response.statusCode)) {
 | 
			
		||||
@ -3441,6 +3451,7 @@ function getCacheEntry(keys, paths, options) {
 | 
			
		||||
        const cacheResult = response.result;
 | 
			
		||||
        const cacheDownloadUrl = cacheResult === null || cacheResult === void 0 ? void 0 : cacheResult.archiveLocation;
 | 
			
		||||
        if (!cacheDownloadUrl) {
 | 
			
		||||
            // Cache achiveLocation not found. This should never happen, and hence bail out.
 | 
			
		||||
            throw new Error('Cache not found.');
 | 
			
		||||
        }
 | 
			
		||||
        core.setSecret(cacheDownloadUrl);
 | 
			
		||||
@ -3450,6 +3461,22 @@ function getCacheEntry(keys, paths, options) {
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
exports.getCacheEntry = getCacheEntry;
 | 
			
		||||
function printCachesListForDiagnostics(key, httpClient, version) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        const resource = `caches?key=${encodeURIComponent(key)}`;
 | 
			
		||||
        const response = yield requestUtils_1.retryTypedResponse('listCache', () => __awaiter(this, void 0, void 0, function* () { return httpClient.getJson(getCacheApiUrl(resource)); }));
 | 
			
		||||
        if (response.statusCode === 200) {
 | 
			
		||||
            const cacheListResult = response.result;
 | 
			
		||||
            const totalCount = cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.totalCount;
 | 
			
		||||
            if (totalCount && totalCount > 0) {
 | 
			
		||||
                core.debug(`No matching cache found for cache key '${key}', version '${version} and scope ${process.env['GITHUB_REF']}. There exist one or more cache(s) with similar key but they have different version or scope. See more info on cache matching here: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key \nOther caches with similar key:`);
 | 
			
		||||
                for (const cacheEntry of (cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.artifactCaches) || []) {
 | 
			
		||||
                    core.debug(`Cache Key: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheKey}, Cache Version: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheVersion}, Cache Scope: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.scope}, Cache Created: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.creationTime}`);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
function downloadCache(archiveLocation, archivePath, options) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        const archiveUrl = new url_1.URL(archiveLocation);
 | 
			
		||||
@ -3470,7 +3497,7 @@ exports.downloadCache = downloadCache;
 | 
			
		||||
function reserveCache(key, paths, options) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        const httpClient = createHttpClient();
 | 
			
		||||
        const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod);
 | 
			
		||||
        const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod, options === null || options === void 0 ? void 0 : options.enableCrossOsArchive);
 | 
			
		||||
        const reserveCacheRequest = {
 | 
			
		||||
            key,
 | 
			
		||||
            version,
 | 
			
		||||
@ -4950,7 +4977,8 @@ var Inputs;
 | 
			
		||||
    Inputs["Key"] = "key";
 | 
			
		||||
    Inputs["Path"] = "path";
 | 
			
		||||
    Inputs["RestoreKeys"] = "restore-keys";
 | 
			
		||||
    Inputs["UploadChunkSize"] = "upload-chunk-size"; // Input for cache, save action
 | 
			
		||||
    Inputs["UploadChunkSize"] = "upload-chunk-size";
 | 
			
		||||
    Inputs["EnableCrossOsArchive"] = "enableCrossOsArchive"; // Input for cache, restore, save action
 | 
			
		||||
})(Inputs = exports.Inputs || (exports.Inputs = {}));
 | 
			
		||||
var Outputs;
 | 
			
		||||
(function (Outputs) {
 | 
			
		||||
@ -38104,27 +38132,27 @@ var __importStar = (this && this.__importStar) || function (mod) {
 | 
			
		||||
};
 | 
			
		||||
Object.defineProperty(exports, "__esModule", { value: true });
 | 
			
		||||
const exec_1 = __webpack_require__(986);
 | 
			
		||||
const core_1 = __webpack_require__(470);
 | 
			
		||||
const io = __importStar(__webpack_require__(1));
 | 
			
		||||
const fs_1 = __webpack_require__(747);
 | 
			
		||||
const path = __importStar(__webpack_require__(622));
 | 
			
		||||
const utils = __importStar(__webpack_require__(15));
 | 
			
		||||
const constants_1 = __webpack_require__(931);
 | 
			
		||||
const IS_WINDOWS = process.platform === 'win32';
 | 
			
		||||
function getTarPath(args, compressionMethod) {
 | 
			
		||||
core_1.exportVariable('MSYS', 'winsymlinks:nativestrict');
 | 
			
		||||
// Returns tar path and type: BSD or GNU
 | 
			
		||||
function getTarPath() {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        switch (process.platform) {
 | 
			
		||||
            case 'win32': {
 | 
			
		||||
                const systemTar = `${process.env['windir']}\\System32\\tar.exe`;
 | 
			
		||||
                if (compressionMethod !== constants_1.CompressionMethod.Gzip) {
 | 
			
		||||
                    // We only use zstandard compression on windows when gnu tar is installed due to
 | 
			
		||||
                    // a bug with compressing large files with bsdtar + zstd
 | 
			
		||||
                    args.push('--force-local');
 | 
			
		||||
                const gnuTar = yield utils.getGnuTarPathOnWindows();
 | 
			
		||||
                const systemTar = constants_1.SystemTarPathOnWindows;
 | 
			
		||||
                if (gnuTar) {
 | 
			
		||||
                    // Use GNUtar as default on windows
 | 
			
		||||
                    return { path: gnuTar, type: constants_1.ArchiveToolType.GNU };
 | 
			
		||||
                }
 | 
			
		||||
                else if (fs_1.existsSync(systemTar)) {
 | 
			
		||||
                    return systemTar;
 | 
			
		||||
                }
 | 
			
		||||
                else if (yield utils.isGnuTarInstalled()) {
 | 
			
		||||
                    args.push('--force-local');
 | 
			
		||||
                    return { path: systemTar, type: constants_1.ArchiveToolType.BSD };
 | 
			
		||||
                }
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
@ -38132,25 +38160,92 @@ function getTarPath(args, compressionMethod) {
 | 
			
		||||
                const gnuTar = yield io.which('gtar', false);
 | 
			
		||||
                if (gnuTar) {
 | 
			
		||||
                    // fix permission denied errors when extracting BSD tar archive with GNU tar - https://github.com/actions/cache/issues/527
 | 
			
		||||
                    args.push('--delay-directory-restore');
 | 
			
		||||
                    return gnuTar;
 | 
			
		||||
                    return { path: gnuTar, type: constants_1.ArchiveToolType.GNU };
 | 
			
		||||
                }
 | 
			
		||||
                else {
 | 
			
		||||
                    return {
 | 
			
		||||
                        path: yield io.which('tar', true),
 | 
			
		||||
                        type: constants_1.ArchiveToolType.BSD
 | 
			
		||||
                    };
 | 
			
		||||
                }
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
            default:
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
        return yield io.which('tar', true);
 | 
			
		||||
        // Default assumption is GNU tar is present in path
 | 
			
		||||
        return {
 | 
			
		||||
            path: yield io.which('tar', true),
 | 
			
		||||
            type: constants_1.ArchiveToolType.GNU
 | 
			
		||||
        };
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
function execTar(args, compressionMethod, cwd) {
 | 
			
		||||
// Return arguments for tar as per tarPath, compressionMethod, method type and os
 | 
			
		||||
function getTarArgs(tarPath, compressionMethod, type, archivePath = '') {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        try {
 | 
			
		||||
            yield exec_1.exec(`"${yield getTarPath(args, compressionMethod)}"`, args, { cwd });
 | 
			
		||||
        const args = [`"${tarPath.path}"`];
 | 
			
		||||
        const cacheFileName = utils.getCacheFileName(compressionMethod);
 | 
			
		||||
        const tarFile = 'cache.tar';
 | 
			
		||||
        const workingDirectory = getWorkingDirectory();
 | 
			
		||||
        // Speficic args for BSD tar on windows for workaround
 | 
			
		||||
        const BSD_TAR_ZSTD = tarPath.type === constants_1.ArchiveToolType.BSD &&
 | 
			
		||||
            compressionMethod !== constants_1.CompressionMethod.Gzip &&
 | 
			
		||||
            IS_WINDOWS;
 | 
			
		||||
        // Method specific args
 | 
			
		||||
        switch (type) {
 | 
			
		||||
            case 'create':
 | 
			
		||||
                args.push('--posix', '-cf', BSD_TAR_ZSTD
 | 
			
		||||
                    ? tarFile
 | 
			
		||||
                    : cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '--exclude', BSD_TAR_ZSTD
 | 
			
		||||
                    ? tarFile
 | 
			
		||||
                    : cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '-P', '-C', workingDirectory.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '--files-from', constants_1.ManifestFilename);
 | 
			
		||||
                break;
 | 
			
		||||
            case 'extract':
 | 
			
		||||
                args.push('-xf', BSD_TAR_ZSTD
 | 
			
		||||
                    ? tarFile
 | 
			
		||||
                    : archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '-P', '-C', workingDirectory.replace(new RegExp(`\\${path.sep}`, 'g'), '/'));
 | 
			
		||||
                break;
 | 
			
		||||
            case 'list':
 | 
			
		||||
                args.push('-tf', BSD_TAR_ZSTD
 | 
			
		||||
                    ? tarFile
 | 
			
		||||
                    : archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '-P');
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
        catch (error) {
 | 
			
		||||
            throw new Error(`Tar failed with error: ${error === null || error === void 0 ? void 0 : error.message}`);
 | 
			
		||||
        // Platform specific args
 | 
			
		||||
        if (tarPath.type === constants_1.ArchiveToolType.GNU) {
 | 
			
		||||
            switch (process.platform) {
 | 
			
		||||
                case 'win32':
 | 
			
		||||
                    args.push('--force-local');
 | 
			
		||||
                    break;
 | 
			
		||||
                case 'darwin':
 | 
			
		||||
                    args.push('--delay-directory-restore');
 | 
			
		||||
                    break;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return args;
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
// Returns commands to run tar and compression program
 | 
			
		||||
function getCommands(compressionMethod, type, archivePath = '') {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        let args;
 | 
			
		||||
        const tarPath = yield getTarPath();
 | 
			
		||||
        const tarArgs = yield getTarArgs(tarPath, compressionMethod, type, archivePath);
 | 
			
		||||
        const compressionArgs = type !== 'create'
 | 
			
		||||
            ? yield getDecompressionProgram(tarPath, compressionMethod, archivePath)
 | 
			
		||||
            : yield getCompressionProgram(tarPath, compressionMethod);
 | 
			
		||||
        const BSD_TAR_ZSTD = tarPath.type === constants_1.ArchiveToolType.BSD &&
 | 
			
		||||
            compressionMethod !== constants_1.CompressionMethod.Gzip &&
 | 
			
		||||
            IS_WINDOWS;
 | 
			
		||||
        if (BSD_TAR_ZSTD && type !== 'create') {
 | 
			
		||||
            args = [[...compressionArgs].join(' '), [...tarArgs].join(' ')];
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            args = [[...tarArgs].join(' '), [...compressionArgs].join(' ')];
 | 
			
		||||
        }
 | 
			
		||||
        if (BSD_TAR_ZSTD) {
 | 
			
		||||
            return args;
 | 
			
		||||
        }
 | 
			
		||||
        return [args.join(' ')];
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
function getWorkingDirectory() {
 | 
			
		||||
@ -38158,91 +38253,116 @@ function getWorkingDirectory() {
 | 
			
		||||
    return (_a = process.env['GITHUB_WORKSPACE']) !== null && _a !== void 0 ? _a : process.cwd();
 | 
			
		||||
}
 | 
			
		||||
// Common function for extractTar and listTar to get the compression method
 | 
			
		||||
function getCompressionProgram(compressionMethod) {
 | 
			
		||||
function getDecompressionProgram(tarPath, compressionMethod, archivePath) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        // -d: Decompress.
 | 
			
		||||
        // unzstd is equivalent to 'zstd -d'
 | 
			
		||||
        // --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit.
 | 
			
		||||
        // Using 30 here because we also support 32-bit self-hosted runners.
 | 
			
		||||
        const BSD_TAR_ZSTD = tarPath.type === constants_1.ArchiveToolType.BSD &&
 | 
			
		||||
            compressionMethod !== constants_1.CompressionMethod.Gzip &&
 | 
			
		||||
            IS_WINDOWS;
 | 
			
		||||
        switch (compressionMethod) {
 | 
			
		||||
            case constants_1.CompressionMethod.Zstd:
 | 
			
		||||
            return [
 | 
			
		||||
                return BSD_TAR_ZSTD
 | 
			
		||||
                    ? [
 | 
			
		||||
                        'zstd -d --long=30 --force -o',
 | 
			
		||||
                        constants_1.TarFilename,
 | 
			
		||||
                        archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/')
 | 
			
		||||
                    ]
 | 
			
		||||
                    : [
 | 
			
		||||
                        '--use-compress-program',
 | 
			
		||||
                IS_WINDOWS ? 'zstd -d --long=30' : 'unzstd --long=30'
 | 
			
		||||
                        IS_WINDOWS ? '"zstd -d --long=30"' : 'unzstd --long=30'
 | 
			
		||||
                    ];
 | 
			
		||||
            case constants_1.CompressionMethod.ZstdWithoutLong:
 | 
			
		||||
            return ['--use-compress-program', IS_WINDOWS ? 'zstd -d' : 'unzstd'];
 | 
			
		||||
                return BSD_TAR_ZSTD
 | 
			
		||||
                    ? [
 | 
			
		||||
                        'zstd -d --force -o',
 | 
			
		||||
                        constants_1.TarFilename,
 | 
			
		||||
                        archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/')
 | 
			
		||||
                    ]
 | 
			
		||||
                    : ['--use-compress-program', IS_WINDOWS ? '"zstd -d"' : 'unzstd'];
 | 
			
		||||
            default:
 | 
			
		||||
                return ['-z'];
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
// Used for creating the archive
 | 
			
		||||
// -T#: Compress using # working thread. If # is 0, attempt to detect and use the number of physical CPU cores.
 | 
			
		||||
// zstdmt is equivalent to 'zstd -T0'
 | 
			
		||||
// --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit.
 | 
			
		||||
// Using 30 here because we also support 32-bit self-hosted runners.
 | 
			
		||||
// Long range mode is added to zstd in v1.3.2 release, so we will not use --long in older version of zstd.
 | 
			
		||||
function getCompressionProgram(tarPath, compressionMethod) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        const cacheFileName = utils.getCacheFileName(compressionMethod);
 | 
			
		||||
        const BSD_TAR_ZSTD = tarPath.type === constants_1.ArchiveToolType.BSD &&
 | 
			
		||||
            compressionMethod !== constants_1.CompressionMethod.Gzip &&
 | 
			
		||||
            IS_WINDOWS;
 | 
			
		||||
        switch (compressionMethod) {
 | 
			
		||||
            case constants_1.CompressionMethod.Zstd:
 | 
			
		||||
                return BSD_TAR_ZSTD
 | 
			
		||||
                    ? [
 | 
			
		||||
                        'zstd -T0 --long=30 --force -o',
 | 
			
		||||
                        cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
 | 
			
		||||
                        constants_1.TarFilename
 | 
			
		||||
                    ]
 | 
			
		||||
                    : [
 | 
			
		||||
                        '--use-compress-program',
 | 
			
		||||
                        IS_WINDOWS ? '"zstd -T0 --long=30"' : 'zstdmt --long=30'
 | 
			
		||||
                    ];
 | 
			
		||||
            case constants_1.CompressionMethod.ZstdWithoutLong:
 | 
			
		||||
                return BSD_TAR_ZSTD
 | 
			
		||||
                    ? [
 | 
			
		||||
                        'zstd -T0 --force -o',
 | 
			
		||||
                        cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
 | 
			
		||||
                        constants_1.TarFilename
 | 
			
		||||
                    ]
 | 
			
		||||
                    : ['--use-compress-program', IS_WINDOWS ? '"zstd -T0"' : 'zstdmt'];
 | 
			
		||||
            default:
 | 
			
		||||
                return ['-z'];
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
// Executes all commands as separate processes
 | 
			
		||||
function execCommands(commands, cwd) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        for (const command of commands) {
 | 
			
		||||
            try {
 | 
			
		||||
                yield exec_1.exec(command, undefined, { cwd });
 | 
			
		||||
            }
 | 
			
		||||
            catch (error) {
 | 
			
		||||
                throw new Error(`${command.split(' ')[0]} failed with error: ${error === null || error === void 0 ? void 0 : error.message}`);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
// List the contents of a tar
 | 
			
		||||
function listTar(archivePath, compressionMethod) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        const args = [
 | 
			
		||||
            ...getCompressionProgram(compressionMethod),
 | 
			
		||||
            '-tf',
 | 
			
		||||
            archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
 | 
			
		||||
            '-P'
 | 
			
		||||
        ];
 | 
			
		||||
        yield execTar(args, compressionMethod);
 | 
			
		||||
        const commands = yield getCommands(compressionMethod, 'list', archivePath);
 | 
			
		||||
        yield execCommands(commands);
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
exports.listTar = listTar;
 | 
			
		||||
// Extract a tar
 | 
			
		||||
function extractTar(archivePath, compressionMethod) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        // Create directory to extract tar into
 | 
			
		||||
        const workingDirectory = getWorkingDirectory();
 | 
			
		||||
        yield io.mkdirP(workingDirectory);
 | 
			
		||||
        const args = [
 | 
			
		||||
            ...getCompressionProgram(compressionMethod),
 | 
			
		||||
            '-xf',
 | 
			
		||||
            archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
 | 
			
		||||
            '-P',
 | 
			
		||||
            '-C',
 | 
			
		||||
            workingDirectory.replace(new RegExp(`\\${path.sep}`, 'g'), '/')
 | 
			
		||||
        ];
 | 
			
		||||
        yield execTar(args, compressionMethod);
 | 
			
		||||
        const commands = yield getCommands(compressionMethod, 'extract', archivePath);
 | 
			
		||||
        yield execCommands(commands);
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
exports.extractTar = extractTar;
 | 
			
		||||
// Create a tar
 | 
			
		||||
function createTar(archiveFolder, sourceDirectories, compressionMethod) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        // Write source directories to manifest.txt to avoid command length limits
 | 
			
		||||
        const manifestFilename = 'manifest.txt';
 | 
			
		||||
        const cacheFileName = utils.getCacheFileName(compressionMethod);
 | 
			
		||||
        fs_1.writeFileSync(path.join(archiveFolder, manifestFilename), sourceDirectories.join('\n'));
 | 
			
		||||
        const workingDirectory = getWorkingDirectory();
 | 
			
		||||
        // -T#: Compress using # working thread. If # is 0, attempt to detect and use the number of physical CPU cores.
 | 
			
		||||
        // zstdmt is equivalent to 'zstd -T0'
 | 
			
		||||
        // --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit.
 | 
			
		||||
        // Using 30 here because we also support 32-bit self-hosted runners.
 | 
			
		||||
        // Long range mode is added to zstd in v1.3.2 release, so we will not use --long in older version of zstd.
 | 
			
		||||
        function getCompressionProgram() {
 | 
			
		||||
            switch (compressionMethod) {
 | 
			
		||||
                case constants_1.CompressionMethod.Zstd:
 | 
			
		||||
                    return [
 | 
			
		||||
                        '--use-compress-program',
 | 
			
		||||
                        IS_WINDOWS ? 'zstd -T0 --long=30' : 'zstdmt --long=30'
 | 
			
		||||
                    ];
 | 
			
		||||
                case constants_1.CompressionMethod.ZstdWithoutLong:
 | 
			
		||||
                    return ['--use-compress-program', IS_WINDOWS ? 'zstd -T0' : 'zstdmt'];
 | 
			
		||||
                default:
 | 
			
		||||
                    return ['-z'];
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        const args = [
 | 
			
		||||
            '--posix',
 | 
			
		||||
            ...getCompressionProgram(),
 | 
			
		||||
            '-cf',
 | 
			
		||||
            cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
 | 
			
		||||
            '--exclude',
 | 
			
		||||
            cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
 | 
			
		||||
            '-P',
 | 
			
		||||
            '-C',
 | 
			
		||||
            workingDirectory.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
 | 
			
		||||
            '--files-from',
 | 
			
		||||
            manifestFilename
 | 
			
		||||
        ];
 | 
			
		||||
        yield execTar(args, compressionMethod, archiveFolder);
 | 
			
		||||
        fs_1.writeFileSync(path.join(archiveFolder, constants_1.ManifestFilename), sourceDirectories.join('\n'));
 | 
			
		||||
        const commands = yield getCommands(compressionMethod, 'create');
 | 
			
		||||
        yield execCommands(commands, archiveFolder);
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
exports.createTar = createTar;
 | 
			
		||||
@ -38477,7 +38597,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
 | 
			
		||||
    return result;
 | 
			
		||||
};
 | 
			
		||||
Object.defineProperty(exports, "__esModule", { value: true });
 | 
			
		||||
exports.isCacheFeatureAvailable = exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.isExactKeyMatch = exports.isGhes = void 0;
 | 
			
		||||
exports.isCacheFeatureAvailable = exports.getInputAsBool = exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.isExactKeyMatch = exports.isGhes = void 0;
 | 
			
		||||
const cache = __importStar(__webpack_require__(692));
 | 
			
		||||
const core = __importStar(__webpack_require__(470));
 | 
			
		||||
const constants_1 = __webpack_require__(196);
 | 
			
		||||
@ -38520,6 +38640,11 @@ function getInputAsInt(name, options) {
 | 
			
		||||
    return value;
 | 
			
		||||
}
 | 
			
		||||
exports.getInputAsInt = getInputAsInt;
 | 
			
		||||
function getInputAsBool(name, options) {
 | 
			
		||||
    const result = core.getInput(name, options);
 | 
			
		||||
    return result.toLowerCase() === "true";
 | 
			
		||||
}
 | 
			
		||||
exports.getInputAsBool = getInputAsBool;
 | 
			
		||||
function isCacheFeatureAvailable() {
 | 
			
		||||
    if (cache.isFeatureAvailable()) {
 | 
			
		||||
        return true;
 | 
			
		||||
@ -40999,9 +41124,8 @@ function saveImpl(stateProvider) {
 | 
			
		||||
            const cachePaths = utils.getInputAsArray(constants_1.Inputs.Path, {
 | 
			
		||||
                required: true
 | 
			
		||||
            });
 | 
			
		||||
            cacheId = yield cache.saveCache(cachePaths, primaryKey, {
 | 
			
		||||
                uploadChunkSize: utils.getInputAsInt(constants_1.Inputs.UploadChunkSize)
 | 
			
		||||
            });
 | 
			
		||||
            const enableCrossOsArchive = utils.getInputAsBool(constants_1.Inputs.EnableCrossOsArchive);
 | 
			
		||||
            cacheId = yield cache.saveCache(cachePaths, primaryKey, { uploadChunkSize: utils.getInputAsInt(constants_1.Inputs.UploadChunkSize) }, enableCrossOsArchive);
 | 
			
		||||
            if (cacheId != -1) {
 | 
			
		||||
                core.info(`Cache saved with key: ${primaryKey}`);
 | 
			
		||||
            }
 | 
			
		||||
@ -47216,9 +47340,10 @@ exports.isFeatureAvailable = isFeatureAvailable;
 | 
			
		||||
 * @param primaryKey an explicit key for restoring the cache
 | 
			
		||||
 * @param restoreKeys an optional ordered list of keys to use for restoring the cache if no cache hit occurred for key
 | 
			
		||||
 * @param downloadOptions cache download options
 | 
			
		||||
 * @param enableCrossOsArchive an optional boolean enabled to restore on windows any cache created on any platform
 | 
			
		||||
 * @returns string returns the key for the cache hit, otherwise returns undefined
 | 
			
		||||
 */
 | 
			
		||||
function restoreCache(paths, primaryKey, restoreKeys, options) {
 | 
			
		||||
function restoreCache(paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        checkPaths(paths);
 | 
			
		||||
        restoreKeys = restoreKeys || [];
 | 
			
		||||
@ -47236,7 +47361,8 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
 | 
			
		||||
        try {
 | 
			
		||||
            // path are needed to compute version
 | 
			
		||||
            const cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, {
 | 
			
		||||
                compressionMethod
 | 
			
		||||
                compressionMethod,
 | 
			
		||||
                enableCrossOsArchive
 | 
			
		||||
            });
 | 
			
		||||
            if (!(cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.archiveLocation)) {
 | 
			
		||||
                // Cache not found
 | 
			
		||||
@ -47283,10 +47409,11 @@ exports.restoreCache = restoreCache;
 | 
			
		||||
 *
 | 
			
		||||
 * @param paths a list of file paths to be cached
 | 
			
		||||
 * @param key an explicit key for restoring the cache
 | 
			
		||||
 * @param enableCrossOsArchive an optional boolean enabled to save cache on windows which could be restored on any platform
 | 
			
		||||
 * @param options cache upload options
 | 
			
		||||
 * @returns number returns cacheId if the cache was saved successfully and throws an error if save fails
 | 
			
		||||
 */
 | 
			
		||||
function saveCache(paths, key, options) {
 | 
			
		||||
function saveCache(paths, key, options, enableCrossOsArchive = false) {
 | 
			
		||||
    var _a, _b, _c, _d, _e;
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        checkPaths(paths);
 | 
			
		||||
@ -47317,6 +47444,7 @@ function saveCache(paths, key, options) {
 | 
			
		||||
            core.debug('Reserving Cache');
 | 
			
		||||
            const reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, {
 | 
			
		||||
                compressionMethod,
 | 
			
		||||
                enableCrossOsArchive,
 | 
			
		||||
                cacheSize: archiveFileSize
 | 
			
		||||
            });
 | 
			
		||||
            if ((_a = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.result) === null || _a === void 0 ? void 0 : _a.cacheId) {
 | 
			
		||||
@ -53243,6 +53371,11 @@ var CompressionMethod;
 | 
			
		||||
    CompressionMethod["ZstdWithoutLong"] = "zstd-without-long";
 | 
			
		||||
    CompressionMethod["Zstd"] = "zstd";
 | 
			
		||||
})(CompressionMethod = exports.CompressionMethod || (exports.CompressionMethod = {}));
 | 
			
		||||
var ArchiveToolType;
 | 
			
		||||
(function (ArchiveToolType) {
 | 
			
		||||
    ArchiveToolType["GNU"] = "gnu";
 | 
			
		||||
    ArchiveToolType["BSD"] = "bsd";
 | 
			
		||||
})(ArchiveToolType = exports.ArchiveToolType || (exports.ArchiveToolType = {}));
 | 
			
		||||
// The default number of retry attempts.
 | 
			
		||||
exports.DefaultRetryAttempts = 2;
 | 
			
		||||
// The default delay in milliseconds between retry attempts.
 | 
			
		||||
@ -53251,6 +53384,12 @@ exports.DefaultRetryDelay = 5000;
 | 
			
		||||
// over the socket during this period, the socket is destroyed and the download
 | 
			
		||||
// is aborted.
 | 
			
		||||
exports.SocketTimeout = 5000;
 | 
			
		||||
// The default path of GNUtar on hosted Windows runners
 | 
			
		||||
exports.GnuTarPathOnWindows = `${process.env['PROGRAMFILES']}\\Git\\usr\\bin\\tar.exe`;
 | 
			
		||||
// The default path of BSDtar on hosted Windows runners
 | 
			
		||||
exports.SystemTarPathOnWindows = `${process.env['SYSTEMDRIVE']}\\Windows\\System32\\tar.exe`;
 | 
			
		||||
exports.TarFilename = 'cache.tar';
 | 
			
		||||
exports.ManifestFilename = 'manifest.txt';
 | 
			
		||||
//# sourceMappingURL=constants.js.map
 | 
			
		||||
 | 
			
		||||
/***/ }),
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										16
									
								
								examples.md
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								examples.md
									
									
									
									
									
								
							@ -38,6 +38,7 @@
 | 
			
		||||
- [Swift, Objective-C - Carthage](#swift-objective-c---carthage)
 | 
			
		||||
- [Swift, Objective-C - CocoaPods](#swift-objective-c---cocoapods)
 | 
			
		||||
- [Swift - Swift Package Manager](#swift---swift-package-manager)
 | 
			
		||||
- [Swift - Mint](#swift---mint)
 | 
			
		||||
 | 
			
		||||
## C# - NuGet
 | 
			
		||||
 | 
			
		||||
@ -641,3 +642,18 @@ whenever possible:
 | 
			
		||||
    restore-keys: |
 | 
			
		||||
      ${{ runner.os }}-spm-
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## Swift - Mint
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
env:
 | 
			
		||||
  MINT_PATH: .mint/lib
 | 
			
		||||
  MINT_LINK_PATH: .mint/bin
 | 
			
		||||
steps:
 | 
			
		||||
  - uses: actions/cache@v3
 | 
			
		||||
    with:
 | 
			
		||||
      path: .mint
 | 
			
		||||
      key: ${{ runner.os }}-mint-${{ hashFiles('**/Mintfile') }}
 | 
			
		||||
      restore-keys: |
 | 
			
		||||
        ${{ runner.os }}-mint-
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										18
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										18
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							@ -1,15 +1,15 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "cache",
 | 
			
		||||
  "version": "3.2.0",
 | 
			
		||||
  "version": "3.2.2",
 | 
			
		||||
  "lockfileVersion": 2,
 | 
			
		||||
  "requires": true,
 | 
			
		||||
  "packages": {
 | 
			
		||||
    "": {
 | 
			
		||||
      "name": "cache",
 | 
			
		||||
      "version": "3.2.0",
 | 
			
		||||
      "version": "3.2.2",
 | 
			
		||||
      "license": "MIT",
 | 
			
		||||
      "dependencies": {
 | 
			
		||||
        "@actions/cache": "^3.0.6",
 | 
			
		||||
        "@actions/cache": "^3.1.2",
 | 
			
		||||
        "@actions/core": "^1.10.0",
 | 
			
		||||
        "@actions/exec": "^1.1.1",
 | 
			
		||||
        "@actions/io": "^1.1.2"
 | 
			
		||||
@ -36,9 +36,9 @@
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "node_modules/@actions/cache": {
 | 
			
		||||
      "version": "3.0.6",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.0.6.tgz",
 | 
			
		||||
      "integrity": "sha512-Tttit+nqmxgb2M5Ufj5p8Lwd+fx329HOTLzxMrY4aaaZqBzqetgWlEfszMyiXfX4cJML+bzLJbyD9rNYt8TJ8g==",
 | 
			
		||||
      "version": "3.1.2",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.1.2.tgz",
 | 
			
		||||
      "integrity": "sha512-3XeKcXIonfIbqvW7gPm/VLOhv1RHQ1dtTgSBCH6OUhCgSTii9bEVgu0PIms7UbLnXeMCKFzECfpbud8fJEvBbQ==",
 | 
			
		||||
      "dependencies": {
 | 
			
		||||
        "@actions/core": "^1.10.0",
 | 
			
		||||
        "@actions/exec": "^1.0.1",
 | 
			
		||||
@ -9722,9 +9722,9 @@
 | 
			
		||||
  },
 | 
			
		||||
  "dependencies": {
 | 
			
		||||
    "@actions/cache": {
 | 
			
		||||
      "version": "3.0.6",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.0.6.tgz",
 | 
			
		||||
      "integrity": "sha512-Tttit+nqmxgb2M5Ufj5p8Lwd+fx329HOTLzxMrY4aaaZqBzqetgWlEfszMyiXfX4cJML+bzLJbyD9rNYt8TJ8g==",
 | 
			
		||||
      "version": "3.1.2",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.1.2.tgz",
 | 
			
		||||
      "integrity": "sha512-3XeKcXIonfIbqvW7gPm/VLOhv1RHQ1dtTgSBCH6OUhCgSTii9bEVgu0PIms7UbLnXeMCKFzECfpbud8fJEvBbQ==",
 | 
			
		||||
      "requires": {
 | 
			
		||||
        "@actions/core": "^1.10.0",
 | 
			
		||||
        "@actions/exec": "^1.0.1",
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,6 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "cache",
 | 
			
		||||
  "version": "3.2.0",
 | 
			
		||||
  "version": "3.2.2",
 | 
			
		||||
  "private": true,
 | 
			
		||||
  "description": "Cache dependencies and build outputs",
 | 
			
		||||
  "main": "dist/restore/index.js",
 | 
			
		||||
@ -23,7 +23,7 @@
 | 
			
		||||
  "author": "GitHub",
 | 
			
		||||
  "license": "MIT",
 | 
			
		||||
  "dependencies": {
 | 
			
		||||
    "@actions/cache": "^3.0.6",
 | 
			
		||||
    "@actions/cache": "^3.1.2",
 | 
			
		||||
    "@actions/core": "^1.10.0",
 | 
			
		||||
    "@actions/exec": "^1.1.1",
 | 
			
		||||
    "@actions/io": "^1.1.2"
 | 
			
		||||
 | 
			
		||||
@ -120,7 +120,7 @@ steps:
 | 
			
		||||
 | 
			
		||||
#### Reusing primary key and restored key in the save action
 | 
			
		||||
 | 
			
		||||
Usually you may want to use same `key` in both actions/cache/restore` and `actions/cache/save` action. To achieve this, use `outputs` from the restore action to reuse the same primary key (or the key of the cache that was restored).
 | 
			
		||||
Usually you may want to use same `key` in both `actions/cache/restore` and `actions/cache/save` action. To achieve this, use `outputs` from the restore action to reuse the same primary key (or the key of the cache that was restored).
 | 
			
		||||
 | 
			
		||||
#### Using restore action outputs to make save action behave just like the cache action
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -11,6 +11,10 @@ inputs:
 | 
			
		||||
  restore-keys:
 | 
			
		||||
    description: 'An ordered list of keys to use for restoring stale cache if no cache hit occurred for key. Note `cache-hit` returns false in this case.'
 | 
			
		||||
    required: false
 | 
			
		||||
  enableCrossOsArchive:
 | 
			
		||||
    description: 'An optional boolean when enabled, allows windows runners to restore caches that were saved on other platforms'
 | 
			
		||||
    default: 'false'
 | 
			
		||||
    required: false
 | 
			
		||||
outputs:
 | 
			
		||||
  cache-hit:
 | 
			
		||||
    description: 'A boolean value to indicate an exact match was found for the primary key'
 | 
			
		||||
 | 
			
		||||
@ -54,7 +54,7 @@ Case 1: Where an user would want to reuse the key as it is
 | 
			
		||||
```yaml
 | 
			
		||||
uses: actions/cache/save@v3
 | 
			
		||||
with:
 | 
			
		||||
    key: steps.restore-cache.output.key
 | 
			
		||||
    key: ${{ steps.restore-cache.outputs.key }}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
Case 2: Where the user would want to re-evaluate the key
 | 
			
		||||
 | 
			
		||||
@ -11,6 +11,10 @@ inputs:
 | 
			
		||||
  upload-chunk-size:
 | 
			
		||||
    description: 'The chunk size used to split up large files during upload, in bytes'
 | 
			
		||||
    required: false
 | 
			
		||||
  enableCrossOsArchive:
 | 
			
		||||
    description: 'An optional boolean when enabled, allows windows runners to save caches that can be restored on other platforms'
 | 
			
		||||
    default: 'false'
 | 
			
		||||
    required: false
 | 
			
		||||
runs:
 | 
			
		||||
  using: 'node16'
 | 
			
		||||
  main: '../dist/save-only/index.js'
 | 
			
		||||
 | 
			
		||||
@ -2,7 +2,8 @@ export enum Inputs {
 | 
			
		||||
    Key = "key", // Input for cache, restore, save action
 | 
			
		||||
    Path = "path", // Input for cache, restore, save action
 | 
			
		||||
    RestoreKeys = "restore-keys", // Input for cache, restore action
 | 
			
		||||
    UploadChunkSize = "upload-chunk-size" // Input for cache, save action
 | 
			
		||||
    UploadChunkSize = "upload-chunk-size", // Input for cache, save action
 | 
			
		||||
    EnableCrossOsArchive = "enableCrossOsArchive" // Input for cache, restore, save action
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export enum Outputs {
 | 
			
		||||
 | 
			
		||||
@ -31,11 +31,16 @@ async function restoreImpl(
 | 
			
		||||
        const cachePaths = utils.getInputAsArray(Inputs.Path, {
 | 
			
		||||
            required: true
 | 
			
		||||
        });
 | 
			
		||||
        const enableCrossOsArchive = utils.getInputAsBool(
 | 
			
		||||
            Inputs.EnableCrossOsArchive
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        const cacheKey = await cache.restoreCache(
 | 
			
		||||
            cachePaths,
 | 
			
		||||
            primaryKey,
 | 
			
		||||
            restoreKeys
 | 
			
		||||
            restoreKeys,
 | 
			
		||||
            {},
 | 
			
		||||
            enableCrossOsArchive
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        if (!cacheKey) {
 | 
			
		||||
 | 
			
		||||
@ -52,9 +52,16 @@ async function saveImpl(stateProvider: IStateProvider): Promise<number | void> {
 | 
			
		||||
            required: true
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        cacheId = await cache.saveCache(cachePaths, primaryKey, {
 | 
			
		||||
            uploadChunkSize: utils.getInputAsInt(Inputs.UploadChunkSize)
 | 
			
		||||
        });
 | 
			
		||||
        const enableCrossOsArchive = utils.getInputAsBool(
 | 
			
		||||
            Inputs.EnableCrossOsArchive
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        cacheId = await cache.saveCache(
 | 
			
		||||
            cachePaths,
 | 
			
		||||
            primaryKey,
 | 
			
		||||
            { uploadChunkSize: utils.getInputAsInt(Inputs.UploadChunkSize) },
 | 
			
		||||
            enableCrossOsArchive
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        if (cacheId != -1) {
 | 
			
		||||
            core.info(`Cache saved with key: ${primaryKey}`);
 | 
			
		||||
 | 
			
		||||
@ -52,6 +52,14 @@ export function getInputAsInt(
 | 
			
		||||
    return value;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function getInputAsBool(
 | 
			
		||||
    name: string,
 | 
			
		||||
    options?: core.InputOptions
 | 
			
		||||
): boolean {
 | 
			
		||||
    const result = core.getInput(name, options);
 | 
			
		||||
    return result.toLowerCase() === "true";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function isCacheFeatureAvailable(): boolean {
 | 
			
		||||
    if (cache.isFeatureAvailable()) {
 | 
			
		||||
        return true;
 | 
			
		||||
 | 
			
		||||
@ -13,6 +13,7 @@ interface CacheInput {
 | 
			
		||||
    path: string;
 | 
			
		||||
    key: string;
 | 
			
		||||
    restoreKeys?: string[];
 | 
			
		||||
    enableCrossOsArchive?: boolean;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function setInputs(input: CacheInput): void {
 | 
			
		||||
@ -20,6 +21,11 @@ export function setInputs(input: CacheInput): void {
 | 
			
		||||
    setInput(Inputs.Key, input.key);
 | 
			
		||||
    input.restoreKeys &&
 | 
			
		||||
        setInput(Inputs.RestoreKeys, input.restoreKeys.join("\n"));
 | 
			
		||||
    input.enableCrossOsArchive !== undefined &&
 | 
			
		||||
        setInput(
 | 
			
		||||
            Inputs.EnableCrossOsArchive,
 | 
			
		||||
            input.enableCrossOsArchive.toString()
 | 
			
		||||
        );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function clearInputs(): void {
 | 
			
		||||
@ -27,4 +33,5 @@ export function clearInputs(): void {
 | 
			
		||||
    delete process.env[getInputName(Inputs.Key)];
 | 
			
		||||
    delete process.env[getInputName(Inputs.RestoreKeys)];
 | 
			
		||||
    delete process.env[getInputName(Inputs.UploadChunkSize)];
 | 
			
		||||
    delete process.env[getInputName(Inputs.EnableCrossOsArchive)];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user