mirror of
https://github.com/julia-actions/cache.git
synced 2026-02-13 09:46:52 +08:00
Compare commits
47 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8ef8d3313f | ||
|
|
5867e4d730 | ||
|
|
2d9095b561 | ||
|
|
4616a55a79 | ||
|
|
ec00ba5d20 | ||
|
|
75868c023d | ||
|
|
d006556bca | ||
|
|
adbfa18f98 | ||
|
|
ed93024b72 | ||
|
|
3ea06f8ffc | ||
|
|
569d290d51 | ||
|
|
47d045b35a | ||
|
|
edf78a706c | ||
|
|
10913c2628 | ||
|
|
a364403e9b | ||
|
|
b695972eeb | ||
|
|
2ff65c9241 | ||
|
|
8618676e71 | ||
|
|
6bbc93575c | ||
|
|
a96f53eeda | ||
|
|
bb2ad8a6dc | ||
|
|
b45946153f | ||
|
|
26bda12c02 | ||
|
|
08f6ca9894 | ||
|
|
d696810071 | ||
|
|
643194b98c | ||
|
|
c314effe59 | ||
|
|
c38652fe18 | ||
|
|
ccbc2ac68e | ||
|
|
936559d9c8 | ||
|
|
c2e869b485 | ||
|
|
1835692219 | ||
|
|
24702b2b39 | ||
|
|
8441b1201b | ||
|
|
8684ae14b7 | ||
|
|
85cc05cd46 | ||
|
|
6ee77ae122 | ||
|
|
2f4c647fce | ||
|
|
745127cf80 | ||
|
|
d5841feac0 | ||
|
|
41e67bac8f | ||
|
|
d2b01b0f17 | ||
|
|
905462d72f | ||
|
|
8e86b8dd2a | ||
|
|
20058080ea | ||
|
|
ce20795e57 | ||
|
|
1dbed0efdd |
9
.github/dependabot.yml
vendored
Normal file
9
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
version: 2
|
||||||
|
|
||||||
|
updates:
|
||||||
|
|
||||||
|
# Keep dependencies for GitHub Actions up-to-date
|
||||||
|
- package-ecosystem: 'github-actions'
|
||||||
|
directory: '/'
|
||||||
|
schedule:
|
||||||
|
interval: 'daily'
|
||||||
84
.github/workflows/CI.yml
vendored
Normal file
84
.github/workflows/CI.yml
vendored
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- 'action.yml'
|
||||||
|
- '.github/**'
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- 'action.yml'
|
||||||
|
- '.github/**'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
generate-key:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
cache-name: ${{ steps.name.outputs.cache-name }}
|
||||||
|
steps:
|
||||||
|
- name: Generate random file
|
||||||
|
shell: 'julia --color=yes {0}'
|
||||||
|
run: 'write("random.txt", string(rand(10)))'
|
||||||
|
- name: Set cache-name as output
|
||||||
|
id: name
|
||||||
|
run: echo "cache-name=${{ hashFiles('random.txt') }}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
test-save:
|
||||||
|
needs: generate-key
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest, macOS-latest]
|
||||||
|
fail-fast: false
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
|
||||||
|
- name: Save cache
|
||||||
|
id: cache
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
cache-name: ${{ needs.generate-key.outputs.cache-name }}
|
||||||
|
- name: Check no artifacts dir
|
||||||
|
shell: 'julia --color=yes {0}'
|
||||||
|
run: |
|
||||||
|
dir = joinpath(first(DEPOT_PATH), "artifacts")
|
||||||
|
@assert !isdir(dir)
|
||||||
|
- name: Install a small binary
|
||||||
|
shell: 'julia --color=yes {0}'
|
||||||
|
run: 'using Pkg; Pkg.add("pandoc_jll")'
|
||||||
|
|
||||||
|
test-restore:
|
||||||
|
needs: [generate-key, test-save]
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest, macOS-latest]
|
||||||
|
fail-fast: false
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
|
||||||
|
- name: Restore cache
|
||||||
|
id: cache
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
cache-name: ${{ needs.generate-key.outputs.cache-name }}
|
||||||
|
- name: Test cache-hit output
|
||||||
|
shell: 'julia --color=yes {0}'
|
||||||
|
run: |
|
||||||
|
@show ENV["cache-hit"]
|
||||||
|
@assert ENV["cache-hit"] == "true"
|
||||||
|
env:
|
||||||
|
cache-hit: ${{ steps.cache.outputs.cache-hit }}
|
||||||
|
- name: Check existance or emptiness of affected dirs
|
||||||
|
shell: 'julia --color=yes {0}'
|
||||||
|
run: |
|
||||||
|
# Artifacts and Packages should exist as they've been cached
|
||||||
|
artifacts_dir = joinpath(first(DEPOT_PATH), "artifacts")
|
||||||
|
@assert !isempty(readdir(artifacts_dir))
|
||||||
|
packages_dir = joinpath(first(DEPOT_PATH), "packages")
|
||||||
|
@assert !isempty(readdir(packages_dir))
|
||||||
|
|
||||||
|
# Caching the compiled dir is disabled by default and should not exist after restoring a cache
|
||||||
|
compiled_dir = joinpath(first(DEPOT_PATH), "compiled")
|
||||||
|
@assert !isdir(compiled_dir) || isempty(readdir(compiled_dir))
|
||||||
|
|
||||||
84
README.md
84
README.md
@@ -1,63 +1,77 @@
|
|||||||
# cache-artifacts
|
# julia-actions/cache Action
|
||||||
A shortcut action to cache Julia artifacts.
|
|
||||||
|
|
||||||
Using this action is equivalent to including the following step in your workflows:
|
A shortcut action to cache Julia artifacts, packages and (optionally) registries to reduce GitHub Actions running time.
|
||||||
|
|
||||||
```yaml
|
|
||||||
- uses: actions/cache@v1
|
|
||||||
env:
|
|
||||||
cache-name: cache-artifacts
|
|
||||||
with:
|
|
||||||
path: ~/.julia/artifacts
|
|
||||||
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-test-${{ env.cache-name }}-
|
|
||||||
${{ runner.os }}-test-
|
|
||||||
${{ runner.os }}-
|
|
||||||
```
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
### Inputs
|
An example workflow that uses this action might look like this:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: julia-actions/cache-artifacts@v1
|
name: CI
|
||||||
with:
|
|
||||||
# The cache name is used as part of the cache key.
|
on: [push, pull_request]
|
||||||
# It is equivalent to the cache-name environment variable in the snippet above.
|
|
||||||
#
|
jobs:
|
||||||
# Default: cache-artifacts
|
test:
|
||||||
cache-name: ''
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: julia-actions/setup-julia@v1
|
||||||
|
- uses: julia-actions/cache@v1
|
||||||
|
- uses: julia-actions/julia-buildpkg@v1
|
||||||
|
- uses: julia-actions/julia-runtest@v1
|
||||||
```
|
```
|
||||||
|
|
||||||
|
By default, this caches the files in `~/.julia/artifacts/` and `~/.julia/packages/`.
|
||||||
|
To also cache `~/.julia/registries/`, use
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- uses: julia-actions/cache@v1
|
||||||
|
with:
|
||||||
|
cache-registries: "true"
|
||||||
|
```
|
||||||
|
|
||||||
|
Note that caching the registries may actually slow down the workflow running time on Windows runners.
|
||||||
|
That is why caching the registries is disabled by default.
|
||||||
|
|
||||||
|
### Inputs
|
||||||
|
|
||||||
|
- `cache-name` - Name used as part of the cache keys
|
||||||
|
- `cache-artifacts` - Whether to cache `~/.julia/artifacts/`. Enabled by default.
|
||||||
|
- `cache-packages` - Whether to cache `~/.julia/packages/`. Enabled by default.
|
||||||
|
- `cache-registries` - Whether to cache `~/.julia/registries/`. Disabled by default.
|
||||||
|
- `cache-compiled` - Whether to cache `~/.julia/compiled/`. Disabled by default. **USE ONLY IF YOU KNOW WHAT YOU'RE DOING!** See [#11](https://github.com/julia-actions/cache/issues/11).
|
||||||
|
- `cache-scratchspaces` - Whether to cache `~/.julia/scratchspaces/`. Enabled by default.
|
||||||
|
|
||||||
### Outputs
|
### Outputs
|
||||||
|
|
||||||
```yaml
|
- `cache-hit` - A boolean value to indicate an exact match was found for the primary key. Returns \"\" when the key is new. Forwarded from actions/cache.
|
||||||
outputs:
|
|
||||||
# A boolean value to indicate an exact match was found for the primary key.
|
## How it works
|
||||||
# Forwarded from actions/cache, check its documentation for more info.
|
|
||||||
cache-hit: ''
|
This action is a wrapper around <https://github.com/actions/cache>.
|
||||||
```
|
In summary, this action stores the files in the aforementioned paths in one compressed file when running for the first time.
|
||||||
|
This cached file is then restored upon the second run.
|
||||||
|
The benefit of this is that downloading one big file is quicker than downloading many different files from many different locations.
|
||||||
|
|
||||||
## Third Party Notice
|
## Third Party Notice
|
||||||
|
|
||||||
This action is built around [`actions/cache`](https://github.com/actions/cache/) and includes parts of that action. `actions/cache` has been released under the following licence:
|
This action is built around [`actions/cache`](https://github.com/actions/cache/) and includes parts of that action. `actions/cache` has been released under the following licence:
|
||||||
|
|
||||||
|
|
||||||
> The MIT License (MIT)
|
> The MIT License (MIT)
|
||||||
>
|
>
|
||||||
> Copyright (c) 2018 GitHub, Inc. and contributors
|
> Copyright (c) 2018 GitHub, Inc. and contributors
|
||||||
>
|
>
|
||||||
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
> of this software and associated documentation files (the "Software"), to deal
|
> of this software and associated documentation files (the "Software"), to deal
|
||||||
> in the Software without restriction, including without limitation the rights
|
> in the Software without restriction, including without limitation the rights
|
||||||
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
> copies of the Software, and to permit persons to whom the Software is
|
> copies of the Software, and to permit persons to whom the Software is
|
||||||
> furnished to do so, subject to the following conditions:
|
> furnished to do so, subject to the following conditions:
|
||||||
>
|
>
|
||||||
> The above copyright notice and this permission notice shall be included in
|
> The above copyright notice and this permission notice shall be included in
|
||||||
> all copies or substantial portions of the Software.
|
> all copies or substantial portions of the Software.
|
||||||
>
|
>
|
||||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
|||||||
53
action.yml
53
action.yml
@@ -1,6 +1,6 @@
|
|||||||
name: 'Cache Julia Artifacts'
|
name: 'Cache Julia artifacts, packages and registry'
|
||||||
description: 'Cache Julia artifacts using actions/cache'
|
description: 'Cache Julia using actions/cache'
|
||||||
author: 'Sascha Mann'
|
author: 'Sascha Mann, Rik Huijzer, and contributors'
|
||||||
|
|
||||||
branding:
|
branding:
|
||||||
icon: 'archive'
|
icon: 'archive'
|
||||||
@@ -9,26 +9,55 @@ branding:
|
|||||||
inputs:
|
inputs:
|
||||||
cache-name:
|
cache-name:
|
||||||
description: 'Name used as part of the cache keys'
|
description: 'Name used as part of the cache keys'
|
||||||
default: 'cache-artifacts'
|
default: 'julia-cache'
|
||||||
|
cache-artifacts:
|
||||||
|
description: 'Whether to cache ~/.julia/artifacts/'
|
||||||
|
default: 'true'
|
||||||
|
cache-packages:
|
||||||
|
description: 'Whether to cache ~/.julia/packages/'
|
||||||
|
default: 'true'
|
||||||
|
cache-registries:
|
||||||
|
description: 'Whether to cache ~/.julia/registries/'
|
||||||
|
default: 'false'
|
||||||
|
cache-compiled:
|
||||||
|
description: 'Whether to cache ~/.julia/compiled. USE WITH CAUTION! See https://github.com/julia-actions/cache/issues/11 for caveats.'
|
||||||
|
default: 'false'
|
||||||
|
cache-scratchspaces:
|
||||||
|
description: 'Whether to cache ~/.julia/scratchspaces/'
|
||||||
|
default: 'true'
|
||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
cache-hit:
|
cache-hit:
|
||||||
description: 'A boolean value to indicate an exact match was found for the primary key. Forwarded from actions/cache'
|
description: 'A boolean value to indicate an exact match was found for the primary key. Returns \"\" when the key is new. Forwarded from actions/cache'
|
||||||
|
value: ${{ steps.hit.outputs.cache-hit }}
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: 'composite'
|
using: 'composite'
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/cache@937d24475381cd9c75ae6db12cb4e79714b926ed
|
- id: paths
|
||||||
|
run: |
|
||||||
|
[ "${{ inputs.cache-artifacts }}" = "true" ] && A_PATH="~/.julia/artifacts"
|
||||||
|
echo "artifacts-path=$A_PATH" >> $GITHUB_OUTPUT
|
||||||
|
[ "${{ inputs.cache-packages }}" = "true" ] && P_PATH="~/.julia/packages"
|
||||||
|
echo "packages-path=$P_PATH" >> $GITHUB_OUTPUT
|
||||||
|
[ "${{ inputs.cache-registries }}" = "true" ] && R_PATH="~/.julia/registries"
|
||||||
|
echo "registries-path=$R_PATH" >> $GITHUB_OUTPUT
|
||||||
|
[ "${{ inputs.cache-compiled }}" = "true" ] && PCC_PATH="~/.julia/compiled"
|
||||||
|
echo "precompilation-cache-path=$PCC_PATH" >> $GITHUB_OUTPUT
|
||||||
|
[ "${{ inputs.cache-scratchspaces }}" = "true" ] && S_PATH="~/.julia/scratchspaces"
|
||||||
|
echo "scratchspaces-path=$S_PATH" >> $GITHUB_OUTPUT
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84
|
||||||
id: cache
|
id: cache
|
||||||
with:
|
with:
|
||||||
path: ~/.julia/artifacts
|
path: "${{ format('{0}\n{1}\n{2}\n{3}\n{4}', steps.paths.outputs.artifacts-path, steps.paths.outputs.packages-path, steps.paths.outputs.registries-path, steps.paths.outputs.precompilation-cache-path, steps.paths.outputs.scratchspaces-path) }}"
|
||||||
key: ${{ runner.os }}-test-${{ inputs.cache-name }}-${{ hashFiles('**/Project.toml') }}
|
key: ${{ runner.os }}-${{ inputs.cache-name }}-${{ hashFiles('**/Project.toml') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-test-${{ inputs.cache-name }}-
|
${{ runner.os }}-${{ inputs.cache-name }}-
|
||||||
${{ runner.os }}-test-
|
|
||||||
${{ runner.os }}-
|
|
||||||
|
|
||||||
- run: echo "::set-output name=cache-hit::$CACHE_HIT"
|
- id: hit
|
||||||
|
run: echo "cache-hit=$CACHE_HIT" >> $GITHUB_OUTPUT
|
||||||
env:
|
env:
|
||||||
CACHE_HIT: ${{ steps.cache.outputs.cache-hit }}
|
CACHE_HIT: ${{ steps.cache.outputs.cache-hit }}
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|||||||
Reference in New Issue
Block a user