Skip to content

Commit f650aa5

Browse files
authored
Merge pull request #1338 from IntersectMBO/mgalazyn/chore/reuse-gha-cache-cardano-api
Reuse cache GHA from cardano-api repository
2 parents fc43f72 + 644ce97 commit f650aa5

File tree

5 files changed

+124
-92
lines changed

5 files changed

+124
-92
lines changed

.github/workflows/haskell.yml

Lines changed: 27 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,33 @@ on:
1313
schedule:
1414
- cron: '0 0 */6 * *'
1515

16+
permissions:
17+
contents: read
18+
1619
jobs:
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:

cabal.project

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ repository cardano-haskell-packages
1313
-- See CONTRIBUTING for information about these, including some Nix commands
1414
-- you need to run if you change them
1515
index-state:
16-
, hackage.haskell.org 2025-12-02T22:23:29Z
16+
, hackage.haskell.org 2026-02-06T20:27:32Z
1717
, cardano-haskell-packages 2026-02-18T15:43:28Z
1818

1919
packages:
@@ -32,6 +32,13 @@ package bitvec
3232
flags: -simd
3333

3434
extra-packages: Cabal
35+
36+
constraints:
37+
-- hourglass and time-hourglass both in dependency tree break musl build
38+
, time-hourglass < 0
39+
-- haskell.nix patch does not work for 1.6.8
40+
, any.crypton-x509-system < 1.6.8
41+
3542
if os(windows)
3643
constraints: time ^>=1.14
3744
allow-newer: *:time

cardano-cli/cardano-cli.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ common project-config
3434
-Wpartial-fields
3535
-Wredundant-constraints
3636

37-
if impl(ghc >= 9.6)
37+
if impl(ghc >=9.6)
3838
ghc-options: -Wunused-packages
3939

4040
common maybe-unix

flake.lock

Lines changed: 76 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)