Skip to content

Commit

Permalink
Minimal cache experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
mosteo committed Jun 27, 2024
1 parent 9f17612 commit 8406906
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 12 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/cache-minimal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Test minimal save/restore of a cache

name: Minimal cache test

on:
push:
branches:
- disabled

jobs:
minimal-cache:
runs-on: ubuntu-latest

steps:
- name: Create fake data
run: |
mkdir mydata
touch mydata/thedata.txt
- name: Create unique key
id: cache-key
run: |
echo "key=cache test $(date -u)" >> $GITHUB_OUTPUT
- name: Verify cache miss
id: miss
uses: actions/cache/restore@v4
with:
path: mydata
key: ${{ steps.cache-key.outputs.key }}
lookup-only: true

- name: Save cache
uses: actions/cache/save@v4
with:
path: mydata
key: ${{ steps.cache-key.outputs.key }}

- name: Query cache hit
id: hit
uses: actions/cache/restore@v4
with:
path: mydata
key: ${{ steps.cache-key.outputs.key }}
fail-on-cache-miss: true
lookup-only: true

- name: Print both cache hit and miss
run: |
echo "Cache miss? ${{ steps.miss.outputs.cache-hit }}"
echo "Cache hit? ${{ steps.hit.outputs.cache-hit }}"
17 changes: 10 additions & 7 deletions .github/workflows/test-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,19 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
os:
# - macos-latest
- ubuntu-latest
# - windows-latest
config:
- version: '2.0.1'
branch: ''
- version: '1.2.2'
branch: ''
- version: 'nightly'
branch: ''
- version: ''
branch: 'master'
# - version: '1.2.2'
# branch: ''
# - version: 'nightly'
# branch: ''
# - version: ''
# branch: 'master'

runs-on: ${{ matrix.os }}

Expand Down
9 changes: 4 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ runs:
id: cache-key
shell: bash
run: |
echo "key=alr[${{ steps.find-hash.outputs.version }}][${{ inputs.toolchain }}][${{ runner.os }}][${{ steps.find-hash.outputs.hash }}][c]" >> $GITHUB_OUTPUT
echo "key=alr[${{ steps.find-hash.outputs.version }}][${{ inputs.toolchain }}][${{ runner.os }}][${{ steps.find-hash.outputs.hash }}][d]" >> $GITHUB_OUTPUT
# The last value in square brackets is to make the key unique for debugging

- name: Reuse cached installation
Expand Down Expand Up @@ -181,9 +181,8 @@ runs:
~/.local/share/alire
./alire_install
~/AppData/Local/alire
key: ${{ steps.cache-alr.outputs.cache-primary-key }}
# Note that '~' is recommended on Windows too:
# https://github.com/actions/cache
key: ${{ steps.cache-key.outputs.key }}
# Note that '~' is recommended on Windows too: https://github.com/actions/cache

# Verify cache was saved properly
- name: Cache verify
Expand All @@ -193,5 +192,5 @@ runs:
path: unused # Forced to provide it
key: ${{steps.cache-key.outputs.key}}
lookup-only: true
fail-on-cache-miss: true
fail-on-cache-miss: true # REMOVE BEFORE MERGE

0 comments on commit 8406906

Please sign in to comment.