Skip to content

Commit 21c8780

Browse files
authored
Merge pull request #9845 from haskell/ci-xdg
Fix #9815: fix caching for quick-jobs CI (XDG, cache keys)
2 parents 381e82b + 5aa8afd commit 21c8780

File tree

3 files changed

+123
-89
lines changed

3 files changed

+123
-89
lines changed

.github/workflows/quick-jobs.yml

Lines changed: 75 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -18,130 +18,125 @@ jobs:
1818
meta:
1919
name: Meta checks
2020
runs-on: ubuntu-latest
21+
env:
22+
cabal_build: >-
23+
cabal build --builddir=dist-newstyle-meta --project-file=cabal.project.meta
24+
gen-cabal-macros
25+
gen-paths-module
26+
gen-spdx
27+
gen-spdx-exc
2128
# This job is not run in a container, any recent GHC should be fine
2229
steps:
23-
- name: Set PATH
24-
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#adding-a-system-path
30+
# SKIP installation of ghc and cabal and use the preinstalled versions.
31+
# - name: ghcup
32+
# run: |
33+
# ghcup --version
34+
# ghcup config set cache true
35+
# ghcup install ghc recommended
36+
# ghcup set ghc recommended
37+
- name: Haskell versions
2538
run: |
26-
echo "$HOME/.cabal/bin" >> $GITHUB_PATH
27-
- uses: actions/cache@v3
28-
with:
29-
path: ~/.cabal/store
30-
key: linux-store-meta
31-
# See https://github.com/haskell/cabal/pull/8739
32-
- name: Sudo chmod to permit ghcup to update its cache
33-
run: |
34-
if [[ "${{ runner.os }}" == "Linux" ]]; then
35-
sudo ls -lah /usr/local/.ghcup/cache
36-
sudo mkdir -p /usr/local/.ghcup/cache
37-
sudo ls -lah /usr/local/.ghcup/cache
38-
sudo chown -R $USER /usr/local/.ghcup
39-
sudo chmod -R 777 /usr/local/.ghcup
40-
fi
41-
- name: ghcup
42-
run: |
43-
ghcup --version
44-
ghcup config set cache true
45-
ghcup install ghc recommended
46-
ghcup set ghc recommended
39+
ghc --version
40+
cabal --version
4741
- name: Update Hackage index
4842
run: cabal v2-update
49-
- name: Install alex
50-
run: cabal v2-install alex --constraint='alex ==3.2.7.3'
5143
- uses: actions/checkout@v4
44+
- name: Generate build plan for correct cache key
45+
run: ${{ env.cabal_build }} --dry-run
46+
- name: Restore cached dependencies
47+
uses: actions/cache/restore@v4
48+
id: cache
49+
with:
50+
path: ~/.local/state/cabal
51+
key: linux-store-meta-${{ hashfiles('dist-newstyle-meta/cache/plan.json') }}
52+
restore-keys: linux-store-meta-
53+
- name: Build tools
54+
run: ${{ env.cabal_build }}
5255
- name: Regenerate files
5356
run: |
54-
make -B lexer
5557
make -B spdx
5658
make -B templates
5759
- name: Check that diff is clean
5860
run: |
5961
git status > /dev/null
6062
git diff-files -p --exit-code
63+
- name: Cache dependencies
64+
uses: actions/cache/save@v4
65+
if: always() && steps.cache.outputs.cache-hit != 'true'
66+
with:
67+
path: ~/.local/state/cabal
68+
key: ${{ steps.cache.outputs.cache-primary-key }}
69+
6170
doctest:
6271
name: Doctest Cabal
6372
runs-on: ubuntu-latest
6473
steps:
65-
- name: Set PATH
74+
# It is complicated to get a proper cache key for the dependencies of a package
75+
# (here: doctest) that we just `cabal install`.
76+
# So, as a heuristics we update the cache once per day.
77+
# Updating it with each run would be an alternative, but we a short of cache space,
78+
# and this would generate too many new caches.
79+
- name: Use date as cache key
6680
run: |
67-
echo "$HOME/.cabal/bin" >> $GITHUB_PATH
68-
- uses: actions/cache@v3
81+
echo "DATE=$(date +'%Y-%m-%d')" >> "${GITHUB_ENV}"
82+
- name: Restore cached dependencies
83+
uses: actions/cache/restore@v4
84+
id: cache
6985
with:
70-
path: ~/.cabal/store
71-
key: linux-store-doctest
72-
# See https://github.com/haskell/cabal/pull/8739
73-
- name: Sudo chmod to permit ghcup to update its cache
74-
run: |
75-
if [[ "${{ runner.os }}" == "Linux" ]]; then
76-
sudo ls -lah /usr/local/.ghcup/cache
77-
sudo mkdir -p /usr/local/.ghcup/cache
78-
sudo ls -lah /usr/local/.ghcup/cache
79-
sudo chown -R $USER /usr/local/.ghcup
80-
sudo chmod -R 777 /usr/local/.ghcup
81-
fi
82-
- name: ghcup
83-
run: |
84-
ghcup --version
85-
ghcup config set cache true
86-
ghcup install ghc --set recommended
87-
ghcup install cabal --set latest
86+
path: ~/.local/state/cabal
87+
key: linux-store-doctest-${{ env.DATE }}
88+
restore-keys: linux-store-doctest
8889
- name: Update Hackage index
8990
run: cabal v2-update
9091
- uses: actions/checkout@v4
9192
- name: Install doctest
9293
run: make doctest-install
9394
- name: Doctest
9495
run: make doctest
96+
- name: Cache dependencies
97+
if: always() && steps.cache.outputs.cache-hit != 'true'
98+
uses: actions/cache/save@v4
99+
with:
100+
path: ~/.local/state/cabal
101+
key: ${{ steps.cache.outputs.cache-primary-key }}
102+
95103
buildinfo:
96104
name: Check Field Syntax Reference
97105
runs-on: ubuntu-latest
106+
env:
107+
cabal_build: cabal build buildinfo-reference-generator
98108
steps:
99-
- name: Set PATH
100-
run: |
101-
echo "$HOME/.cabal/bin" >> $GITHUB_PATH
102-
- uses: actions/cache@v3
103-
with:
104-
path: ~/.cabal/store
105-
key: linux-store-buildinfo-doc-diff
106-
# See https://github.com/haskell/cabal/pull/8739
107-
- name: Sudo chmod to permit ghcup to update its cache
108-
run: |
109-
if [[ "${{ runner.os }}" == "Linux" ]]; then
110-
sudo ls -lah /usr/local/.ghcup/cache
111-
sudo mkdir -p /usr/local/.ghcup/cache
112-
sudo ls -lah /usr/local/.ghcup/cache
113-
sudo chown -R $USER /usr/local/.ghcup
114-
sudo chmod -R 777 /usr/local/.ghcup
115-
fi
116-
- name: ghcup
117-
run: |
118-
ghcup --version
119-
ghcup config set cache true
120-
ghcup install ghc --set recommended
121-
ghcup install cabal --set latest
122109
- name: Update Hackage index
123110
run: cabal v2-update
124111
- uses: actions/checkout@v4
112+
- name: Generate build plan for correct cache key
113+
run: ${{ env.cabal_build }} --dry-run
114+
- name: Restore cached dependencies
115+
uses: actions/cache/restore@v4
116+
id: cache
117+
with:
118+
path: ~/.local/state/cabal
119+
key: linux-store-buildinfo-doc-diff-${{ hashfiles('dist-newstyle/cache/plan.json') }}
120+
restore-keys: linux-store-buildinfo-doc-diff
121+
- name: Build buildinfo-reference-generator
122+
run: ${{ env.cabal_build }}
125123
- name: Are buildinfo docs up to date?
126124
run: make doc/buildinfo-fields-reference.rst
125+
- name: Cache dependencies
126+
uses: actions/cache/save@v4
127+
if: always() && steps.cache.outputs.cache-hit != 'true'
128+
with:
129+
path: ~/.local/state/cabal
130+
key: ${{ steps.cache.outputs.cache-primary-key }}
131+
127132
release-project:
128133
name: Check Release Project
129134
runs-on: ubuntu-latest
130135
steps:
131-
- name: Set PATH
132-
run: |
133-
echo "$HOME/.cabal/bin" >> $GITHUB_PATH
134-
- name: ghcup
135-
run: |
136-
ghcup --version
137-
ghcup config set cache true
138-
ghcup install ghc --set recommended
139-
ghcup install cabal --set latest
140136
- name: Update Hackage Index
141137
run: cabal v2-update
142138
- uses: actions/checkout@v4
143139
- name: Check Release with Pinned Hackage
144140
run: cabal build all --dry-run --project-file=cabal.project.release
145141
- name: Check Release with Latest Hackage
146142
run: cabal build all --dry-run --project-file=cabal.project.release --index-state="hackage.haskell.org HEAD"
147-

Cabal/src/Distribution/Simple/Build/Macros/Z.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
module Distribution.Simple.Build.Macros.Z (render, Z(..), ZPackage (..), ZTool (..)) where
44
import Distribution.ZinzaPrelude
55
data Z
6-
= Z {zPackages :: ([ZPackage]),
7-
zTools :: ([ZTool]),
6+
= Z {zPackages :: [ZPackage],
7+
zTools :: [ZTool],
88
zPackageKey :: String,
99
zComponentId :: String,
1010
zPackageVersion :: Version,

0 commit comments

Comments
 (0)