-
Notifications
You must be signed in to change notification settings - Fork 339
/
cabal.yml
218 lines (189 loc) · 7.85 KB
/
cabal.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
name: Build (cabal)
on:
push:
branches:
- master
- ci-*
- release*
paths: &trigger_path_list
- '.github/workflows/cabal.yml'
- 'Agda.cabal'
- 'Setup.hs'
- 'src/agda-mode/**'
- 'src/full/**'
- 'src/main/**'
- 'test/**.hs'
pull_request:
paths: *trigger_path_list
defaults:
run:
shell: bash
jobs:
auto-cancel:
if: |
!contains(github.event.head_commit.message, '[skip ci]')
&& !contains(github.event.head_commit.message, '[ci skip]')
&& !contains(github.event.head_commit.message, '[github skip]')
&& !contains(github.event.head_commit.message, '[skip github]')
runs-on: Ubuntu-latest # Required, but it can be anything here.
steps:
- uses: styfle/cancel-workflow-action@0.12.1
with:
access_token: ${{ github.token }}
cabal:
needs: auto-cancel
timeout-minutes: 60
# In these fields, we cannot refer to `env` (or even `runner.os`).
# Thus, we need redundant entries in the matrix.
name: Cabal ${{ matrix.description }}, ${{ matrix.ghc-ver }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04]
description: [Linux] ## This just for pretty-printing the job name.
ghc-ver: [9.8.1, 9.6.4, 9.4.8, 9.2.8, 9.0.2, 8.10.7, 8.8.4, 8.6.5]
# Need to mention "cabal-ver" at least once in the matrix, otherwise matrix.cabal-ver is an actionlint error.
cabal-ver: ['3.10']
cabal-flags: ['--enable-tests -f enable-cluster-counting']
doctest: [false]
include:
## Latest GHC, special builds
# Linux, without tests but with doctest
- os: ubuntu-22.04
description: Linux doctest
ghc-ver: '9.8.1'
# Can't leave cabal-flags empty here lest it becomes the default value.
cabal-flags: '--disable-tests'
doctest: true
# Linux, without -f enable-cluster-counting but with -f debug
- os: ubuntu-22.04
description: Linux debug
ghc-ver: '9.8.1'
cabal-flags: '--enable-tests -f debug'
# Linux, with containers-0.7 and everything
- os: ubuntu-22.04
description: Linux containers 0.7
ghc-ver: '9.8.1'
## Andreas, 2023-09-28: Test containers-0.7 here which has breaking changes.
## Note: -c 'containers >= 0.7' with single quotes does not get communicated properly.
## (The single quotes stay, and "-c 'containers" is an option parse error for cabal.)
cabal-flags: |
--enable-tests -f enable-cluster-counting -f debug -c containers>=0.7 --allow-newer=containers
# macOS with default flags
- os: macos-12
description: macOS
ghc-ver: '9.8.1'
# Windows with default flags
- os: windows-2022
description: Windows
ghc-ver: '9.8.1'
# Default values
env:
GHC_VER: ${{ matrix.ghc-ver || '9.8.1' }}
CABAL_VER: ${{ matrix.cabal-ver || '3.10' }}
FLAGS: ${{ matrix.cabal-flags || '--enable-tests -f enable-cluster-counting' }}
steps:
- uses: actions/checkout@v4
- name: Switch off XDG directories for cabal (Linux)
if: ${{ runner.os == 'Linux' }}
run: |
mkdir -p ~/.cabal
# The presence of ~/.cabal should switch cabal 3.10 to not use the XDG layout.
- uses: haskell-actions/setup@v2
id: setup-haskell
with:
ghc-version: ${{ env.GHC_VER }}
cabal-version: ${{ env.CABAL-VER }}
cabal-update: true
- name: Environment settings based on the Haskell setup
run: |
GHC_VER=$(ghc --numeric-version)
CABAL_VER=$(cabal --numeric-version)
echo "GHC_VER = ${GHC_VER}"
echo "CABAL_VER = ${CABAL_VER}"
echo "GHC_VER=${GHC_VER}" >> "${GITHUB_ENV}"
echo "CABAL_VER=${CABAL_VER}" >> "${GITHUB_ENV}"
# From now on, env.{GHC|CABAL}_VER are the precise versions.
# See: https://github.com/haskell/text-icu/pull/86
# pacman needs MSYS /usr/bin in PATH, but this breaks the latest cache action.
# - https://github.com/actions/cache/issues/1073
# MSYS' pkg-config needs MSYS /mingw64/bin which we can safely add to the PATH
#
- name: Install the ICU library (Windows)
if: ${{ runner.os == 'Windows' }}
shell: pwsh
run: |
$env:PATH = "C:\msys64\usr\bin;$env:PATH"
pacman --noconfirm -S msys2-keyring mingw-w64-x86_64-pkgconf mingw-w64-x86_64-icu
echo "C:\msys64\mingw64\bin" | Out-File -FilePath "$env:GITHUB_PATH" -Append
- name: Set up pkg-config for the ICU library (macOS)
if: ${{ runner.os == 'macOS' }}
run: |
PKG_CONFIG_PATH=$(brew --prefix)/opt/icu4c/lib/pkgconfig
echo "PKG_CONFIG_PATH=${PKG_CONFIG_PATH}" >> "${GITHUB_ENV}"
# # print some information to debug pkg-config
# echo "$ export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}"
# echo "$ ls -l ${PKG_CONFIG_PATH}"
# ls -l "${PKG_CONFIG_PATH}"
# export PKG_CONFIG_PATH
# echo "$ pkg-config --modversion icu-i18n"
# pkg-config --modversion icu-i18n
- name: Determine the ICU version
run: |
ICU_VER=$(pkg-config --modversion icu-i18n)
echo "ICU_VER=${ICU_VER}"
echo "ICU_VER=${ICU_VER}" >> "${GITHUB_ENV}"
- name: Configure the build plan
run: |
cabal configure -O0 ${FLAGS}
cabal build --dry-run
# cabal build --dry-run creates dist-newstyle/cache/plan.json
# This does not download the dependencies, except with buggy `cabal-3.9`:
# https://github.com/haskell/cabal/issues/8706
- name: Restore cache from approximate key
# uses: actions/cache/restore@v4
# Andreas, 2023-02-02 revert to default cache saving logic.
# "Save always" is bad because it may duplicate caches from the base branch on the feature branch.
uses: actions/cache@v4
id: cache
with:
# We don't cache dist-newstyle because it is too fat (e.g. >400MB on GHC 9.4.4)
path: &cache_path |
${{ steps.setup-haskell.outputs.cabal-store }}
# Append the build plan to the cache key so that a new cache gets saved when dependencies update.
# `plan.json` is a good cache key because it does not contain time stamps (unlike `cabal.project.freeze`).
key: &cache_key cabal.yml-${{ runner.os }}-ghc-${{ env.GHC_VER }}-cabal-${{ env.CABAL_VER }}-${{ hashFiles('**/plan.json') }}
restore-keys: cabal.yml-${{ runner.os }}-ghc-${{ env.GHC_VER }}-cabal-${{ env.CABAL_VER }}-
- name: Install dependencies
# Formally skip this when we successfully restored the cache, to shave a few seconds.
# Note that the dependencies will anyway be built in the `cabal build` step.
# So, strictly speaking, this step is superfluous anyways.
# However, we keep it here so that we do not clutter the output of the
# `cabal build` step too much in the ordinary case.
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
run: |
cabal build --only-dependencies
- name: Build Agda
run: |
cabal build
- name: Run doctest
if: ${{ matrix.doctest }}
run: |
make doc-test
# - name: Clear old cache
# if: ${{ steps.cache.outputs.cache-hit == 'true' }}
# env:
# KEY: ${{ steps.cache.outputs.cache-matched-key }}
# GH_TOKEN: ${{ github.token }}
# run: |
# gh extension install actions/gh-actions-cache
# gh actions-cache delete -B ${{ github.ref }} ${{ env.KEY }} --confirm
# # Don't fail if cache cannot be deleted
# continue-on-error: true
# - name: Save cache
# uses: actions/cache/save@v4
# if: always() # save cache even when build fails
# with:
# key: *cache_key
# path: *cache_path