@@ -18,130 +18,125 @@ jobs:
18
18
meta :
19
19
name : Meta checks
20
20
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
21
28
# This job is not run in a container, any recent GHC should be fine
22
29
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
25
38
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
47
41
- name : Update Hackage index
48
42
run : cabal v2-update
49
- - name : Install alex
50
- run : cabal v2-install alex --constraint='alex ==3.2.7.3'
51
43
- 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 }}
52
55
- name : Regenerate files
53
56
run : |
54
- make -B lexer
55
57
make -B spdx
56
58
make -B templates
57
59
- name : Check that diff is clean
58
60
run : |
59
61
git status > /dev/null
60
62
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
+
61
70
doctest :
62
71
name : Doctest Cabal
63
72
runs-on : ubuntu-latest
64
73
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
66
80
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
69
85
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
88
89
- name : Update Hackage index
89
90
run : cabal v2-update
90
91
- uses : actions/checkout@v4
91
92
- name : Install doctest
92
93
run : make doctest-install
93
94
- name : Doctest
94
95
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
+
95
103
buildinfo :
96
104
name : Check Field Syntax Reference
97
105
runs-on : ubuntu-latest
106
+ env :
107
+ cabal_build : cabal build buildinfo-reference-generator
98
108
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
122
109
- name : Update Hackage index
123
110
run : cabal v2-update
124
111
- 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 }}
125
123
- name : Are buildinfo docs up to date?
126
124
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
+
127
132
release-project :
128
133
name : Check Release Project
129
134
runs-on : ubuntu-latest
130
135
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
140
136
- name : Update Hackage Index
141
137
run : cabal v2-update
142
138
- uses : actions/checkout@v4
143
139
- name : Check Release with Pinned Hackage
144
140
run : cabal build all --dry-run --project-file=cabal.project.release
145
141
- name : Check Release with Latest Hackage
146
142
run : cabal build all --dry-run --project-file=cabal.project.release --index-state="hackage.haskell.org HEAD"
147
-
0 commit comments