mirror of
https://github.com/julia-actions/cache.git
synced 2026-02-12 09:26:53 +08:00
Also test packages dir (#5)
* Also test packages dir * Fix passing of newlines into path
This commit is contained in:
15
.github/workflows/CI.yml
vendored
15
.github/workflows/CI.yml
vendored
@@ -6,9 +6,11 @@ on:
|
|||||||
- main
|
- main
|
||||||
paths:
|
paths:
|
||||||
- 'action.yml'
|
- 'action.yml'
|
||||||
|
- '.github/**'
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
- 'action.yml'
|
- 'action.yml'
|
||||||
|
- '.github/**'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
generate-key:
|
generate-key:
|
||||||
@@ -21,9 +23,7 @@ jobs:
|
|||||||
run: 'write("random.txt", string(rand(10)))'
|
run: 'write("random.txt", string(rand(10)))'
|
||||||
- name: Set cache-name as output
|
- name: Set cache-name as output
|
||||||
id: name
|
id: name
|
||||||
run: echo "::set-output name=cache-name::$(echo $CACHE_NAME)"
|
run: echo "::set-output name=cache-name::${{ hashFiles('random.txt') }}"
|
||||||
env:
|
|
||||||
CACHE_NAME: ${{ hashFiles('random.txt') }}
|
|
||||||
|
|
||||||
test-save:
|
test-save:
|
||||||
needs: generate-key
|
needs: generate-key
|
||||||
@@ -69,10 +69,11 @@ jobs:
|
|||||||
@assert ENV["cache-hit"] == "true"
|
@assert ENV["cache-hit"] == "true"
|
||||||
env:
|
env:
|
||||||
cache-hit: ${{ steps.cache.outputs.cache-hit }}
|
cache-hit: ${{ steps.cache.outputs.cache-hit }}
|
||||||
- name: Check non-empty artifacts dir
|
- name: Check non-empty artifacts and packages dir
|
||||||
shell: 'julia --color=yes {0}'
|
shell: 'julia --color=yes {0}'
|
||||||
run: |
|
run: |
|
||||||
dir = joinpath(first(DEPOT_PATH), "artifacts")
|
artifacts_dir = joinpath(first(DEPOT_PATH), "artifacts")
|
||||||
@assert isdir(dir)
|
@assert !isempty(readdir(artifacts_dir))
|
||||||
@assert !isempty(readdir(dir))
|
packages_dir = joinpath(first(DEPOT_PATH), "packages")
|
||||||
|
@assert !isempty(readdir(packages_dir))
|
||||||
|
|
||||||
|
|||||||
29
action.yml
29
action.yml
@@ -11,13 +11,13 @@ inputs:
|
|||||||
description: 'Name used as part of the cache keys'
|
description: 'Name used as part of the cache keys'
|
||||||
default: 'julia-cache'
|
default: 'julia-cache'
|
||||||
cache-artifacts:
|
cache-artifacts:
|
||||||
description: 'Whether to cache artifacts'
|
description: 'Whether to cache ~/.julia/artifacts/'
|
||||||
default: 'true'
|
default: 'true'
|
||||||
cache-packages:
|
cache-packages:
|
||||||
description: 'Whether to cache packages'
|
description: 'Whether to cache ~/.julia/packages/'
|
||||||
default: 'true'
|
default: 'true'
|
||||||
cache-registry:
|
cache-registries:
|
||||||
description: 'Whether to cache the registry'
|
description: 'Whether to cache ~/.julia/registries/'
|
||||||
default: 'false'
|
default: 'false'
|
||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
@@ -30,25 +30,18 @@ runs:
|
|||||||
steps:
|
steps:
|
||||||
- id: paths
|
- id: paths
|
||||||
run: |
|
run: |
|
||||||
PATHS=""
|
[ "${{ inputs.cache-artifacts }}" = "true" ] && A_PATH="~/.julia/artifacts"
|
||||||
[ "$CACHE_ARTIFACTS" = "true" ] && PATHS="${PATHS}~/.julia/artifacts"$'\n'
|
echo "ARTIFACTS_PATH=$A_PATH" >> $GITHUB_ENV
|
||||||
[ "$CACHE_PACKAGES" = "true" ] && PATHS="${PATHS}~/.julia/packages"$'\n'
|
[ "${{ inputs.cache-packages }}" = "true" ] && P_PATH="~/.julia/packages"
|
||||||
[ "$CACHE_REGISTRY" = "true" ] && PATHS="${PATHS}~/.julia/registry"$'\n'
|
echo "PACKAGES_PATH=$P_PATH" >> $GITHUB_ENV
|
||||||
if [ "$PATHS" = "" ]; then
|
[ "${{ inputs.cache-registries }}" = "true" ] && R_PATH="~/.julia/registries"
|
||||||
echo "::error title=Invalid inputs::At least one of cache-artifacts, cache-packages or cache-registry has to be true"
|
echo "REGISTRIES_PATH=$R_PATH" >> $GITHUB_ENV
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "::set-output name=cache-paths::$PATHS"
|
|
||||||
env:
|
|
||||||
CACHE_ARTIFACTS: ${{ inputs.cache-artifacts }}
|
|
||||||
CACHE_PACKAGES: ${{ inputs.cache-packages }}
|
|
||||||
CACHE_REGISTRY: ${{ inputs.cache-registry }}
|
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- uses: actions/cache@937d24475381cd9c75ae6db12cb4e79714b926ed
|
- uses: actions/cache@937d24475381cd9c75ae6db12cb4e79714b926ed
|
||||||
id: cache
|
id: cache
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.paths.outputs.cache-paths }}
|
path: "${{ format('{0}\n{1}\n{2}', env.ARTIFACTS_PATH, env.PACKAGES_PATH, env.REGISTRIES_PATH) }}"
|
||||||
key: ${{ runner.os }}-test-${{ inputs.cache-name }}-${{ hashFiles('**/Project.toml') }}
|
key: ${{ runner.os }}-test-${{ inputs.cache-name }}-${{ hashFiles('**/Project.toml') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-test-${{ inputs.cache-name }}-
|
${{ runner.os }}-test-${{ inputs.cache-name }}-
|
||||||
|
|||||||
Reference in New Issue
Block a user