Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync upstream #1935

Draft
wants to merge 57 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
c7fc05d
feat: adds warp-cache
prajjwaldimri Nov 17, 2023
84879c0
feat: modifies implementation of save, restore and introduces delete.
prajjwaldimri Nov 22, 2023
42f300a
fix: changes auth token env var name
prajjwaldimri Nov 28, 2023
0a21fc0
Merge pull request #1 from WarpBuilds/feat-add-warp-cache-action
prajjwaldimri Nov 28, 2023
bee057f
fix: changes baseURL to WARP_CACHE_URL
prajjwaldimri Nov 30, 2023
bf3e976
changes to 0.1.1
prajjwaldimri Nov 30, 2023
50d47a9
fix: changes to v0.2.0
prajjwaldimri Nov 30, 2023
6de528c
Merge branch 'actions:main' into main
prajjwaldimri Apr 8, 2024
1fc87f9
adds streaming download support
prajjwaldimri Apr 10, 2024
917853e
feat: adds streaming download and upload for gcs provider
prajjwaldimri Apr 11, 2024
9a8c6b2
modifies for warpcache
prajjwaldimri Apr 15, 2024
a090299
adds explicit token auth mechanism
prajjwaldimri Apr 15, 2024
a73dbad
changes to multipart download
prajjwaldimri Apr 15, 2024
5e3d03b
comments test
prajjwaldimri Apr 15, 2024
8400948
bumps version
prajjwaldimri Apr 15, 2024
d0787ac
adjusts chunk size
prajjwaldimri Apr 15, 2024
63c6089
moves to streaming for gcs
prajjwaldimri Apr 15, 2024
d989701
adds wget for streaming download
prajjwaldimri Apr 15, 2024
560aa2f
adds annotations to api requests
prajjwaldimri Apr 15, 2024
596cfa8
Merge pull request #2 from WarpBuilds/prajjwal-warp-245
prajjwaldimri Apr 15, 2024
868b4d3
changes isfeatureavailable logic
prajjwaldimri Apr 15, 2024
890c6b5
adds backup download method for streaming cache
prajjwaldimri May 17, 2024
c597cfa
better error capturing for all spawned commands
prajjwaldimri May 17, 2024
fc0eaea
bumps up version
prajjwaldimri May 17, 2024
ef01eae
adds crc32c validation for files
prajjwaldimri May 17, 2024
ac477ea
adds basic GCP download as fallback to multipart
prajjwaldimri May 17, 2024
e5677fb
bumps version
prajjwaldimri May 17, 2024
f120696
adds better info messages. reduces retry timeout for simple download.…
prajjwaldimri May 17, 2024
81041b2
sets auto retry to false
prajjwaldimri May 17, 2024
7efbd15
adds timeout to single thread download
prajjwaldimri May 17, 2024
a36bdba
adds custom timeout
prajjwaldimri May 17, 2024
cea490e
Merge pull request #3 from WarpBuilds/hotfix-gcs-backup-download
prajjwaldimri May 17, 2024
0fbee79
returns user defined key decoded key
prajjwaldimri Jun 2, 2024
8793dde
Merge pull request #4 from WarpBuilds/hotfix-cache-save
prajjwaldimri Jun 2, 2024
5670c35
adds streaming download for s3
prajjwaldimri Jun 3, 2024
57e2581
bumps to 1.1.13
prajjwaldimri Jun 3, 2024
b719dac
adds better error handling
prajjwaldimri Jun 3, 2024
d78ac4e
removes duplicate extraction
prajjwaldimri Jun 3, 2024
5ee82ff
Merge pull request #5 from WarpBuilds/feat-add-streaming-download-s3
prajjwaldimri Jun 3, 2024
86e2ed1
changes to multipart download for s3
prajjwaldimri Jun 4, 2024
6bdbdf3
Merge pull request #6 from WarpBuilds/fix-change-to-multipart-s3
prajjwaldimri Jun 5, 2024
1de6efd
fixes s3 return value
prajjwaldimri Jun 14, 2024
20d9767
Merge pull request #7 from WarpBuilds/hotfix-s3-cacheKeyResponse
prajjwaldimri Jun 14, 2024
67fd4c7
adds support for restoring across branches
prajjwaldimri Jun 20, 2024
cb3493c
adds base and default ref for PR case
prajjwaldimri Jun 20, 2024
84b7e68
changes restore refs to be set
prajjwaldimri Jun 20, 2024
0480697
Merge pull request #8 from WarpBuilds/prajjwal-warp-320
prajjwaldimri Jun 20, 2024
8a15609
adds concurrency limits
prajjwaldimri Jul 18, 2024
b0cca20
bumps version
prajjwaldimri Jul 18, 2024
e85e3f8
Merge pull request #9 from WarpBuilds/hotfix-concurrency-limits-uploads
prajjwaldimri Jul 18, 2024
07e783f
Merge pull request #10 from actions/main
prajjwaldimri Oct 21, 2024
665d790
adds azure support
prajjwaldimri Oct 23, 2024
d42be66
updates version
prajjwaldimri Oct 23, 2024
2409210
Merge pull request #11 from WarpBuilds/feat-azure-byoc
prajjwaldimri Oct 25, 2024
5b3af52
handles different types of events for branch restores
prajjwaldimri Nov 21, 2024
1d2f2a4
Merge pull request #12 from WarpBuilds/fix-merge-group-restores
prajjwaldimri Nov 21, 2024
bab449d
Merge remote-tracking branch 'upstream/main' into sync-upstream
suryaoruganti Jan 20, 2025
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
21 changes: 21 additions & 0 deletions packages/warp-cache/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Test.ts",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}/src/test.ts",
"preLaunchTask": "tsc: build - tsconfig.json",
"outFiles": [
"${workspaceFolder}/lib/**/*.js"
]
}
]
}
9 changes: 9 additions & 0 deletions packages/warp-cache/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The MIT License (MIT)

Copyright 2019 GitHub

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
51 changes: 51 additions & 0 deletions packages/warp-cache/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# `@actions/cache`

> Functions necessary for caching dependencies and build outputs to improve workflow execution time.

See ["Caching dependencies to speed up workflows"](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows) for how caching works.

Note that GitHub will remove any cache entries that have not been accessed in over 7 days. There is no limit on the number of caches you can store, but the total size of all caches in a repository is limited to 10 GB. If you exceed this limit, GitHub will save your cache but will begin evicting caches until the total size is less than 10 GB.

## Usage

This package is used by the v2+ versions of our first party cache action. You can find an example implementation in the cache repo [here](https://github.com/actions/cache).

#### Save Cache

Saves a cache containing the files in `paths` using the `key` provided. The files would be compressed using zstandard compression algorithm if zstd is installed, otherwise gzip is used. Function returns the cache id if the cache was saved succesfully and throws an error if cache upload fails.

```js
const cache = require('@actions/cache');
const paths = [
'node_modules',
'packages/*/node_modules/'
]
const key = 'npm-foobar-d5ea0750'
const cacheId = await cache.saveCache(paths, key)
```

#### Restore Cache

Restores a cache based on `key` and `restoreKeys` to the `paths` provided. Function returns the cache key for cache hit and returns undefined if cache not found.

```js
const cache = require('@actions/cache');
const paths = [
'node_modules',
'packages/*/node_modules/'
]
const key = 'npm-foobar-d5ea0750'
const restoreKeys = [
'npm-foobar-',
'npm-'
]
const cacheKey = await cache.restoreCache(paths, key, restoreKeys)
```

##### Cache segment restore timeout

A cache gets downloaded in multiple segments of fixed sizes (now `128MB` to fail-fast, previously `1GB` for a `32-bit` runner and `2GB` for a `64-bit` runner were used). Sometimes, a segment download gets stuck which causes the workflow job to be stuck forever and fail. Version `v3.0.4` of cache package introduces a segment download timeout. The segment download timeout will allow the segment download to get aborted and hence allow the job to proceed with a cache miss.

Default value of this timeout is 10 minutes (starting `v3.2.1` and higher, previously 60 minutes in versions between `v.3.0.4` and `v3.2.0`, both included) and can be customized by specifying an [environment variable](https://docs.github.com/en/actions/learn-github-actions/environment-variables) named `SEGMENT_DOWNLOAD_TIMEOUT_MINS` with timeout value in minutes.


166 changes: 166 additions & 0 deletions packages/warp-cache/RELEASES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
# @actions/cache Releases

### 0.1.0

- Initial release

### 0.2.0

- Fixes issues with the zstd compression algorithm on Windows and Ubuntu 16.04 [#469](https://github.com/actions/toolkit/pull/469)

### 0.2.1

- Fix to await async function getCompressionMethod

### 1.0.0

- Downloads Azure-hosted caches using the Azure SDK for speed and reliability
- Displays download progress
- Includes changes that break compatibility with earlier versions, including:
- `retry`, `retryTypedResponse`, and `retryHttpClientResponse` moved from `cacheHttpClient` to `requestUtils`

### 1.0.1

- Fix bug in downloading large files (> 2 GBs) with the Azure SDK

### 1.0.2

- Use posix archive format to add support for some tools

### 1.0.3

- Use http-client v1.0.9
- Fixes error handling so retries are not attempted on non-retryable errors (409 Conflict, for example)
- Adds 5 second delay between retry attempts

### 1.0.4

- Use @actions/core v1.2.6
- Fixes uploadChunk to throw an error if any unsuccessful response code is received

### 1.0.5

- Fix to ensure Windows cache paths get resolved correctly

### 1.0.6

- Make caching more verbose [#650](https://github.com/actions/toolkit/pull/650)
- Use GNU tar on macOS if available [#701](https://github.com/actions/toolkit/pull/701)

### 1.0.7

- Fixes permissions issue extracting archives with GNU tar on macOS ([issue](https://github.com/actions/cache/issues/527))

### 1.0.8

- Increase the allowed artifact cache size from 5GB to 10GB ([issue](https://github.com/actions/cache/discussions/497))

### 1.0.9

- Use @azure/ms-rest-js v2.6.0
- Use @azure/storage-blob v12.8.0

### 1.0.10

- Update `lockfileVersion` to `v2` in `package-lock.json [#1022](https://github.com/actions/toolkit/pull/1022)

### 1.0.11

- Fix file downloads > 2GB([issue](https://github.com/actions/cache/issues/773))

### 2.0.0

- Added support to check if Actions cache service feature is available or not [#1028](https://github.com/actions/toolkit/pull/1028)

### 2.0.3

- Update to v2.0.0 of `@actions/http-client`

### 2.0.4

- Update to v2.0.1 of `@actions/http-client` [#1087](https://github.com/actions/toolkit/pull/1087)

### 2.0.5

- Fix to avoid saving empty cache when no files are available for caching. ([issue](https://github.com/actions/cache/issues/624))

### 2.0.6

- Fix `Tar failed with error: The process '/usr/bin/tar' failed with exit code 1` issue when temp directory where tar is getting created is actually the subdirectory of the path mentioned by the user for caching. ([issue](https://github.com/actions/cache/issues/689))

### 3.0.0

- Updated actions/cache to suppress Actions cache server error and log warning for those error [#1122](https://github.com/actions/toolkit/pull/1122)

### 3.0.1

- Fix [#833](https://github.com/actions/cache/issues/833) - cache doesn't work with github workspace directory.
- Fix [#809](https://github.com/actions/cache/issues/809) `zstd -d: no such file or directory` error on AWS self-hosted runners.

### 3.0.2

- Added 1 hour timeout for the download stuck issue [#810](https://github.com/actions/cache/issues/810).

### 3.0.3

- Bug fixes for download stuck issue [#810](https://github.com/actions/cache/issues/810).

### 3.0.4

- Fix zstd not working for windows on gnu tar in issues [#888](https://github.com/actions/cache/issues/888) and [#891](https://github.com/actions/cache/issues/891).
- Allowing users to provide a custom timeout as input for aborting download of a cache segment using an environment variable `SEGMENT_DOWNLOAD_TIMEOUT_MINS`. Default is 60 minutes.

### 3.0.5

- Update `@actions/cache` to use `@actions/core@^1.10.0`

### 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.

### 3.1.1

- Reverted changes in 3.1.0 to fix issue with symlink restoration on windows.
- Added support for verbose logging about cache version during cache miss.

### 3.1.2

- Fix issue with symlink restoration on windows.

### 3.1.3

- Fix to prevent from setting MYSYS environement variable globally [#1329](https://github.com/actions/toolkit/pull/1329).

### 3.1.4

- Fix zstd not being used due to `zstd --version` output change in zstd 1.5.4 release. See [#1353](https://github.com/actions/toolkit/pull/1353).

### 3.2.0

- Add `lookupOnly` to cache restore `DownloadOptions`.

### 3.2.1

- Updated @azure/storage-blob to `v12.13.0`

### 3.2.2

- Add new default cache download method to improve performance and reduce hangs [#1484](https://github.com/actions/toolkit/pull/1484)
5 changes: 5 additions & 0 deletions packages/warp-cache/__tests__/__fixtures__/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: 'Set env variables'
description: 'Sets certain env variables so that e2e restore and save cache can be tested in a shell'
runs:
using: 'node12'
main: 'index.js'
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello world
14 changes: 14 additions & 0 deletions packages/warp-cache/__tests__/__fixtures__/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Certain env variables are not set by default in a shell context and are only available in a node context from a running action
// In order to be able to restore and save cache e2e in a shell when running CI tests, we need these env variables set
const fs = require('fs');
const os = require('os');
const filePath = process.env[`GITHUB_ENV`]
fs.appendFileSync(filePath, `ACTIONS_RUNTIME_TOKEN=${process.env.ACTIONS_RUNTIME_TOKEN}${os.EOL}`, {
encoding: 'utf8'
})
fs.appendFileSync(filePath, `ACTIONS_CACHE_URL=${process.env.ACTIONS_CACHE_URL}${os.EOL}`, {
encoding: 'utf8'
})
fs.appendFileSync(filePath, `GITHUB_RUN_ID=${process.env.GITHUB_RUN_ID}${os.EOL}`, {
encoding: 'utf8'
})
14 changes: 14 additions & 0 deletions packages/warp-cache/__tests__/cache.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import * as cache from '../src/cache'

test('isFeatureAvailable returns true if server url is set', () => {
try {
process.env['WARPBUILD_CACHE_URL'] = 'http://cache.com'
expect(cache.isFeatureAvailable()).toBe(true)
} finally {
delete process.env['WARPBUILD_CACHE_URL']
}
})

test('isFeatureAvailable returns false if server url is not set', () => {
expect(cache.isFeatureAvailable()).toBe(false)
})
Loading