Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b2cac08
Create CODE_OF_CONDUCT.md
joshmgross Oct 30, 2019
889c603
Update workflow (#1)
joshmgross Oct 31, 2019
7611296
Add Ruby Gem example (#4)
koogawa Oct 31, 2019
83bb08d
Add Cocoapods example (#5)
koogawa Oct 31, 2019
6e37fd1
Add Carthage example (#10)
ry-itto Oct 31, 2019
3743276
Move examples to their own page (#13)
joshmgross Oct 31, 2019
6be35d1
Minor typo in README (#15)
akhyarrh Oct 31, 2019
d676b6c
Update README.md
chrispat Oct 31, 2019
526c940
Prevent commands from executing during tests (#21)
joshmgross Oct 31, 2019
c401b56
Link to NuGet lock files documentation (#20)
zarenner Oct 31, 2019
287ee06
Add trailing dash to Maven fallback key (#19)
zarenner Oct 31, 2019
fc310d4
Fix README.md (#25)
peter7z Oct 31, 2019
aae1376
Exclude documentation from CI tests (#28)
joshmgross Oct 31, 2019
0e86554
Ignore all .md files
joshmgross Nov 1, 2019
2523667
Add note about time-based eviction to README (#30)
dhadka Nov 1, 2019
7058277
Fix typo in error message (#29)
winterjung Nov 1, 2019
d384987
Time based eviction interval is 1 week (#34)
zarenner Nov 1, 2019
25e0c8f
Remove cache checksum debug - close #24 (#26)
ad-m Nov 1, 2019
87c0185
Add Go modules example (#18)
crazy-max Nov 1, 2019
fe98aa6
Fix repo name in contact email (#41)
xt0rted Nov 3, 2019
8c4c641
Add Elixir Mix example (#42)
ghostrick Nov 4, 2019
57f889e
Add cargo example for Rust project (#8)
rhysd Nov 4, 2019
ce4a52a
Stop warning when cache is not found (#40)
poiru Nov 4, 2019
21f72b1
Bump package version
joshmgross Nov 4, 2019
f7a83c3
Release v0.0.2
joshmgross Nov 4, 2019
0400ab3
Merge branch 'preview' into preview-v0.0.2
joshmgross Nov 4, 2019
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
15 changes: 13 additions & 2 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
name: Test Cache Action
name: Tests
on:
pull_request:
push:
branches:
- master
paths-ignore:
- '**.md'

jobs:
test:
runs-on: ubuntu-latest
name: Test on ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v1

- uses: actions/setup-node@v1
with:
node-version: '12.x'

- run: npm ci

Expand Down
76 changes: 76 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to make participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies within all project spaces, and it also applies when
an individual is representing the project or its community in public spaces.
Examples of representing a project or community include using an official
project e-mail address, posting via an official social media account, or acting
as an appointed representative at an online or offline event. Representation of
a project may be further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at opensource+actions/[email protected]. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
65 changes: 11 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

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"></a>

## Usage

### Pre-requisites
Expand Down Expand Up @@ -33,11 +35,13 @@ jobs:
steps:
- uses: actions/checkout@v1

- name: Cache node_modules
- name: Cache node modules
uses: actions/cache@preview
with:
path: node_modules
key: ${{ runner.os }}-node
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- name: Install Dependencies
run: npm install
Expand All @@ -48,61 +52,14 @@ jobs:
- name: Test
run: npm run test
```
## Ecosystem Examples

### Node - npm

```yaml
- uses: actions/cache@preview
with:
path: node_modules
key: ${{ runner.os }}-node
```

### Node - Yarn

```yaml
- uses: actions/cache@preview
with:
path: ~/.cache/yarn
key: ${{ runner.os }}-yarn-${{ hashFiles(format('{0}{1}', github.workspace, '/yarn.lock')) }}
restore-keys: |
${{ runner.os }}-yarn-
```

### C# - Nuget

```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: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle') }}
restore-keys: |
gradle-${{ runner.os }}-
```
## Ecosystem Examples

### Java - Maven
```yaml
- uses: actions/cache@preview
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven
```
See [Examples](examples.md)

## Cache Limits

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

Expand All @@ -124,10 +81,10 @@ steps:
run: /install.sh
```

> Note: The `id` defined in `actions/cache` must match the `id` in the `if` statement (i.e. `steps.[ID].outupts.cache-hit`)
> Note: The `id` defined in `actions/cache` must match the `id` in the `if` statement (i.e. `steps.[ID].outputs.cache-hit`)

## Contributing
We would love for you to contribute to `@actions/cache`, pull requests are welcome! Please see the [CONTRIBUTING.md](CONTRIBUTING.md) for more information.

## License
The scripts and documentation in this project are released under the [MIT License](LICENSE)
The scripts and documentation in this project are released under the [MIT License](LICENSE)
28 changes: 14 additions & 14 deletions dist/restore/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1475,10 +1475,11 @@ exports.debug = debug; // for test
"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Expand Down Expand Up @@ -1506,7 +1507,7 @@ function getCacheEntry(keys) {
]);
const response = yield restClient.get(resource, getRequestOptions());
if (response.statusCode === 204) {
throw new Error(`Cache not found for input keys: ${JSON.stringify(keys)}.`);
return null;
}
if (response.statusCode !== 200) {
throw new Error(`Cache service responded with ${response.statusCode}`);
Expand Down Expand Up @@ -2120,10 +2121,11 @@ exports.createType3Message = createType3Message;
"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Expand Down Expand Up @@ -2200,7 +2202,7 @@ function resolvePath(filePath) {
if (filePath[0] === "~") {
const home = os.homedir();
if (!home) {
throw new Error("Unable to resole `~` to HOME");
throw new Error("Unable to resolve `~` to HOME");
}
return path.join(home, filePath.slice(1));
}
Expand Down Expand Up @@ -2938,10 +2940,11 @@ module.exports = require("fs");
"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Expand Down Expand Up @@ -2989,9 +2992,13 @@ function run() {
}
}
try {
const cacheEntry = yield cacheHttpClient.getCacheEntry(keys);
if (!cacheEntry) {
core.info(`Cache not found for input keys: ${JSON.stringify(keys)}.`);
return;
}
let archivePath = path.join(yield utils.createTempDirectory(), "cache.tgz");
core.debug(`Archive Path: ${archivePath}`);
const cacheEntry = yield cacheHttpClient.getCacheEntry(keys);
// Store the cache result
utils.setCacheState(cacheEntry);
// Download the cache from the cache entry
Expand All @@ -3014,14 +3021,7 @@ function run() {
yield exec_1.exec(`"${tarPath}"`, args);
const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheEntry);
utils.setCacheHitOutput(isExactKeyMatch);
core.info(`Cache restored from key:${cacheEntry && cacheEntry.cacheKey}`);
try {
core.info("Cache Checksum:");
yield exec_1.exec(`md5sum`, [`${archivePath}`]);
}
catch (error) {
core.debug(`Failed to checkum with ${error}`);
}
core.info(`Cache restored from key: ${cacheEntry && cacheEntry.cacheKey}`);
}
catch (error) {
core.warning(error.message);
Expand Down
20 changes: 8 additions & 12 deletions dist/save/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1475,10 +1475,11 @@ exports.debug = debug; // for test
"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Expand Down Expand Up @@ -1506,7 +1507,7 @@ function getCacheEntry(keys) {
]);
const response = yield restClient.get(resource, getRequestOptions());
if (response.statusCode === 204) {
throw new Error(`Cache not found for input keys: ${JSON.stringify(keys)}.`);
return null;
}
if (response.statusCode !== 200) {
throw new Error(`Cache service responded with ${response.statusCode}`);
Expand Down Expand Up @@ -2120,10 +2121,11 @@ exports.createType3Message = createType3Message;
"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Expand Down Expand Up @@ -2200,7 +2202,7 @@ function resolvePath(filePath) {
if (filePath[0] === "~") {
const home = os.homedir();
if (!home) {
throw new Error("Unable to resole `~` to HOME");
throw new Error("Unable to resolve `~` to HOME");
}
return path.join(home, filePath.slice(1));
}
Expand Down Expand Up @@ -2832,10 +2834,11 @@ function isUnixExecutable(stats) {
"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Expand Down Expand Up @@ -2895,13 +2898,6 @@ function run() {
}
const stream = fs.createReadStream(archivePath);
yield cacheHttpClient.saveCache(stream, primaryKey);
try {
core.info("Cache Checksum:");
yield exec_1.exec(`md5sum`, [`${archivePath}`]);
}
catch (error) {
core.debug(`Failed to checkum with ${error}`);
}
}
catch (error) {
core.warning(error.message);
Expand Down
Loading