Update cache every run. Add /compiled and /logs. Make key sensitive to matrix. (#71)

Co-authored-by: Rik Huijzer <github@huijzer.xyz>
Co-authored-by: Sascha Mann <git@mail.saschamann.eu>
This commit is contained in:
Ian Butterworth
2023-11-25 00:08:21 -05:00
committed by GitHub
parent b606b82bd0
commit 3466649946
4 changed files with 206 additions and 29 deletions

View File

@@ -6,10 +6,12 @@ on:
- main
paths:
- 'action.yml'
- 'handle_caches.jl'
- '.github/**'
pull_request:
paths:
- 'action.yml'
- 'handle_caches.jl'
- '.github/**'
jobs:
@@ -48,6 +50,26 @@ jobs:
shell: 'julia --color=yes {0}'
run: 'using Pkg; Pkg.add("pandoc_jll")'
# Do tests with no matrix also given the matrix is auto-included in cache key
test-save-nomatrix:
needs: generate-key
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- 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:
@@ -72,13 +94,47 @@ jobs:
- name: Check existance or emptiness of affected dirs
shell: 'julia --color=yes {0}'
run: |
# Artifacts and Packages should exist as they've been cached
# These dirs 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))
@assert !isempty(readdir(compiled_dir))
scratchspaces_dir = joinpath(first(DEPOT_PATH), "scratchspaces")
@assert !isempty(readdir(scratchspaces_dir))
logs_dir = joinpath(first(DEPOT_PATH), "logs")
@assert !isempty(readdir(logs_dir))
test-restore-nomatrix:
needs: [generate-key, test-save-nomatrix]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- 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: |
# These dirs 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))
compiled_dir = joinpath(first(DEPOT_PATH), "compiled")
@assert !isempty(readdir(compiled_dir))
scratchspaces_dir = joinpath(first(DEPOT_PATH), "scratchspaces")
@assert !isempty(readdir(scratchspaces_dir))
logs_dir = joinpath(first(DEPOT_PATH), "logs")
@assert !isempty(readdir(logs_dir))