Skip to content

Commit 3b313a7

Browse files
committed
CI: GitHub: Cabal: improvement of the GitHub caching
A riff on the theme of https://markkarpov.com/post/github-actions-for-haskell-ci.html
1 parent fbbfee2 commit 3b313a7

File tree

2 files changed

+49
-26
lines changed

2 files changed

+49
-26
lines changed

.github/workflows/Cabal-Linux.yml

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ on:
88
schedule:
99
- cron: "45 02 * * *"
1010

11+
env:
12+
cabalConfig: --enable-tests --enable-benchmarks --disable-optimization --enable-deterministic
1113

1214
jobs:
1315

@@ -18,25 +20,34 @@ jobs:
1820
matrix:
1921
ghc: [ "8.10", "8.4" ]
2022
steps:
21-
- uses: actions/checkout@v2
23+
- name: "Git checkout"
24+
uses: actions/checkout@v2
2225
with:
2326
submodules: recursive
24-
- name: "Cache of ~/.cabal/packages, ~/.cabal/store and dist-newstyle"
25-
uses: actions/cache@v2
26-
with:
27-
path: |
28-
~/.cabal/packages
29-
~/.cabal/store
30-
dist-newstyle
31-
key: ${{ runner.os }}-Cabal-${{ matrix.ghc }}
32-
- uses: haskell/actions/setup@v1
27+
- name: "Haskell env setup"
28+
id: HaskEnvSetup
29+
uses: haskell/actions/setup@v1
3330
with:
3431
ghc-version: ${{ matrix.ghc }}
3532
- name: "Install additional system packages"
3633
run: sudo apt install libsodium-dev
3734
# 2020-08-01: NOTE: Nix instantiate still needed for HNix tests
3835
- name: "Install Nix"
3936
uses: cachix/install-nix-action@v12
40-
- run: cabal v2-configure --disable-optimization --enable-tests --enable-deterministic
41-
- run: cabal v2-build
42-
- run: cabal v2-test
37+
- name: "Repository update"
38+
run: cabal v2-update
39+
# NOTE: Freeze is for the caching
40+
- name: "Configuration freeze"
41+
run: cabal v2-freeze $cabalConfig
42+
- name: "Configuring GitHub cache"
43+
uses: actions/cache@v2
44+
with:
45+
path: |
46+
${{ steps.HaskEnvSetup.outputs.cabal-store }}
47+
dist-newstyle
48+
key: ${{ runner.os }}-Cabal-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}
49+
restore-keys: ${{ runner.os }}-Cabal-${{ matrix.ghc }}-
50+
- name: "Build"
51+
run: cabal v2-build $cabalConfig
52+
- name: "Tests"
53+
run: cabal v2-test $cabalConfig

.github/workflows/On-Release-Cabal-Linux.yml

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
# created: a draft is saved, or a release or pre-release is published without previously being saved as a draft
66
types: [ created ]
77

8+
env:
9+
cabalConfig: --enable-tests --enable-benchmarks --disable-optimization --enable-deterministic
10+
811
jobs:
912

1013
build10:
@@ -15,25 +18,34 @@ jobs:
1518
# Since CI by default tests boundary GHCs, test middle versions of GHCs
1619
ghc: [ "8.8", "8.6"]
1720
steps:
18-
- uses: actions/checkout@v2
21+
- name: "Git checkout"
22+
uses: actions/checkout@v2
1923
with:
2024
submodules: recursive
21-
- name: Cache of ~/.cabal/packages, ~/.cabal/store and dist-newstyle
22-
uses: actions/cache@v2
23-
with:
24-
path: |
25-
~/.cabal/packages
26-
~/.cabal/store
27-
dist-newstyle
28-
key: ${{ runner.os }}-Cabal-${{ matrix.ghc }}
29-
- uses: haskell/actions/setup@v1
25+
- name: "Haskell env setup"
26+
id: HaskEnvSetup
27+
uses: haskell/actions/setup@v1
3028
with:
3129
ghc-version: ${{ matrix.ghc }}
3230
- name: "Install additional system packages"
3331
run: sudo apt install libsodium-dev
3432
# 2020-08-01: NOTE: Nix instantiate still needed for HNix tests
3533
- name: "Install Nix"
3634
uses: cachix/install-nix-action@v12
37-
- run: cabal v2-configure --disable-optimization --enable-tests --enable-deterministic
38-
- run: cabal v2-build
39-
- run: cabal v2-test
35+
- name: "Repository update"
36+
run: cabal v2-update
37+
# NOTE: Freeze is for the caching
38+
- name: "Configuration freeze"
39+
run: cabal v2-freeze $cabalConfig
40+
- name: "Configuring GitHub cache"
41+
uses: actions/cache@v2
42+
with:
43+
path: |
44+
${{ steps.HaskEnvSetup.outputs.cabal-store }}
45+
dist-newstyle
46+
key: ${{ runner.os }}-Cabal-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}
47+
restore-keys: ${{ runner.os }}-Cabal-${{ matrix.ghc }}-
48+
- name: "Build"
49+
run: cabal v2-build $cabalConfig
50+
- name: "Tests"
51+
run: cabal v2-test $cabalConfig

0 commit comments

Comments
 (0)