mirror of
https://gitee.com/actions-mirror/cache.git
synced 2024-11-23 19:30:43 +08:00
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
This commit is contained in:
parent
e7ad80454a
commit
0da99ad140
15
.github/workflows/workflow.yml
vendored
15
.github/workflows/workflow.yml
vendored
@ -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
|
||||
|
||||
|
76
CODE_OF_CONDUCT.md
Normal file
76
CODE_OF_CONDUCT.md
Normal file
@ -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/cache@github.com. 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
README.md
65
README.md
@ -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
|
||||
@ -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
|
||||
@ -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 }}-
|
||||
```
|
||||
|
||||
### 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
|
||||
|
||||
@ -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
dist/restore/index.js
vendored
28
dist/restore/index.js
vendored
@ -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());
|
||||
});
|
||||
};
|
||||
@ -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}`);
|
||||
@ -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());
|
||||
});
|
||||
};
|
||||
@ -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));
|
||||
}
|
||||
@ -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());
|
||||
});
|
||||
};
|
||||
@ -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
|
||||
@ -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);
|
||||
|
20
dist/save/index.js
vendored
20
dist/save/index.js
vendored
@ -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());
|
||||
});
|
||||
};
|
||||
@ -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}`);
|
||||
@ -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());
|
||||
});
|
||||
};
|
||||
@ -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));
|
||||
}
|
||||
@ -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());
|
||||
});
|
||||
};
|
||||
@ -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);
|
||||
|
142
examples.md
Normal file
142
examples.md
Normal file
@ -0,0 +1,142 @@
|
||||
# Examples
|
||||
|
||||
- [Node - npm](#node---npm)
|
||||
- [Node - Yarn](#node---yarn)
|
||||
- [C# - Nuget](#c---nuget)
|
||||
- [Java - Gradle](#java---gradle)
|
||||
- [Java - Maven](#java---maven)
|
||||
- [Swift, Objective-C - Carthage](#swift-objective-c---carthage)
|
||||
- [Swift, Objective-C - CocoaPods](#swift-objective-c---cocoapods)
|
||||
- [Ruby - Gem](#ruby---gem)
|
||||
- [Go - Modules](#go---modules)
|
||||
- [Elixir - Mix](#elixir---mix)
|
||||
- [Rust - Cargo](#rust---cargo)
|
||||
|
||||
## Node - npm
|
||||
|
||||
```yaml
|
||||
- uses: actions/cache@preview
|
||||
with:
|
||||
path: node_modules
|
||||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
||||
restore-keys: |
|
||||
${{ 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
|
||||
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
|
||||
|
||||
```yaml
|
||||
- uses: actions/cache@preview
|
||||
with:
|
||||
path: vendor/bundle
|
||||
key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-gem-
|
||||
```
|
||||
|
||||
## Go - Modules
|
||||
|
||||
```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
|
||||
uses: actions/cache@preview
|
||||
with:
|
||||
path: ~/.cargo/registry
|
||||
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
|
||||
- name: Cache cargo index
|
||||
uses: actions/cache@preview
|
||||
with:
|
||||
path: ~/.cargo/git
|
||||
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
|
||||
- name: Cache cargo build
|
||||
uses: actions/cache@preview
|
||||
with:
|
||||
path: target
|
||||
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
|
||||
```
|
@ -8,4 +8,13 @@ module.exports = {
|
||||
'^.+\\.ts$': 'ts-jest'
|
||||
},
|
||||
verbose: true
|
||||
}
|
||||
|
||||
const processStdoutWrite = process.stdout.write.bind(process.stdout)
|
||||
process.stdout.write = (str, encoding, cb) => {
|
||||
// Core library will directly call process.stdout.write for commands
|
||||
// We don't want :: commands to be executed by the runner during tests
|
||||
if (!str.match(/^::/)) {
|
||||
return processStdoutWrite(str, encoding, cb);
|
||||
}
|
||||
}
|
6
package-lock.json
generated
6
package-lock.json
generated
@ -4975,9 +4975,9 @@
|
||||
}
|
||||
},
|
||||
"typescript": {
|
||||
"version": "3.5.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.3.tgz",
|
||||
"integrity": "sha512-ACzBtm/PhXBDId6a6sDJfroT2pOWt/oOnk4/dElG5G33ZL776N3Y6/6bKZJBFpd+b05F3Ct9qDjMeJmRWtE2/g==",
|
||||
"version": "3.6.4",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.6.4.tgz",
|
||||
"integrity": "sha512-unoCll1+l+YK4i4F8f22TaNVPRHcD9PA3yCuZ8g5e0qGqlVlJ/8FSateOLLSagn+Yg5+ZwuPkL8LFUc0Jcvksg==",
|
||||
"dev": true
|
||||
},
|
||||
"uglify-js": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cache",
|
||||
"version": "0.0.1",
|
||||
"version": "0.0.2",
|
||||
"private": true,
|
||||
"description": "Cache dependencies and build outputs",
|
||||
"main": "dist/restore/index.js",
|
||||
@ -38,6 +38,6 @@
|
||||
"jest-circus": "^24.7.1",
|
||||
"prettier": "1.18.2",
|
||||
"ts-jest": "^24.0.2",
|
||||
"typescript": "^3.5.1"
|
||||
"typescript": "^3.6.4"
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import { ArtifactCacheEntry } from "./contracts";
|
||||
|
||||
export async function getCacheEntry(
|
||||
keys: string[]
|
||||
): Promise<ArtifactCacheEntry> {
|
||||
): Promise<ArtifactCacheEntry | null> {
|
||||
const cacheUrl = getCacheUrl();
|
||||
const token = process.env["ACTIONS_RUNTIME_TOKEN"] || "";
|
||||
const bearerCredentialHandler = new BearerCredentialHandler(token);
|
||||
@ -28,9 +28,7 @@ export async function getCacheEntry(
|
||||
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}`);
|
||||
|
@ -49,14 +49,20 @@ async function run() {
|
||||
}
|
||||
|
||||
try {
|
||||
const cacheEntry = await cacheHttpClient.getCacheEntry(keys);
|
||||
if (!cacheEntry) {
|
||||
core.info(
|
||||
`Cache not found for input keys: ${JSON.stringify(keys)}.`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
let archivePath = path.join(
|
||||
await utils.createTempDirectory(),
|
||||
"cache.tgz"
|
||||
);
|
||||
core.debug(`Archive Path: ${archivePath}`);
|
||||
|
||||
const cacheEntry = await cacheHttpClient.getCacheEntry(keys);
|
||||
|
||||
// Store the cache result
|
||||
utils.setCacheState(cacheEntry);
|
||||
|
||||
@ -92,15 +98,8 @@ async function run() {
|
||||
utils.setCacheHitOutput(isExactKeyMatch);
|
||||
|
||||
core.info(
|
||||
`Cache restored from key:${cacheEntry && cacheEntry.cacheKey}`
|
||||
`Cache restored from key: ${cacheEntry && cacheEntry.cacheKey}`
|
||||
);
|
||||
|
||||
try {
|
||||
core.info("Cache Checksum:");
|
||||
await exec(`md5sum`, [`${archivePath}`]);
|
||||
} catch (error) {
|
||||
core.debug(`Failed to checkum with ${error}`);
|
||||
}
|
||||
} catch (error) {
|
||||
core.warning(error.message);
|
||||
utils.setCacheHitOutput(false);
|
||||
|
@ -66,13 +66,6 @@ async function run() {
|
||||
|
||||
const stream = fs.createReadStream(archivePath);
|
||||
await cacheHttpClient.saveCache(stream, primaryKey);
|
||||
|
||||
try {
|
||||
core.info("Cache Checksum:");
|
||||
await exec(`md5sum`, [`${archivePath}`]);
|
||||
} catch (error) {
|
||||
core.debug(`Failed to checkum with ${error}`);
|
||||
}
|
||||
} catch (error) {
|
||||
core.warning(error.message);
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ export function resolvePath(filePath: string): string {
|
||||
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));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user