Skip to content

Commit 109517c

Browse files
committed
[ ci ] Avoid tag-scoped cache saves
1 parent 36c9612 commit 109517c

2 files changed

Lines changed: 20 additions & 11 deletions

File tree

.github/workflows/test.yaml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,9 @@ jobs:
9797
echo GHC_VERSION="${GHC_VERSION}" >> "${GITHUB_ENV}"
9898
9999
- name: 💾 Cache Haskell toolchain
100+
id: haskell-toolchain
100101
if: runner.os == 'macOS'
101-
uses: actions/cache@v4
102+
uses: actions/cache/restore@v4
102103
with:
103104
path: |
104105
~/.ghcup
@@ -117,6 +118,16 @@ jobs:
117118
ghc-version: ${{ env.GHC_VERSION }}
118119
enable-stack: true
119120
stack-version: 'latest'
121+
122+
- name: 💾 Cache Haskell toolchain
123+
if: runner.os == 'macOS' && github.ref == 'refs/heads/master' && steps.haskell-toolchain.outputs.cache-hit != 'true'
124+
uses: actions/cache/save@v4
125+
with:
126+
path: |
127+
~/.ghcup
128+
~/.stack/programs
129+
~/.stack/pantry
130+
key: ${{ steps.haskell-toolchain.outputs.cache-primary-key }}
120131

121132
- name: 🎛️ Determine Stack root
122133
run: |
@@ -179,14 +190,14 @@ jobs:
179190
# things to be cached
180191

181192
- name: 💾 Cache stack global package db
182-
if: always() && steps.stack-global.outputs.cache-hit != 'true'
193+
if: always() && github.ref == 'refs/heads/master' && steps.stack-global.outputs.cache-hit != 'true'
183194
uses: actions/cache/save@v4
184195
with:
185196
path: ${{ env.STACK_ROOT }}
186197
key: ${{ steps.stack-global.outputs.cache-primary-key }}
187198

188199
- name: 💾 Cache .stack-work
189-
if: always() && steps.stack-work.outputs.cache-hit != 'true'
200+
if: always() && github.ref == 'refs/heads/master' && steps.stack-work.outputs.cache-hit != 'true'
190201
uses: actions/cache/save@v4
191202
with:
192203
path: .stack-work
@@ -477,7 +488,7 @@ jobs:
477488
478489
- name: Cache dist-newstyle
479490
uses: actions/cache/save@v4
480-
if: steps.build-deps-other-than-agda.outcome == 'success'
491+
if: github.ref == 'refs/heads/master' && steps.build-deps-other-than-agda.outcome == 'success'
481492
with:
482493
path: als/dist-newstyle
483494
key: ${{ steps.dist-newstyle-cache-key.outputs.key }}
@@ -496,7 +507,7 @@ jobs:
496507

497508
- name: Cache native cabal
498509
uses: actions/cache/save@v4
499-
if: steps.ghc-wasm-setup.outcome == 'success'
510+
if: github.ref == 'refs/heads/master' && steps.ghc-wasm-setup.outcome == 'success'
500511
with:
501512
path: |
502513
~/.config/cabal
@@ -505,7 +516,7 @@ jobs:
505516

506517
- name: Cache ghc-wasm-meta
507518
uses: actions/cache/save@v4
508-
if: steps.ghc-wasm-setup.outcome == 'success'
519+
if: github.ref == 'refs/heads/master' && steps.ghc-wasm-setup.outcome == 'success'
509520
with:
510521
path: ~/.ghc-wasm
511522
key: ${{ steps.ghc-wasm-cache-restore.outputs.cache-primary-key }}

.github/workflows/wasm.yaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ name: Compile WASM
33
on:
44
push:
55
branches: [wasm, wasm-*]
6-
tags:
7-
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
86
pull_request:
97
branches: [wasm, wasm-*]
108

@@ -107,7 +105,7 @@ jobs:
107105

108106
- name: Cache dist-newstyle
109107
uses: actions/cache/save@v4
110-
if: steps.build-dep-agda.outcome == 'success'
108+
if: github.ref_type == 'branch' && steps.build-dep-agda.outcome == 'success'
111109
with:
112110
path: als/dist-newstyle
113111
key: dist-newstyle-${{ env.CI_CACHE_KEY }}-${{ hashFiles('als/dist-newstyle/**') }}
@@ -137,7 +135,7 @@ jobs:
137135

138136
- name: Cache native cabal
139137
uses: actions/cache/save@v4
140-
if: steps.ghc-wasm-setup.outcome == 'success'
138+
if: github.ref_type == 'branch' && steps.ghc-wasm-setup.outcome == 'success'
141139
with:
142140
path: |
143141
~/.config/cabal
@@ -146,7 +144,7 @@ jobs:
146144

147145
- name: Cache ghc-wasm-meta
148146
uses: actions/cache/save@v4
149-
if: steps.ghc-wasm-setup.outcome == 'success'
147+
if: github.ref_type == 'branch' && steps.ghc-wasm-setup.outcome == 'success'
150148
with:
151149
path: ~/.ghc-wasm
152150
key: ${{ steps.ghc-wasm-cache-restore.outputs.cache-primary-key }}

0 commit comments

Comments
 (0)