Compare commits

..

2 Commits

Author SHA1 Message Date
0da99ad140 Preview v0.0.2 Release (#50)
* Create CODE_OF_CONDUCT.md

* Update workflow (#1)

* Run workflow on linux, mac, and windows

* Add status badge

* Use npm install instead

* Bump typescript version

* Use node 12.x

* Add Ruby Gem example (#4)

* Add Cocoapods example (#5)

* Add Carthage example (#10)

* Move examples to their own page (#13)

* Minor typo in README (#15)

from `steps.[ID].outupts.cache-hit` to `steps.[ID].outputs.cache-hit`

* Update README.md

* Prevent commands from executing during tests (#21)

* Prevent commands from executing during tests

* Add newline at end of file

* Drop all commands from output

* Link to NuGet lock files documentation (#20)

* Add trailing dash to Maven fallback key (#19)

* Fix README.md (#25)

`restore-keys` had incorrect indentation.

* Exclude documentation from CI tests (#28)

* Ignore all .md files

* Add note about time-based eviction to README (#30)

* Fix typo in error message (#29)

* Time based eviction interval is 1 week (#34)

* Remove cache checksum debug - close #24 (#26)

* Remove cache checksum debug - close #24

*  Remove cache checksum debug on save

* Fix formatting

* Add Go modules example (#18)

* Add Go modules example

* Fix TOC

* Fix repo name in contact email (#41)

* Add Elixir Mix example (#42)

* Add Elixir Mix example

* Fix typo

* Add cargo example for Rust project (#8)

* Add cargo example

* Add hash of Cargo.lock to keys of caches

* Move Rust example to examples.md

* Stop warning when cache is not found (#40)

The cache not being found is a common situation so very visible warning
is a little too much.

* Bump package version

* Release v0.0.2
2019-11-04 13:39:29 -05:00
e7ad80454a Release preview version 2019-10-30 14:50:22 -04:00
8 changed files with 114 additions and 125 deletions

View File

@ -2,11 +2,7 @@
This GitHub Action allows caching dependencies and build outputs to improve workflow execution time. This GitHub Action allows caching dependencies and build outputs to improve workflow execution time.
<a href="https://github.com/actions/cache"><img alt="GitHub Actions status" src="https://github.com/actions/cache/workflows/Tests/badge.svg?branch=master&event=push"></a> <a href="https://github.com/actions/cache"><img alt="GitHub Actions status" src="https://github.com/actions/cache/workflows/Tests/badge.svg"></a>
## Documentation
See ["Caching dependencies to speed up workflows"](https://help.github.com/github/automating-your-workflow-with-github-actions/caching-dependencies-to-speed-up-workflows).
## Usage ## Usage
@ -40,7 +36,7 @@ jobs:
- uses: actions/checkout@v1 - uses: actions/checkout@v1
- name: Cache node modules - name: Cache node modules
uses: actions/cache@v1 uses: actions/cache@preview
with: with:
path: node_modules path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
@ -63,7 +59,7 @@ See [Examples](examples.md)
## Cache Limits ## Cache Limits
Individual caches are limited to 400MB and a repository can have up to 2GB of caches. Once the 2GB limit is reached, older caches will be evicted based on when the cache was last accessed. Caches that are not accessed within the last week will also be evicted. Individual caches are limited to 200MB and a repository can have up to 2GB of caches. Once the 2GB limit is reached, older caches will be evicted based on when the cache was last accessed. Caches that are not accessed within the last week will also be evicted.
## Skipping steps based on cache-hit ## Skipping steps based on cache-hit
@ -74,7 +70,7 @@ Example:
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v1
- uses: actions/cache@v1 - uses: actions/cache@preview
id: cache id: cache
with: with:
path: path/to/dependencies path: path/to/dependencies

View File

@ -2972,10 +2972,7 @@ function run() {
core.debug(`Cache Path: ${cachePath}`); core.debug(`Cache Path: ${cachePath}`);
const primaryKey = core.getInput(constants_1.Inputs.Key, { required: true }); const primaryKey = core.getInput(constants_1.Inputs.Key, { required: true });
core.saveState(constants_1.State.CacheKey, primaryKey); core.saveState(constants_1.State.CacheKey, primaryKey);
const restoreKeys = core const restoreKeys = core.getInput(constants_1.Inputs.RestoreKeys).split("\n");
.getInput(constants_1.Inputs.RestoreKeys)
.split("\n")
.filter(x => x !== "");
const keys = [primaryKey, ...restoreKeys]; const keys = [primaryKey, ...restoreKeys];
core.debug("Resolved Keys:"); core.debug("Resolved Keys:");
core.debug(JSON.stringify(keys)); core.debug(JSON.stringify(keys));
@ -2997,7 +2994,7 @@ function run() {
try { try {
const cacheEntry = yield cacheHttpClient.getCacheEntry(keys); const cacheEntry = yield cacheHttpClient.getCacheEntry(keys);
if (!cacheEntry) { if (!cacheEntry) {
core.info(`Cache not found for input keys: ${keys.join(", ")}.`); core.info(`Cache not found for input keys: ${JSON.stringify(keys)}.`);
return; return;
} }
let archivePath = path.join(yield utils.createTempDirectory(), "cache.tgz"); let archivePath = path.join(yield utils.createTempDirectory(), "cache.tgz");

4
dist/save/index.js vendored
View File

@ -2889,11 +2889,11 @@ function run() {
const tarPath = yield io.which("tar", true); const tarPath = yield io.which("tar", true);
core.debug(`Tar Path: ${tarPath}`); core.debug(`Tar Path: ${tarPath}`);
yield exec_1.exec(`"${tarPath}"`, args); yield exec_1.exec(`"${tarPath}"`, args);
const fileSizeLimit = 400 * 1024 * 1024; // 400MB const fileSizeLimit = 200 * 1024 * 1024; // 200MB
const archiveFileSize = fs.statSync(archivePath).size; const archiveFileSize = fs.statSync(archivePath).size;
core.debug(`File Size: ${archiveFileSize}`); core.debug(`File Size: ${archiveFileSize}`);
if (archiveFileSize > fileSizeLimit) { if (archiveFileSize > fileSizeLimit) {
core.warning(`Cache size of ${archiveFileSize} bytes is over the 400MB limit, not saving cache.`); core.warning(`Cache size of ${archiveFileSize} bytes is over the 200MB limit, not saving cache.`);
return; return;
} }
const stream = fs.createReadStream(archivePath); const stream = fs.createReadStream(archivePath);

View File

@ -1,76 +1,21 @@
# Examples # Examples
- [C# - Nuget](#c---nuget)
- [Elixir - Mix](#elixir---mix)
- [Go - Modules](#go---modules)
- [Java - Gradle](#java---gradle)
- [Java - Maven](#java---maven)
- [Node - npm](#node---npm) - [Node - npm](#node---npm)
- [Node - Yarn](#node---yarn) - [Node - Yarn](#node---yarn)
- [Ruby - Gem](#ruby---gem) - [C# - Nuget](#c---nuget)
- [Rust - Cargo](#rust---cargo) - [Java - Gradle](#java---gradle)
- [Java - Maven](#java---maven)
- [Swift, Objective-C - Carthage](#swift-objective-c---carthage) - [Swift, Objective-C - Carthage](#swift-objective-c---carthage)
- [Swift, Objective-C - CocoaPods](#swift-objective-c---cocoapods) - [Swift, Objective-C - CocoaPods](#swift-objective-c---cocoapods)
- [Ruby - Gem](#ruby---gem)
## C# - Nuget - [Go - Modules](#go---modules)
Using [NuGet lock files](https://docs.microsoft.com/nuget/consume-packages/package-references-in-project-files#locking-dependencies): - [Elixir - Mix](#elixir---mix)
- [Rust - Cargo](#rust---cargo)
```yaml
- uses: actions/cache@v1
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
```
## Elixir - Mix
```yaml
- uses: actions/cache@v1
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
restore-keys: |
${{ runner.os }}-mix-
```
## Go - Modules
```yaml
- uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
```
## Java - Gradle
```yaml
- uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: |
${{ runner.os }}-gradle-
```
## Java - Maven
```yaml
- uses: actions/cache@v1
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
```
## Node - npm ## Node - npm
```yaml ```yaml
- uses: actions/cache@v1 - uses: actions/cache@preview
with: with:
path: node_modules path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
@ -81,7 +26,7 @@ Using [NuGet lock files](https://docs.microsoft.com/nuget/consume-packages/packa
## Node - Yarn ## Node - Yarn
```yaml ```yaml
- uses: actions/cache@v1 - uses: actions/cache@preview
with: with:
path: ~/.cache/yarn path: ~/.cache/yarn
key: ${{ runner.os }}-yarn-${{ hashFiles(format('{0}{1}', github.workspace, '/yarn.lock')) }} key: ${{ runner.os }}-yarn-${{ hashFiles(format('{0}{1}', github.workspace, '/yarn.lock')) }}
@ -89,10 +34,65 @@ Using [NuGet lock files](https://docs.microsoft.com/nuget/consume-packages/packa
${{ runner.os }}-yarn- ${{ runner.os }}-yarn-
``` ```
## C# - Nuget
Using [NuGet lock files](https://docs.microsoft.com/nuget/consume-packages/package-references-in-project-files#locking-dependencies):
```yaml
- uses: actions/cache@preview
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
```
## Java - Gradle
```yaml
- uses: actions/cache@preview
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: |
${{ runner.os }}-gradle-
```
## Java - Maven
```yaml
- uses: actions/cache@preview
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
```
## Swift, Objective-C - Carthage
```yaml
uses: actions/cache@preview
with:
path: Carthage
key: ${{ runner.os }}-carthage-${{ hashFiles('**/Cartfile.resolved') }}
restore-keys: |
${{ runner.os }}-carthage-
```
## Swift, Objective-C - CocoaPods
```yaml
- uses: actions/cache@preview
with:
path: Pods
key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }}
restore-keys: |
${{ runner.os }}-pods-
```
## Ruby - Gem ## Ruby - Gem
```yaml ```yaml
- uses: actions/cache@v1 - uses: actions/cache@preview
with: with:
path: vendor/bundle path: vendor/bundle
key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }} key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
@ -100,44 +100,43 @@ Using [NuGet lock files](https://docs.microsoft.com/nuget/consume-packages/packa
${{ runner.os }}-gem- ${{ runner.os }}-gem-
``` ```
## Rust - Cargo ## Go - Modules
```yaml ```yaml
- uses: actions/cache@preview
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
```
## Elixir - Mix
```yaml
- uses: actions/cache@preview
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
restore-keys: |
${{ runner.os }}-mix-
```
## Rust - Cargo
```
- name: Cache cargo registry - name: Cache cargo registry
uses: actions/cache@v1 uses: actions/cache@preview
with: with:
path: ~/.cargo/registry path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index - name: Cache cargo index
uses: actions/cache@v1 uses: actions/cache@preview
with: with:
path: ~/.cargo/git path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo build - name: Cache cargo build
uses: actions/cache@v1 uses: actions/cache@preview
with: with:
path: target path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
``` ```
## Swift, Objective-C - Carthage
```yaml
- uses: actions/cache@v1
with:
path: Carthage
key: ${{ runner.os }}-carthage-${{ hashFiles('**/Cartfile.resolved') }}
restore-keys: |
${{ runner.os }}-carthage-
```
## Swift, Objective-C - CocoaPods
```yaml
- uses: actions/cache@v1
with:
path: Pods
key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }}
restore-keys: |
${{ runner.os }}-pods-
```

22
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "cache", "name": "cache",
"version": "1.0.1", "version": "0.0.1",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -1105,9 +1105,9 @@
} }
}, },
"commander": { "commander": {
"version": "2.20.3", "version": "2.20.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.1.tgz",
"integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", "integrity": "sha512-cCuLsMhJeWQ/ZpsFTbE765kvVfoeSddc4nU3up4fV+fDBcfUXnbITJ+JzhkdjzOqhURjZgujxaioam4RM9yGUg==",
"dev": true, "dev": true,
"optional": true "optional": true
}, },
@ -2318,9 +2318,9 @@
"dev": true "dev": true
}, },
"handlebars": { "handlebars": {
"version": "4.5.1", "version": "4.4.2",
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.5.1.tgz", "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.4.2.tgz",
"integrity": "sha512-C29UoFzHe9yM61lOsIlCE5/mQVGrnIOrOq7maQl76L7tYPCgC1og0Ajt6uWnX4ZTxBPnjw+CUvawphwCfJgUnA==", "integrity": "sha512-cIv17+GhL8pHHnRJzGu2wwcthL5sb8uDKBHvZ2Dtu5s1YNt0ljbzKbamnc+gr69y7bzwQiBdr5+hOpRd5pnOdg==",
"dev": true, "dev": true,
"requires": { "requires": {
"neo-async": "^2.6.0", "neo-async": "^2.6.0",
@ -4981,13 +4981,13 @@
"dev": true "dev": true
}, },
"uglify-js": { "uglify-js": {
"version": "3.6.7", "version": "3.6.0",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.7.tgz", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.0.tgz",
"integrity": "sha512-4sXQDzmdnoXiO+xvmTzQsfIiwrjUCSA95rSP4SEd8tDb51W2TiDOlL76Hl+Kw0Ie42PSItCW8/t6pBNCF2R48A==", "integrity": "sha512-W+jrUHJr3DXKhrsS7NUVxn3zqMOFn0hL/Ei6v0anCIMoKC93TjcflTagwIHLW7SfMFfiQuktQyFVCFHGUE0+yg==",
"dev": true, "dev": true,
"optional": true, "optional": true,
"requires": { "requires": {
"commander": "~2.20.3", "commander": "~2.20.0",
"source-map": "~0.6.1" "source-map": "~0.6.1"
} }
}, },

View File

@ -1,6 +1,6 @@
{ {
"name": "cache", "name": "cache",
"version": "1.0.1", "version": "0.0.2",
"private": true, "private": true,
"description": "Cache dependencies and build outputs", "description": "Cache dependencies and build outputs",
"main": "dist/restore/index.js", "main": "dist/restore/index.js",

View File

@ -20,10 +20,7 @@ async function run() {
const primaryKey = core.getInput(Inputs.Key, { required: true }); const primaryKey = core.getInput(Inputs.Key, { required: true });
core.saveState(State.CacheKey, primaryKey); core.saveState(State.CacheKey, primaryKey);
const restoreKeys = core const restoreKeys = core.getInput(Inputs.RestoreKeys).split("\n");
.getInput(Inputs.RestoreKeys)
.split("\n")
.filter(x => x !== "");
const keys = [primaryKey, ...restoreKeys]; const keys = [primaryKey, ...restoreKeys];
core.debug("Resolved Keys:"); core.debug("Resolved Keys:");
@ -55,7 +52,7 @@ async function run() {
const cacheEntry = await cacheHttpClient.getCacheEntry(keys); const cacheEntry = await cacheHttpClient.getCacheEntry(keys);
if (!cacheEntry) { if (!cacheEntry) {
core.info( core.info(
`Cache not found for input keys: ${keys.join(", ")}.` `Cache not found for input keys: ${JSON.stringify(keys)}.`
); );
return; return;
} }

View File

@ -54,12 +54,12 @@ async function run() {
core.debug(`Tar Path: ${tarPath}`); core.debug(`Tar Path: ${tarPath}`);
await exec(`"${tarPath}"`, args); await exec(`"${tarPath}"`, args);
const fileSizeLimit = 400 * 1024 * 1024; // 400MB const fileSizeLimit = 200 * 1024 * 1024; // 200MB
const archiveFileSize = fs.statSync(archivePath).size; const archiveFileSize = fs.statSync(archivePath).size;
core.debug(`File Size: ${archiveFileSize}`); core.debug(`File Size: ${archiveFileSize}`);
if (archiveFileSize > fileSizeLimit) { if (archiveFileSize > fileSizeLimit) {
core.warning( core.warning(
`Cache size of ${archiveFileSize} bytes is over the 400MB limit, not saving cache.` `Cache size of ${archiveFileSize} bytes is over the 200MB limit, not saving cache.`
); );
return; return;
} }