mirror of
https://github.com/actions/cache.git
synced 2025-03-13 11:47:00 +00:00
Merge branch 'main' into patch-1
This commit is contained in:
commit
6d0655e4ae
6 changed files with 495 additions and 441 deletions
4
dist/save/index.js
vendored
4
dist/save/index.js
vendored
|
@ -47154,6 +47154,10 @@ const cache = __importStar(__webpack_require__(692));
|
||||||
const core = __importStar(__webpack_require__(470));
|
const core = __importStar(__webpack_require__(470));
|
||||||
const constants_1 = __webpack_require__(196);
|
const constants_1 = __webpack_require__(196);
|
||||||
const utils = __importStar(__webpack_require__(443));
|
const utils = __importStar(__webpack_require__(443));
|
||||||
|
// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in
|
||||||
|
// @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to
|
||||||
|
// throw an uncaught exception. Instead of failing this action, just warn.
|
||||||
|
process.on("uncaughtException", e => utils.logWarning(e.message));
|
||||||
function run() {
|
function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
|
|
121
examples.md
121
examples.md
|
@ -1,39 +1,44 @@
|
||||||
# Examples
|
# Examples
|
||||||
|
|
||||||
- [Examples](#examples)
|
- [C# - NuGet](#c---nuget)
|
||||||
- [C# - NuGet](#c---nuget)
|
- [D - DUB](#d---dub)
|
||||||
- [D - DUB](#d---dub)
|
- [POSIX](#posix)
|
||||||
- [Elixir - Mix](#elixir---mix)
|
|
||||||
- [Go - Modules](#go---modules)
|
|
||||||
- [Haskell - Cabal](#haskell---cabal)
|
|
||||||
- [Java - Gradle](#java---gradle)
|
|
||||||
- [Java - Maven](#java---maven)
|
|
||||||
- [Node - npm](#node---npm)
|
|
||||||
- [macOS and Ubuntu](#macos-and-ubuntu)
|
|
||||||
- [Windows](#windows)
|
- [Windows](#windows)
|
||||||
|
- [Elixir - Mix](#elixir---mix)
|
||||||
|
- [Go - Modules](#go---modules)
|
||||||
|
- [Linux](#linux)
|
||||||
|
- [macOS](#macos)
|
||||||
|
- [Windows](#windows-1)
|
||||||
|
- [Haskell - Cabal](#haskell---cabal)
|
||||||
|
- [Java - Gradle](#java---gradle)
|
||||||
|
- [Java - Maven](#java---maven)
|
||||||
|
- [Node - npm](#node---npm)
|
||||||
|
- [macOS and Ubuntu](#macos-and-ubuntu)
|
||||||
|
- [Windows](#windows-2)
|
||||||
- [Using multiple systems and `npm config`](#using-multiple-systems-and-npm-config)
|
- [Using multiple systems and `npm config`](#using-multiple-systems-and-npm-config)
|
||||||
- [Node - Lerna](#node---lerna)
|
- [Node - Lerna](#node---lerna)
|
||||||
- [Node - Yarn](#node---yarn)
|
- [Node - Yarn](#node---yarn)
|
||||||
- [Node - Yarn 2](#node---yarn-2)
|
- [Node - Yarn 2](#node---yarn-2)
|
||||||
- [OCaml/Reason - esy](#ocamlreason---esy)
|
- [OCaml/Reason - esy](#ocamlreason---esy)
|
||||||
- [PHP - Composer](#php---composer)
|
- [PHP - Composer](#php---composer)
|
||||||
- [Python - pip](#python---pip)
|
- [Python - pip](#python---pip)
|
||||||
- [Simple example](#simple-example)
|
- [Simple example](#simple-example)
|
||||||
- [Multiple OSes in a workflow](#multiple-oss-in-a-workflow)
|
- [Multiple OS's in a workflow](#multiple-oss-in-a-workflow)
|
||||||
|
- [Multiple OS's in a workflow with a matrix](#multiple-oss-in-a-workflow-with-a-matrix)
|
||||||
- [Using pip to get cache location](#using-pip-to-get-cache-location)
|
- [Using pip to get cache location](#using-pip-to-get-cache-location)
|
||||||
- [Using a script to get cache location](#using-a-script-to-get-cache-location)
|
- [Python - pipenv](#python---pipenv)
|
||||||
- [Python - pipenv](#python---pipenv)
|
- [R - renv](#r---renv)
|
||||||
- [R - renv](#r---renv)
|
|
||||||
- [Simple example](#simple-example-1)
|
- [Simple example](#simple-example-1)
|
||||||
- [Multiple OSes in a workflow](#multiple-oss-in-a-workflow-1)
|
- [Multiple OS's in a workflow](#multiple-oss-in-a-workflow-1)
|
||||||
- [Ruby - Bundler](#ruby---bundler)
|
- [Ruby - Bundler](#ruby---bundler)
|
||||||
- [Rust - Cargo](#rust---cargo)
|
- [Rust - Cargo](#rust---cargo)
|
||||||
- [Scala - SBT](#scala---sbt)
|
- [Scala - SBT](#scala---sbt)
|
||||||
- [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)
|
||||||
- [Swift - Swift Package Manager](#swift---swift-package-manager)
|
- [Swift - Swift Package Manager](#swift---swift-package-manager)
|
||||||
|
|
||||||
## C# - NuGet
|
## C# - NuGet
|
||||||
|
|
||||||
Using [NuGet lock files](https://docs.microsoft.com/nuget/consume-packages/package-references-in-project-files#locking-dependencies):
|
Using [NuGet lock files](https://docs.microsoft.com/nuget/consume-packages/package-references-in-project-files#locking-dependencies):
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
@ -47,6 +52,7 @@ Using [NuGet lock files](https://docs.microsoft.com/nuget/consume-packages/packa
|
||||||
|
|
||||||
Depending on the environment, huge packages might be pre-installed in the global cache folder.
|
Depending on the environment, huge packages might be pre-installed in the global cache folder.
|
||||||
With `actions/cache@v2` you can now exclude unwanted packages with [exclude pattern](https://github.com/actions/toolkit/tree/main/packages/glob#exclude-patterns)
|
With `actions/cache@v2` you can now exclude unwanted packages with [exclude pattern](https://github.com/actions/toolkit/tree/main/packages/glob#exclude-patterns)
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: actions/cache@v2
|
- uses: actions/cache@v2
|
||||||
with:
|
with:
|
||||||
|
@ -111,10 +117,40 @@ steps:
|
||||||
|
|
||||||
## Go - Modules
|
## Go - Modules
|
||||||
|
|
||||||
|
### Linux
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: actions/cache@v2
|
- uses: actions/cache@v2
|
||||||
with:
|
with:
|
||||||
path: ~/go/pkg/mod
|
path: |
|
||||||
|
~/.cache/go-build
|
||||||
|
~/go/pkg/mod
|
||||||
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-go-
|
||||||
|
```
|
||||||
|
|
||||||
|
### macOS
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/Library/Caches/go-build
|
||||||
|
~/go/pkg/mod
|
||||||
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-go-
|
||||||
|
```
|
||||||
|
|
||||||
|
### Windows
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
%LocalAppData%\go-build
|
||||||
|
~/go/pkg/mod
|
||||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-go-
|
${{ runner.os }}-go-
|
||||||
|
@ -137,6 +173,8 @@ We cache the elements of the Cabal store separately, as the entirety of `~/.caba
|
||||||
|
|
||||||
## Java - Gradle
|
## Java - Gradle
|
||||||
|
|
||||||
|
>Note: Ensure no Gradle daemons are running anymore when your workflow completes. Creating the cache package might fail due to locks being held by Gradle. Refer to the [Gradle Daemon documentation](https://docs.gradle.org/current/userguide/gradle_daemon.html) on how to disable or stop the Gradle Daemons.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: actions/cache@v2
|
- uses: actions/cache@v2
|
||||||
with:
|
with:
|
||||||
|
@ -254,6 +292,7 @@ The yarn cache directory will depend on your operating system and version of `ya
|
||||||
|
|
||||||
|
|
||||||
## Node - Yarn 2
|
## Node - Yarn 2
|
||||||
|
|
||||||
The yarn 2 cache directory will depend on your config. See https://yarnpkg.com/configuration/yarnrc#cacheFolder for more info.
|
The yarn 2 cache directory will depend on your config. See https://yarnpkg.com/configuration/yarnrc#cacheFolder for more info.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
@ -271,6 +310,7 @@ The yarn 2 cache directory will depend on your config. See https://yarnpkg.com/c
|
||||||
```
|
```
|
||||||
|
|
||||||
## OCaml/Reason - esy
|
## OCaml/Reason - esy
|
||||||
|
|
||||||
Esy allows you to export built dependencies and import pre-built dependencies.
|
Esy allows you to export built dependencies and import pre-built dependencies.
|
||||||
```yaml
|
```yaml
|
||||||
- name: Restore Cache
|
- name: Restore Cache
|
||||||
|
@ -297,7 +337,6 @@ Esy allows you to export built dependencies and import pre-built dependencies.
|
||||||
if: steps.restore-cache.outputs.cache-hit != 'true'
|
if: steps.restore-cache.outputs.cache-hit != 'true'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## PHP - Composer
|
## PHP - Composer
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
@ -318,11 +357,13 @@ Esy allows you to export built dependencies and import pre-built dependencies.
|
||||||
For pip, the cache directory will vary by OS. See https://pip.pypa.io/en/stable/reference/pip_install/#caching
|
For pip, the cache directory will vary by OS. See https://pip.pypa.io/en/stable/reference/pip_install/#caching
|
||||||
|
|
||||||
Locations:
|
Locations:
|
||||||
- Ubuntu: `~/.cache/pip`
|
|
||||||
- Windows: `~\AppData\Local\pip\Cache`
|
- Ubuntu: `~/.cache/pip`
|
||||||
- macOS: `~/Library/Caches/pip`
|
- Windows: `~\AppData\Local\pip\Cache`
|
||||||
|
- macOS: `~/Library/Caches/pip`
|
||||||
|
|
||||||
### Simple example
|
### Simple example
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: actions/cache@v2
|
- uses: actions/cache@v2
|
||||||
with:
|
with:
|
||||||
|
@ -421,11 +462,13 @@ jobs:
|
||||||
For renv, the cache directory will vary by OS. Look at https://rstudio.github.io/renv/articles/renv.html#cache
|
For renv, the cache directory will vary by OS. Look at https://rstudio.github.io/renv/articles/renv.html#cache
|
||||||
|
|
||||||
Locations:
|
Locations:
|
||||||
- Ubuntu: `~/.local/share/renv`
|
|
||||||
- macOS: `~/Library/Application Support/renv`
|
- Ubuntu: `~/.local/share/renv`
|
||||||
- Windows: `%LOCALAPPDATA%/renv`
|
- macOS: `~/Library/Application Support/renv`
|
||||||
|
- Windows: `%LOCALAPPDATA%/renv`
|
||||||
|
|
||||||
### Simple example
|
### Simple example
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: actions/cache@v2
|
- uses: actions/cache@v2
|
||||||
with:
|
with:
|
||||||
|
@ -487,9 +530,11 @@ whenever possible:
|
||||||
- uses: actions/cache@v2
|
- uses: actions/cache@v2
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
~/.cargo/registry
|
~/.cargo/bin/
|
||||||
~/.cargo/git
|
~/.cargo/registry/index/
|
||||||
target
|
~/.cargo/registry/cache/
|
||||||
|
~/.cargo/git/db/
|
||||||
|
target/
|
||||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
2
package-lock.json
generated
2
package-lock.json
generated
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "cache",
|
"name": "cache",
|
||||||
"version": "2.1.5",
|
"version": "2.1.6",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "cache",
|
"name": "cache",
|
||||||
"version": "2.1.5",
|
"version": "2.1.6",
|
||||||
"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",
|
||||||
|
|
|
@ -4,6 +4,11 @@ import * as core from "@actions/core";
|
||||||
import { Events, Inputs, State } from "./constants";
|
import { Events, Inputs, State } from "./constants";
|
||||||
import * as utils from "./utils/actionUtils";
|
import * as utils from "./utils/actionUtils";
|
||||||
|
|
||||||
|
// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in
|
||||||
|
// @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to
|
||||||
|
// throw an uncaught exception. Instead of failing this action, just warn.
|
||||||
|
process.on("uncaughtException", e => utils.logWarning(e.message));
|
||||||
|
|
||||||
async function run(): Promise<void> {
|
async function run(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
if (utils.isGhes()) {
|
if (utils.isGhes()) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue