Skip to content

Commit 2286068

Browse files
authored
Update CI to latest GHC and action versions, modernize caching (#448)
* Update CI to latest GHC and action versions, modernize caching - separate caching into restore and save step - always save cache even if build failed (speeds up next attempt) - use build plan rather than freeze file as cache key * Use andreasabel/fix-whitespace-action * Update requirements.txt for doc building (Sphinx) * Remove if on actions/checkout (makes no sense) * Deploy docs only when merged into master
1 parent bb5f086 commit 2286068

File tree

5 files changed

+77
-34
lines changed

5 files changed

+77
-34
lines changed

.github/workflows/ci.yml

Lines changed: 51 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@ name: CI
33
# Trigger the workflow on push or pull request, but only for the master branch
44
on:
55
pull_request:
6+
paths:
7+
- 'lib/**'
8+
- 'src/**'
9+
- 'test/**'
10+
- 'lib/base/base.agda-lib'
11+
- 'agda2hs.cabal'
12+
- 'cabal.project'
13+
- 'Makefile'
14+
- '.github/workflows/**.yml'
15+
branches: [master]
616
push:
717
paths:
818
- 'lib/**'
@@ -22,12 +32,11 @@ jobs:
2232
strategy:
2333
matrix:
2434
os: [ubuntu-latest] # macOS-latest, windows-latest
25-
cabal: [3.10.3]
26-
deploy-ghc: [9.6.6]
27-
ghc: [9.4.8, 9.6.6, 9.8.2, 9.10.1]
35+
cabal: [3.14.2.0]
36+
deploy-ghc: [9.6.7]
37+
ghc: [9.6.7, 9.8.4, 9.10.3, 9.12.2]
2838
steps:
29-
- uses: actions/checkout@v3
30-
if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/master'
39+
- uses: actions/checkout@v6
3140

3241
# Takes care of ghc and cabal. See https://github.com/haskell/actions.
3342
- uses: haskell-actions/setup@v2
@@ -37,42 +46,64 @@ jobs:
3746
ghc-version: ${{ matrix.ghc }}
3847
cabal-version: ${{ matrix.cabal }}
3948

40-
# Generate a cabal.project.freeze file with all dependencies. We use the
41-
# hash of this as the cache key, so when a dependency changes we upload a
42-
# new cache.
43-
- name: Freeze
44-
run: cabal freeze
49+
# Andreas, 2025-11-28: Since the freeze file contains a timestamp of the Hackage index
50+
# and the index changes several times a day,
51+
# the freeze file is not very useful as a cache key.
52+
# Instead, use the plan.json file (see below).
53+
# # Generate a cabal.project.freeze file with all dependencies. We use the
54+
# # hash of this as the cache key, so when a dependency changes we upload a
55+
# # new cache.
56+
# - name: Freeze
57+
# run: cabal freeze
4558

46-
# Install fix-whitespace since we need it for tests.
47-
# This is done after the freeze to make sure we re-use the packages
48-
- name: Install fix-whitespace
59+
- name: Configure the build plan
4960
run: |
50-
echo "import: cabal.project" > cabal.project.ci
51-
cabal install fix-whitespace --project-file=cabal.project.ci
61+
cabal build --dry-run
62+
# cabal build --dry-run creates dist-newstyle/cache/plan.json
63+
64+
# Andreas, 2025-11-28, AIM XLI, use fix-whitespace-action
65+
# # Install fix-whitespace since we need it for tests.
66+
# # This is done after the freeze to make sure we re-use the packages
67+
# - name: Install fix-whitespace
68+
# run: |
69+
# echo "import: cabal.project" > cabal.project.ci
70+
# cabal install fix-whitespace --project-file=cabal.project.ci
5271

5372
# Cache the contents of ~/.cabal/store to avoid rebuilding dependencies for
5473
# every build. `restore-keys` makes it use the latest cache even if the
5574
# fingerprint doesn't match, so we don't need to start from scratch every
5675
# time a dependency changes.
57-
- uses: actions/cache@v3
58-
name: Cache ~/.cabal/store
76+
- uses: actions/cache/restore@v4
77+
name: Restore cached ~/.cabal/store
78+
id: cache
5979
with:
6080
path: ${{ steps.setup-haskell-cabal.outputs.cabal-store }}
61-
key: ${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}
81+
# The freeze file is a bad key, use dist-newstyle/cache/plan.json instead.
82+
# key: ${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}
83+
key: ${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('**/plan.json') }}
6284
restore-keys: ${{ runner.os }}-${{ matrix.ghc }}-
6385

86+
- name: Run fix-whitespace
87+
uses: andreasabel/fix-whitespace-action@v1
88+
6489
- name: Run test suite
65-
run: make test && git diff --exit-code
90+
run: make test-on-CI && git diff --exit-code
6691

6792
- name: Generate Prelude HTML
6893
if: ${{ (matrix.ghc == matrix.deploy-ghc) && (github.ref == 'refs/heads/master') }}
6994
run: make libHtml
7095

7196
- name: Deploy Prelude HTML
7297
if: ${{ (matrix.ghc == matrix.deploy-ghc) && (github.ref == 'refs/heads/master') }}
73-
uses: peaceiris/actions-gh-pages@v3
98+
uses: peaceiris/actions-gh-pages@v4
7499
with:
75100
github_token: ${{ secrets.GITHUB_TOKEN }}
76101
publish_dir: html
77102
destination_dir: lib
78103

104+
- uses: actions/cache/save@v4
105+
name: Cache ~/.cabal/store
106+
if: always() && steps.cache.outputs.cache-hit != 'true'
107+
with:
108+
path: ${{ steps.setup-haskell-cabal.outputs.cabal-store }}
109+
key: ${{ steps.cache.outputs.cache-primary-key }}

.github/workflows/docs.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ on:
66
push:
77
branches: [master]
88

9+
# Runs on PRs targeting the default branch
10+
pull_request:
11+
branches: [master]
12+
913
# Allows you to run this workflow manually from the Actions tab
1014
workflow_dispatch:
1115

@@ -19,7 +23,7 @@ jobs:
1923
deploy:
2024
strategy:
2125
matrix:
22-
python-version: ["3.10.8"]
26+
python-version: ["3.14"]
2327

2428
env:
2529
DOCS_DIR: docs
@@ -28,21 +32,27 @@ jobs:
2832

2933
runs-on: ubuntu-latest
3034
steps:
35+
3136
- name: Checkout
32-
uses: actions/checkout@v3
37+
uses: actions/checkout@v6
38+
3339
- name: Set up Python ${{ matrix.python-version }}
34-
uses: actions/setup-python@v4
40+
uses: actions/setup-python@v6
3541
with:
3642
python-version: ${{ matrix.python-version }}
43+
3744
- name: Install dependencies
3845
run: |
3946
pip install -r ${{ env.DOCS_DIR }}/requirements.txt
47+
4048
- name: Build User Manual in HTML
4149
run: |
4250
cd ${{ env.DOCS_DIR }}
4351
make html
52+
4453
- name: Deploy to GitHub Pages
45-
uses: peaceiris/actions-gh-pages@v3
54+
uses: peaceiris/actions-gh-pages@v4
55+
if: github.ref == 'refs/heads/master'
4656
with:
4757
github_token: ${{ secrets.GITHUB_TOKEN }}
4858
publish_dir: ${{ env.DOCS_BUILD_HTML_DIR }}

.github/workflows/nix-ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ jobs:
3333
- pretty: "Typecheck with Agda"
3434
derivation: containers-lib
3535
steps:
36-
- uses: actions/checkout@v3
37-
- uses: nixbuild/nix-quick-install-action@v30
36+
- uses: actions/checkout@v6
37+
- uses: nixbuild/nix-quick-install-action@v34
3838
with:
3939
nix_conf: |
4040
keep-env-derivations = true
@@ -50,8 +50,8 @@ jobs:
5050
name: "Test building inside a nix shell"
5151
runs-on: ubuntu-latest
5252
steps:
53-
- uses: actions/checkout@v3
54-
- uses: nixbuild/nix-quick-install-action@v30
53+
- uses: actions/checkout@v6
54+
- uses: nixbuild/nix-quick-install-action@v34
5555
with:
5656
nix_conf: |
5757
keep-env-derivations = true

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY : install agda repl libHtml test testContainers testHtml golden docs
1+
.PHONY : install agda repl libHtml testContainers test test-on-CI testHtml golden clean docs
22
FILES = $(shell find src -type f)
33

44
build :
@@ -23,7 +23,9 @@ test/agda2hs : $(FILES)
2323
testContainers:
2424
cd ./lib/containers && ./generate-haskell.sh && cabal build containers-prop
2525

26-
test : checkWhitespace test/agda2hs testContainers
26+
test : checkWhitespace test-on-CI
27+
28+
test-on-CI : test/agda2hs testContainers
2729
make -C test
2830

2931
testHtml : test/agda2hs

docs/requirements.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
sphinx==5.3.0
2-
sphinx_rtd_theme==1.1.1
3-
readthedocs-sphinx-search==0.1.2
4-
myst_parser==0.18.1
1+
sphinx==8.2.3
2+
sphinx_rtd_theme==3.0.2
3+
readthedocs-sphinx-search==0.3.2
4+
myst-parser==4.0.1

0 commit comments

Comments
 (0)