From 4790dfc4259973b9ab9b3b1e00d1e30f8a54c906 Mon Sep 17 00:00:00 2001 From: Andreas Abel Date: Mon, 20 Nov 2023 17:39:10 +0800 Subject: [PATCH] CI caching: split restore and save into separate steps --- .github/workflows/test-linux.yaml | 38 ++++++++++++++++++++----- .github/workflows/test-mac.yaml | 44 +++++++++++++++++++++++------ .github/workflows/test-windows.yaml | 43 ++++++++++++++++++++++------ 3 files changed, 100 insertions(+), 25 deletions(-) diff --git a/.github/workflows/test-linux.yaml b/.github/workflows/test-linux.yaml index 92d08ea..919c014 100644 --- a/.github/workflows/test-linux.yaml +++ b/.github/workflows/test-linux.yaml @@ -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') }} @@ -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 }} diff --git a/.github/workflows/test-mac.yaml b/.github/workflows/test-mac.yaml index d5c1820..5cd996c 100644 --- a/.github/workflows/test-mac.yaml +++ b/.github/workflows/test-mac.yaml @@ -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') }} @@ -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 diff --git a/.github/workflows/test-windows.yaml b/.github/workflows/test-windows.yaml index cfb3ba5..2a0bcfe 100644 --- a/.github/workflows/test-windows.yaml +++ b/.github/workflows/test-windows.yaml @@ -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 ? @@ -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') }} @@ -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