Skip to content

Commit

Permalink
CI caching: split restore and save into separate steps
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasabel committed Nov 20, 2023
1 parent a572c66 commit 4790dfc
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 25 deletions.
38 changes: 31 additions & 7 deletions .github/workflows/test-linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,29 @@ jobs:
- name: 📥 Checkout repository
uses: actions/checkout@v4

# things to be cached/restored:
# things to be restored:

- name: 💾 Cache stack global package db
- name: 💾 Restore cached stack global package db
id: stack-global
uses: actions/cache@v3
uses: actions/cache/restore@v3
with:
path: ~/.stack
key: ${{ runner.os }}-stack-global-${{ hashFiles('**.yaml') }}
restore-keys: |
${{ runner.os }}-stack-global
- name: 💾 Cache stack-installed programs in ~/.local/bin
- name: 💾 Restore cached stack-installed programs in ~/.local/bin
id: stack-programs
uses: actions/cache@v3
uses: actions/cache/restore@v3
with:
path: ~/.local/bin
key: ${{ runner.os }}-stack-programs-${{ hashFiles('**.yaml') }}
restore-keys: |
${{ runner.os }}-stack-programs
- name: 💾 Cache .stack-work
uses: actions/cache@v3
- name: 💾 Restore cached .stack-work
id: stack-work
uses: actions/cache/restore@v3
with:
path: .stack-work
key: ${{ runner.os }}-stack-work-${{ hashFiles('**.yaml') }}
Expand Down Expand Up @@ -93,9 +94,32 @@ jobs:
- name: 🚢 Release Artifacts
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/') # so that only commits with a git tag would upload artifacts
# things to be cached

- name: 💾 Cache stack global package db
if: always() && steps.stack-global.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
files: als-ubuntu.zip
draft: true
prerelease: true
path: ~/.stack
key: ${{ steps.stack-global.outputs.cache-primary-key }}

- name: 💾 Cache stack-installed programs in ~/.local/bin
if: always() && steps.stack-programs.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: ~/.local/bin
key: ${{ steps.stack-programs.outputs.cache-primary-key }}

- name: 💾 Cache .stack-work
if: always() && steps.stack-work.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: .stack-work
key: ${{ steps.stack-work.outputs.cache-primary-key }}

# release (optional)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44 changes: 35 additions & 9 deletions .github/workflows/test-mac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,29 @@ jobs:
- name: 📥 Checkout repository
uses: actions/checkout@v4

# things to be cached/restored:
# things to be restored:

- name: 💾 Cache stack global package db
- name: 💾 Restore cached stack global package db
id: stack-global
uses: actions/cache@v3
uses: actions/cache/restore@v3
with:
path: ~/.stack
key: ${{ runner.os }}-stack-global-after20210110-${{ hashFiles('**.yaml') }}
key: ${{ runner.os }}-stack-global-${{ hashFiles('**.yaml') }}
restore-keys: |
${{ runner.os }}-stack-global-after202110110
${{ runner.os }}-stack-global
- name: 💾 Cache stack-installed programs in ~/.local/bin
- name: 💾 Restore cached stack-installed programs in ~/.local/bin
id: stack-programs
uses: actions/cache@v3
uses: actions/cache/restore@v3
with:
path: ~/.local/bin
key: ${{ runner.os }}-stack-programs-${{ hashFiles('**.yaml') }}
restore-keys: |
${{ runner.os }}-stack-programs
- name: 💾 Cache .stack-work
uses: actions/cache@v3
- name: 💾 Restore cached .stack-work
id: stack-work
uses: actions/cache/restore@v3
with:
path: .stack-work
key: ${{ runner.os }}-stack-work-${{ hashFiles('**.yaml') }}
Expand Down Expand Up @@ -70,6 +71,31 @@ jobs:
run: |
stack test
# things to be cached

- name: 💾 Cache stack global package db
if: always() && steps.stack-global.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: ~/.stack
key: ${{ steps.stack-global.outputs.cache-primary-key }}

- name: 💾 Cache stack-installed programs in ~/.local/bin
if: always() && steps.stack-programs.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: ~/.local/bin
key: ${{ steps.stack-programs.outputs.cache-primary-key }}

- name: 💾 Cache .stack-work
if: always() && steps.stack-work.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: .stack-work
key: ${{ steps.stack-work.outputs.cache-primary-key }}

# release (optional)

- name: 🔗 Bundle ICU4C DLLs
run: | # Bundle icu4c DLLs
Expand Down
43 changes: 34 additions & 9 deletions .github/workflows/test-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ jobs:
- name: 📥 Checkout repository
uses: actions/checkout@v4

# things to be cached/restored:
# things to be restored:

- name: 💾 Cache stack global package db
id: stack-global-package-db
uses: actions/cache@v3
- name: 💾 Restore cached stack global package db
id: stack-global
uses: actions/cache/restore@v3
with:
path: C:\Users\runneradmin\AppData\Roaming\stack\
key: ${{ runner.os }}-appdata-roaming-stack-${{ hashFiles('**.yaml') }}
restore-keys: |
${{ runner.os }}-appdata-roaming-stack
- name: 💾 Cache stack programs dir # ghc, ghc-included packages and their haddocks, mingw, msys2
id: stack-programs-dir
uses: actions/cache@v3
- name: 💾 Restore cached stack-installed programs in ~/.local/bin
id: stack-programs
uses: actions/cache/restore@v3
with:
path: C:\Users\runneradmin\AppData\Local\Programs\stack\
# which files signal a change in stack's global db ?
Expand All @@ -38,8 +38,9 @@ jobs:
restore-keys: |
${{ runner.os }}-appdata-local-programs-stack
- name: 💾 Cache .stack-work
uses: actions/cache@v3
- name: 💾 Restore cached .stack-work
id: stack-work
uses: actions/cache/restore@v3
with:
path: .stack-work
key: ${{ runner.os }}-stack-work-${{ hashFiles('**.yaml') }}
Expand Down Expand Up @@ -83,6 +84,30 @@ jobs:
run: |
./stack test
# things to be cached

- name: 💾 Cache stack global package db
if: always() && steps.stack-global.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: ~/.stack
key: ${{ steps.stack-global.outputs.cache-primary-key }}

- name: 💾 Cache stack-installed programs in ~/.local/bin
if: always() && steps.stack-programs.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: ~/.local/bin
key: ${{ steps.stack-programs.outputs.cache-primary-key }}

- name: 💾 Cache .stack-work
if: always() && steps.stack-work.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: .stack-work
key: ${{ steps.stack-work.outputs.cache-primary-key }}

# release (optional)
# artifacts:

- name: 📦 Compress executable and data files
Expand Down

0 comments on commit 4790dfc

Please sign in to comment.