Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
6349c3c
bsd + zstd fallback implementation
lvpx Nov 16, 2022
db3517f
bsd + zstd fallback implementation
lvpx Nov 16, 2022
27bf830
Fix tar operations
lvpx Nov 16, 2022
e9e146b
Add -v option for testing
lvpx Nov 16, 2022
5f89653
Fix order of args for tar
lvpx Nov 17, 2022
6f7397f
Add GNUtar as default on windows
Phantsure Nov 17, 2022
964682b
Fix test
Phantsure Nov 17, 2022
caadeee
Merge pull request #1239 from actions/phantsure/gnutar_windows
Phantsure Nov 17, 2022
ea98560
Fix tar tests
lvpx Nov 17, 2022
4fa5b7d
Fix lint issues
lvpx Nov 17, 2022
b3bd482
Fix windows gnutar test case
lvpx Nov 17, 2022
f9dfb05
Temporarily remove thhe condition that prevents zstd usage on windows…
lvpx Nov 17, 2022
54eb9b8
Address some comments and correct compression commands
Phantsure Nov 21, 2022
32b9582
Add windows bsdtar test
Phantsure Nov 21, 2022
32f5381
Fix windows test
Phantsure Nov 21, 2022
ffde3e4
Fix test
Phantsure Nov 22, 2022
2f73afa
Separate args
Phantsure Nov 23, 2022
39b7a86
Fix old tests
Phantsure Nov 23, 2022
1f33717
Add new tests
Phantsure Nov 23, 2022
187781e
Fix tests
Phantsure Nov 23, 2022
0822441
Fix lint test
Phantsure Nov 23, 2022
0fd856d
Refactor code
Phantsure Nov 28, 2022
34f0143
Address review comments
Phantsure Nov 29, 2022
2e5a517
Fix test
Phantsure Nov 29, 2022
424ae62
Fix tar test
Phantsure Nov 30, 2022
afbc5c0
Add await to async function calls
Phantsure Nov 30, 2022
8595831
Fix test
Phantsure Nov 30, 2022
785599d
Merge pull request #1237 from actions/pdotl/win-bsdtar-zstd
Phantsure Dec 1, 2022
c207fbd
Update for beta release
Phantsure Dec 1, 2022
61e6308
Fix audit issues
Phantsure Dec 5, 2022
de8fda6
Merge pull request #1244 from actions/phantsure/release-beta-1
Phantsure Dec 5, 2022
1dae855
Add fallback to gzip compression if cache not found
Phantsure Dec 6, 2022
c0085d7
Fix test
Phantsure Dec 6, 2022
d1094e1
Add test
Phantsure Dec 7, 2022
d79a09b
Address review comments
Phantsure Dec 7, 2022
27f9a7d
Revert Address review comments
Phantsure Dec 7, 2022
cb3dc49
Merge pull request #1249 from actions/phantsure/gzip-fallback
Phantsure Dec 8, 2022
8e39d78
Release 3.1.0-beta.2 cache package
Phantsure Dec 8, 2022
27d5148
Merge pull request #1257 from actions/phantsure/release-beta-2
Phantsure Dec 8, 2022
d31c2dd
Fix issues
Phantsure Dec 9, 2022
7a532d0
Reconfigure catch block
Phantsure Dec 9, 2022
0c23c38
Add debug logging for gzip fall back
Phantsure Dec 9, 2022
0690c10
Fix test
Phantsure Dec 9, 2022
d175a18
Add end to end test for cache using bsd on windows
Phantsure Dec 12, 2022
bbf5659
Fix test
Phantsure Dec 12, 2022
6bc5dc5
Fix test
Phantsure Dec 12, 2022
d7ae8cd
Fix tests
Phantsure Dec 12, 2022
cad074c
Add better comments
Phantsure Dec 12, 2022
e7e1984
Update packages/cache/src/internal/cacheHttpClient.ts
Phantsure Dec 12, 2022
2d3c79e
Address review comments
Phantsure Dec 12, 2022
8b695c1
Merge pull request #1260 from actions/phantsure/cache-testing
Phantsure Dec 12, 2022
0ff35ed
Update for new beta cache package release
Phantsure Dec 12, 2022
a20e7c1
Address bugbash issues
Phantsure Dec 21, 2022
8e69225
Fix tests
Phantsure Dec 21, 2022
c24b93f
Merge pull request #1279 from actions/phantsure/bug-bash
Phantsure Dec 22, 2022
3959b79
Merge branch 'releases/cache-v3-beta' of https://github.com/actions/t…
Phantsure Dec 22, 2022
fd47902
Merge branch 'main' of https://github.com/actions/toolkit into releas…
Phantsure Dec 22, 2022
c76b5b3
Release new actions/cache minor version
Phantsure Dec 22, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions .github/workflows/cache-windows-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: cache-windows-bsd-unit-tests
on:
push:
branches:
- main
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'

jobs:
build:
name: Build

runs-on: windows-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- shell: bash
run: |
rm "C:\Program Files\Git\usr\bin\tar.exe"

- name: Set Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x

# In order to save & restore cache from a shell script, certain env variables need to be set that are only available in the
# node context. This runs a local action that gets and sets the necessary env variables that are needed
- name: Set env variables
uses: ./packages/cache/__tests__/__fixtures__/

# Need root node_modules because certain npm packages like jest are configured for the entire repository and it won't be possible
# without these to just compile the cache package
- name: Install root npm packages
run: npm ci

- name: Compile cache package
run: |
npm ci
npm run tsc
working-directory: packages/cache

- name: Generate files in working directory
shell: bash
run: packages/cache/__tests__/create-cache-files.sh ${{ runner.os }} test-cache

- name: Generate files outside working directory
shell: bash
run: packages/cache/__tests__/create-cache-files.sh ${{ runner.os }} ~/test-cache

# We're using node -e to call the functions directly available in the @actions/cache package
- name: Save cache using saveCache()
run: |
node -e "Promise.resolve(require('./packages/cache/lib/cache').saveCache(['test-cache','~/test-cache'],'test-${{ runner.os }}-${{ github.run_id }}'))"

- name: Delete cache folders before restoring
shell: bash
run: |
rm -rf test-cache
rm -rf ~/test-cache

- name: Restore cache using restoreCache() with http-client
run: |
node -e "Promise.resolve(require('./packages/cache/lib/cache').restoreCache(['test-cache','~/test-cache'],'test-${{ runner.os }}-${{ github.run_id }}',[],{useAzureSdk: false}))"

- name: Verify cache restored with http-client
shell: bash
run: |
packages/cache/__tests__/verify-cache-files.sh ${{ runner.os }} test-cache
packages/cache/__tests__/verify-cache-files.sh ${{ runner.os }} ~/test-cache

- name: Delete cache folders before restoring
shell: bash
run: |
rm -rf test-cache
rm -rf ~/test-cache

- name: Restore cache using restoreCache() with Azure SDK
run: |
node -e "Promise.resolve(require('./packages/cache/lib/cache').restoreCache(['test-cache','~/test-cache'],'test-${{ runner.os }}-${{ github.run_id }}'))"

- name: Verify cache restored with Azure SDK
shell: bash
run: |
packages/cache/__tests__/verify-cache-files.sh ${{ runner.os }} test-cache
packages/cache/__tests__/verify-cache-files.sh ${{ runner.os }} ~/test-cache
14 changes: 14 additions & 0 deletions packages/cache/RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,17 @@

### 3.0.6
- Added `@azure/abort-controller` to dependencies to fix compatibility issue with ESM [#1208](https://github.com/actions/toolkit/issues/1208)

### 3.1.0-beta.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))

### 3.1.0-beta.2
- Added support for fallback to gzip to restore old caches on windows.

### 3.1.0-beta.3
- Bug Fixes for fallback to gzip to restore old caches on windows and bsdtar if gnutar is not available.

### 3.1.0
- Update actions/cache on windows to use gnu tar and zstd by default
- Update actions/cache on windows to fallback to bsdtar and zstd if gnu tar is not available.
- Added support for fallback to gzip to restore old caches on windows.
75 changes: 75 additions & 0 deletions packages/cache/__tests__/restoreCache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,81 @@ test('restore with gzip compressed cache found', async () => {
expect(getCompressionMock).toHaveBeenCalledTimes(1)
})

test('restore with zstd as default but gzip compressed cache found on windows', async () => {
if (process.platform === 'win32') {
const paths = ['node_modules']
const key = 'node-test'

const cacheEntry: ArtifactCacheEntry = {
cacheKey: key,
scope: 'refs/heads/main',
archiveLocation: 'www.actionscache.test/download'
}
const getCacheMock = jest.spyOn(cacheHttpClient, 'getCacheEntry')
getCacheMock
.mockImplementationOnce(async () => {
return Promise.resolve(null)
})
.mockImplementationOnce(async () => {
return Promise.resolve(cacheEntry)
})

const tempPath = '/foo/bar'

const createTempDirectoryMock = jest.spyOn(
cacheUtils,
'createTempDirectory'
)
createTempDirectoryMock.mockImplementation(async () => {
return Promise.resolve(tempPath)
})

const archivePath = path.join(tempPath, CacheFilename.Gzip)
const downloadCacheMock = jest.spyOn(cacheHttpClient, 'downloadCache')

const fileSize = 142
const getArchiveFileSizeInBytesMock = jest
.spyOn(cacheUtils, 'getArchiveFileSizeInBytes')
.mockReturnValue(fileSize)

const extractTarMock = jest.spyOn(tar, 'extractTar')
const unlinkFileMock = jest.spyOn(cacheUtils, 'unlinkFile')

const compression = CompressionMethod.Zstd
const getCompressionMock = jest
.spyOn(cacheUtils, 'getCompressionMethod')
.mockReturnValue(Promise.resolve(compression))

const cacheKey = await restoreCache(paths, key)

expect(cacheKey).toBe(key)
expect(getCacheMock).toHaveBeenNthCalledWith(1, [key], paths, {
compressionMethod: compression
})
expect(getCacheMock).toHaveBeenNthCalledWith(2, [key], paths, {
compressionMethod: CompressionMethod.Gzip
})
expect(createTempDirectoryMock).toHaveBeenCalledTimes(1)
expect(downloadCacheMock).toHaveBeenCalledWith(
cacheEntry.archiveLocation,
archivePath,
undefined
)
expect(getArchiveFileSizeInBytesMock).toHaveBeenCalledWith(archivePath)

expect(extractTarMock).toHaveBeenCalledTimes(1)
expect(extractTarMock).toHaveBeenCalledWith(
archivePath,
CompressionMethod.Gzip
)

expect(unlinkFileMock).toHaveBeenCalledTimes(1)
expect(unlinkFileMock).toHaveBeenCalledWith(archivePath)

expect(getCompressionMock).toHaveBeenCalledTimes(1)
}
})

test('restore with zstd compressed cache found', async () => {
const paths = ['node_modules']
const key = 'node-test'
Expand Down
Loading