1313 schedule :
1414 - cron : ' 0 0 */6 * *'
1515
16+ permissions :
17+ contents : read
18+
1619jobs :
1720 build :
1821 runs-on : ${{ matrix.sys.os }}
1922
2023 strategy :
2124 fail-fast : false
2225 matrix :
23- ghc : ["9.6", "9.10", "9.12"]
24- cabal : ["3.14 "]
26+ ghc : [&ghc-stable "9.6", "9.10", &ghc-latest "9.12"]
27+ cabal : [&cabal-version "3.16 "]
2528 sys :
26- - { os: windows-latest, shell: 'C:/msys64/usr/bin/bash.exe -e {0}' }
2729 - { os: ubuntu-latest, shell: bash }
30+ include :
31+ # Using include, to make sure there will only be one macOS job, even if the matrix gets expanded later on.
32+ # We want a single job, because macOS runners are scarce.
33+ - ghc : *ghc-stable
34+ cabal : *cabal-version
35+ sys :
36+ os : macos-latest
37+ shell : bash
38+ - ghc : *ghc-latest
39+ cabal : *cabal-version
40+ sys :
41+ os : windows-latest
42+ shell : ' C:/msys64/usr/bin/bash.exe -e {0}'
2843
2944 defaults :
3045 run :
@@ -74,60 +89,11 @@ jobs:
7489
7590 - uses : actions/checkout@v4
7691
77- - name : Cabal update
78- run : cabal update
79-
80- # A dry run `build all` operation does *NOT* download anything, it just looks at the package
81- # indices to generate an install plan.
82- - name : Build dry run
83- run : cabal build all --enable-tests --dry-run --minimize-conflict-set
84-
85- # From the install plan we generate a dependency list.
86- - name : Record dependencies
87- id : record-deps
88- run : |
89- cat dist-newstyle/cache/plan.json | jq -r '."install-plan"[] | select(.style != "local") | .id' | sort | uniq > dependencies.txt
90-
91- # Use a fresh cache each month
92- - name : Store month number and GHC version as environment variables used in cache version
93- run : |
94- cat <<EOF >> $GITHUB_ENV
95- MONTHNUM=$(date -u '+%m')
96- GHC=$(ghc --numeric-version)
97- EOF
98-
99- # From the dependency list we restore the cached dependencies.
100- # We use the hash of `dependencies.txt` as part of the cache key because that will be stable
101- # until the `index-state` values in the `cabal.project` file changes.
102- - name : Restore cached dependencies
103- uses : actions/cache/restore@v4
104- id : cache
105- with :
106- path : |
107- ${{ steps.setup-haskell.outputs.cabal-store }}
108- dist-newstyle
109- key :
110- cache-${{ env.CABAL_CACHE_VERSION }}-${{ runner.os }}-${{ env.GHC }}-${{ env.MONTHNUM }}-${{ hashFiles('dependencies.txt') }}
111- # try to restore previous cache from this month if there's no cache for the dependencies set
112- restore-keys : |
113- cache-${{ env.CABAL_CACHE_VERSION }}-${{ runner.os }}-${{ env.GHC }}-${{ env.MONTHNUM }}-
114-
115- # Now we install the dependencies. If the cache was found and restored in the previous step,
116- # this should be a no-op, but if the cache key was not found we need to build stuff so we can
117- # cache it for the next step.
118- - name : Install dependencies
119- run : cabal build all --enable-tests --only-dependencies
120-
121- # Always store the cabal cache.
122- # This can fail (benign failure) if there is already a hash at that key.
123- - name : Cache Cabal store
124- uses : actions/cache/save@v4
92+ - name : Cache and install Cabal dependencies
93+ uses : intersectmbo/cardano-api/.github/actions/cabal-cache@a7bd74dfa6ccb1eb04f69791f978a3b9e0cc63ca
12594 with :
126- path : |
127- ${{ steps.setup-haskell.outputs.cabal-store }}
128- dist-newstyle
129- key :
130- ${{ steps.cache.outputs.cache-primary-key }}
95+ cabal-store : ${{ steps.setup-haskell.outputs.cabal-store }}
96+ cache-version : ${{ env.CABAL_CACHE_VERSION }}
13197
13298 # Now we build.
13399 - name : Build all
@@ -160,7 +126,7 @@ jobs:
160126 # https://github.com/IntersectMBO/cardano-cli/blob/0048f119036ffb9eab357b25dcaf7d320362f071/cardano-cli/test/cardano-cli-golden/Test/Golden/Help.hs#L54
161127 if : ${{ matrix.sys.os != 'windows-latest' }}
162128 run : |
163- NB_UNUSED_GOLDEN_FILES=$(git ls-files -d | wc -l)
129+ NB_UNUSED_GOLDEN_FILES=$(git ls-files -d | wc -l | xargs )
164130 if [[ "$NB_UNUSED_GOLDEN_FILES" != "0" ]]; then
165131 echo -e "⚠️ The following golden files are not used anymore:\n"
166132 git ls-files -d
@@ -172,7 +138,7 @@ jobs:
172138 # We don't run this step on Windows, as explained in the previous step.
173139 if : ${{ matrix.sys.os != 'windows-latest' }}
174140 run : |
175- NB_MODIFIED_GOLDEN_FILES=$(git ls-files -m | wc -l)
141+ NB_MODIFIED_GOLDEN_FILES=$(git ls-files -m | wc -l | xargs )
176142 if [[ "$NB_MODIFIED_GOLDEN_FILES" != "0" ]]; then
177143 echo -e "💣 The following golden files are not up-to-date:\n"
178144 git ls-files -m
@@ -214,9 +180,9 @@ jobs:
214180 # and will silently fail if msys2 is not in path. See the "Run tests" step.
215181 #
216182 # - name: Setup tmate session
217- # if: ${{ failure() }}
218- # uses: mxschmitt/action-tmate@v3
219- # with:
183+ # if: ${{ failure() }}
184+ # uses: mxschmitt/action-tmate@v3
185+ # with:
220186 # limit-access-to-actor: true
221187
222188 build-complete :
0 commit comments