mirror of
https://github.com/julia-actions/cache.git
synced 2026-02-12 09:26:53 +08:00
Add basic test (#1)
* Update action.yml * Add basic test * Add needs * Fix unexpected symbol * Assert isdir * Update CI.yml * Add mktempdir * Write random Project.toml * Switch to assert isempty * Use random.txt * Be more strict in restore-keys * Assert isempty dir * Fix CI? * Restore gonna fail * Fix save? * Pass cache name * Fix typo * Fix bash string subst * Fix typo * Use string * Remove Project.toml * Remove change to action.yml * Fix CI (#3) * Small change * Use DEPOT_PATH * Fix CI? * Pass name better * Changes * Change id * Add a show * Fix CI? * Fix CI? * Fix CI? * Also output cache-hit * Add echo * Fix missing outputs * Fix CI? * Improve log * Improve log * Improve log * Try different actions/cache version * Check for empty * Check for empty * Fix syntax error * Try something else * Propagate value * Temporarily use restore * Update test-save * Simplify * Apply suggestions from code review Co-authored-by: Sascha Mann <git@mail.saschamann.eu> * Add basic test (#2) * Add basic test * Add needs * Fix unexpected symbol * Assert isdir * Update CI.yml * Add mktempdir * Write random Project.toml * Switch to assert isempty * Use random.txt * Be more strict in restore-keys * Assert isempty dir * Fix CI? * Restore gonna fail * Fix save? * Pass cache name * Fix typo * Fix bash string subst * Fix typo * Use string * Remove Project.toml * Remove change to action.yml * Fix CI (#3) * Small change * Use DEPOT_PATH * Fix CI? * Pass name better * Changes * Change id * Add a show * Fix CI? * Fix CI? * Fix CI? * Also output cache-hit * Add echo * Fix missing outputs * Fix CI? * Improve log * Improve log * Improve log * Try different actions/cache version * Check for empty * Check for empty * Fix syntax error * Try something else * Propagate value * Temporarily use restore * Update test-save * Simplify * Apply suggestions from code review Co-authored-by: Sascha Mann <git@mail.saschamann.eu> * Also cache packages and registry * Only cache artifacts * Revert name and description Co-authored-by: Sascha Mann <git@mail.saschamann.eu>
This commit is contained in:
67
.github/workflows/CI.yml
vendored
Normal file
67
.github/workflows/CI.yml
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'action.yml'
|
||||
pull_request:
|
||||
paths:
|
||||
- 'action.yml'
|
||||
|
||||
jobs:
|
||||
test-save:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
cache-name: ${{ steps.name.outputs.cache-name }}
|
||||
steps:
|
||||
- uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
|
||||
- name: Generate random file
|
||||
shell: 'julia --color=yes {0}'
|
||||
run: 'write("random.txt", string(rand(10)))'
|
||||
- name: Save cache
|
||||
id: cache
|
||||
uses: ./
|
||||
with:
|
||||
cache-name: ${{ hashFiles('random.txt') }}
|
||||
- name: Set cache-name as output
|
||||
id: name
|
||||
run: |
|
||||
echo "Setting outputs.cache-name to \"$CACHE_NAME\""
|
||||
echo "::set-output name=cache-name::$CACHE_NAME"
|
||||
env:
|
||||
CACHE_NAME: ${{ hashFiles('random.txt') }}
|
||||
- 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: test-save
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
|
||||
- name: Restore cache
|
||||
id: cache
|
||||
uses: ./
|
||||
with:
|
||||
cache-name: ${{ needs.test-save.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 non-empty artifacts dir
|
||||
shell: 'julia --color=yes {0}'
|
||||
run: |
|
||||
dir = joinpath(first(DEPOT_PATH), "artifacts")
|
||||
@assert isdir(dir)
|
||||
@assert !isempty(readdir(dir))
|
||||
|
||||
11
action.yml
11
action.yml
@@ -13,7 +13,8 @@ inputs:
|
||||
|
||||
outputs:
|
||||
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:
|
||||
using: 'composite'
|
||||
@@ -21,14 +22,14 @@ runs:
|
||||
- uses: actions/cache@937d24475381cd9c75ae6db12cb4e79714b926ed
|
||||
id: cache
|
||||
with:
|
||||
path: ~/.julia/artifacts
|
||||
path: |
|
||||
~/.julia/artifacts
|
||||
key: ${{ runner.os }}-test-${{ inputs.cache-name }}-${{ hashFiles('**/Project.toml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-test-${{ inputs.cache-name }}-
|
||||
${{ runner.os }}-test-
|
||||
${{ runner.os }}-
|
||||
|
||||
- run: echo "::set-output name=cache-hit::$CACHE_HIT"
|
||||
- id: hit
|
||||
run: echo "::set-output name=cache-hit::$(echo $CACHE_HIT)"
|
||||
env:
|
||||
CACHE_HIT: ${{ steps.cache.outputs.cache-hit }}
|
||||
shell: bash
|
||||
|
||||
Reference in New Issue
Block a user