mirror of
https://github.com/julia-actions/cache.git
synced 2026-02-12 01:16:54 +08:00
Extend cache action (#4)
* Extend cache action * Also test on Windows and macOS * Fix a problem with setting output on Windows * Use echo after set-output * Generate key only once * Fix non-matching name (should fail but doesn't weirdly) * Update action.yml Co-authored-by: Sascha Mann <git@mail.saschamann.eu> * Update action.yml Co-authored-by: Sascha Mann <git@mail.saschamann.eu> Co-authored-by: Sascha Mann <git@mail.saschamann.eu>
This commit is contained in:
37
.github/workflows/CI.yml
vendored
37
.github/workflows/CI.yml
vendored
@@ -11,27 +11,34 @@ on:
|
||||
- 'action.yml'
|
||||
|
||||
jobs:
|
||||
test-save:
|
||||
generate-key:
|
||||
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: Set cache-name as output
|
||||
id: name
|
||||
run: echo "::set-output name=cache-name::$(echo $CACHE_NAME)"
|
||||
env:
|
||||
CACHE_NAME: ${{ hashFiles('random.txt') }}
|
||||
|
||||
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@ec3a7ce113134d7a93b817d10a8272cb61118579
|
||||
- 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') }}
|
||||
cache-name: ${{ needs.generate-key.outputs.cache-name }}
|
||||
- name: Check no artifacts dir
|
||||
shell: 'julia --color=yes {0}'
|
||||
run: |
|
||||
@@ -42,15 +49,19 @@ jobs:
|
||||
run: 'using Pkg; Pkg.add("pandoc_jll")'
|
||||
|
||||
test-restore:
|
||||
needs: test-save
|
||||
runs-on: ubuntu-latest
|
||||
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@ec3a7ce113134d7a93b817d10a8272cb61118579
|
||||
- name: Restore cache
|
||||
id: cache
|
||||
uses: ./
|
||||
with:
|
||||
cache-name: ${{ needs.test-save.outputs.cache-name }}
|
||||
cache-name: ${{ needs.generate-key.outputs.cache-name }}
|
||||
- name: Test cache-hit output
|
||||
shell: 'julia --color=yes {0}'
|
||||
run: |
|
||||
|
||||
Reference in New Issue
Block a user