-
Notifications
You must be signed in to change notification settings - Fork 17
304 lines (242 loc) Β· 10.5 KB
/
test.yaml
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
# modified from https://github.com/simonmichael/hledger/blob/master/.github/workflows/linux.yml
name: CI
defaults:
run:
shell: bash
on:
push:
branches: [master, ci-*, ci]
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
pull_request:
branches: [master]
jobs:
build-and-test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, macos-13, windows-latest]
agda: ['Agda-2.7.0.1', 'Agda-2.6.4.3', 'Agda-2.6.3']
fail-fast: false
steps:
- name: π₯ Checkout repository
uses: actions/checkout@v4
- name: π€ Install yq (Windows)
if: runner.os == 'Windows'
uses: frenck/action-setup-yq@v1
- name: ποΈ Determine which version of Agda to target
run: |
STACK_YAML=$(echo stack-9.2-${{ matrix.agda }}.yaml)
STACK_YAML_ARG="--stack-yaml $(echo stack-9.2-${{ matrix.agda }}.yaml)"
if [[ ${{ matrix.os }} == "ubuntu-latest" ]]; then
ARTEFACT="als-${{ matrix.agda }}-ubuntu"
fi
if [[ ${{ matrix.os }} == "macos-latest" ]]; then
ARTEFACT="als-${{ matrix.agda }}-macos-arm64"
fi
if [[ ${{ matrix.os }} == "macos-13" ]]; then
ARTEFACT="als-${{ matrix.agda }}-macos-x64"
fi
if [[ ${{ matrix.os }} == "windows-latest" ]]; then
ARTEFACT="als-${{ matrix.agda }}-windows"
fi
echo STACK_YAML_ARG="${STACK_YAML_ARG}" >> "${GITHUB_ENV}"
echo STACK_YAML="${STACK_YAML}" >> "${GITHUB_ENV}"
echo ARTEFACT="${ARTEFACT}" >> "${GITHUB_ENV}"
- name: ποΈ Determine Stack resolver & GHC version
run: |
STACK_RESOLVER=$(yq .resolver $STACK_YAML)
GHC_VERSION=$(echo $(yq .compiler $STACK_YAML) | cut -c 5-)
echo STACK_RESOLVER="${STACK_RESOLVER}" >> "${GITHUB_ENV}"
echo GHC_VERSION="${GHC_VERSION}" >> "${GITHUB_ENV}"
- name: π Setup Haskell
if : runner.os == 'macOS'
uses: haskell-actions/setup@v2
id: setup-haskell
with:
ghc-version: ${{ env.GHC_VERSION }}
enable-stack: true
stack-version: 'latest'
- name: ποΈ Determine Stack root
run: |
STACK_ROOT="$(stack path $STACK_YAML_ARG --stack-root)"
echo STACK_ROOT="${STACK_ROOT}" >> "${GITHUB_ENV}"
- name: π Review all variables
run: |
echo "STACK_YAML = ${STACK_YAML}"
echo "STACK_YAML_ARG = ${STACK_YAML_ARG}"
echo "STACK_RESOLVER = ${STACK_RESOLVER}"
echo "ARTEFACT = ${ARTEFACT}"
echo "GHC_VERSION = ${GHC_VERSION}"
echo "STACK_ROOT = ${STACK_ROOT}"
# things to be restored:
# Include STACK_RESOLVER in cache key, otherwise caches accumulate build products for different resolvers.
- name: πΎ Restore cached stack global package db
id: stack-global
uses: actions/cache/restore@v4
with:
path: ${{ env.STACK_ROOT }}
key: ${{ matrix.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-global-${{ hashFiles('**.yaml') }}-${{ matrix.agda }}
restore-keys: |
${{ matrix.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-global
- name: πΎ Restore cached .stack-work
id: stack-work
uses: actions/cache/restore@v4
with:
path: .stack-work
key: ${{ matrix.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-work-${{ hashFiles('**.yaml') }}-${{ matrix.agda }}
restore-keys: |
${{ matrix.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-work
# actions:
- name: βοΈ Set PKG_CONFIG_PATH for the ICU library (on macOS)
if: runner.os == 'macOS'
run: |
echo PKG_CONFIG_PATH="$(brew --prefix)/opt/icu4c/lib/pkgconfig" >> "${GITHUB_ENV}"
- name: π₯ Install the icu library (on Windows)
if: runner.os == 'Windows'
run: |
stack exec $STACK_YAML_ARG -- pacman -S --noconfirm mingw-w64-x86_64-icu mingw-w64-x86_64-pkgconf
- name: πΈ Build Snapshot
run: stack build $STACK_YAML_ARG --no-terminal --only-snapshot -j1
- name: ποΈ Build Dependencies
run: stack build $STACK_YAML_ARG --no-terminal --only-dependencies
- name: ποΈ Build ALS
run: stack build $STACK_YAML_ARG
- name: ποΈ Build Testings
run: stack build $STACK_YAML_ARG --test --no-terminal --only-dependencies
# things to be cached
- name: πΎ Cache stack global package db
if: always() && steps.stack-global.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: ${{ env.STACK_ROOT }}
key: ${{ steps.stack-global.outputs.cache-primary-key }}
- name: πΎ Cache .stack-work
if: always() && steps.stack-work.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: .stack-work
key: ${{ steps.stack-work.outputs.cache-primary-key }}
- name: π¦ Bundle executable, DLLs and data files (on macOS)
if: runner.os == 'macOS'
run: | # Bundle icu4c DLLs
# see if icu4c has been installed
if [ "$(brew list | grep icu4c)" = "" ]
then
echo "installing icu4c"
brew install icu4c
fi
# get the directory of the DDLs we want (icuuc, icui18n, icudata)
dylib_dir=$(dirname "$(brew list icu4c | grep icuuc.dylib)")
echo "dylib_dir: $dylib_dir"
# find the path of "als"
executable=$(find "$(stack path $STACK_YAML_ARG --local-install-root)"/bin -name "als")
echo "executable: $executable"
# remove the old dylib, and make a new one
rm -rf dylib
mkdir dylib
################################################################################
# icuuc
################################################################################
icuuc_id=$(otool -L "$executable" | grep icuuc | awk '{print $1}')
icuuc_id_basename=$(basename "$icuuc_id")
icuuc_path=$dylib_dir/$icuuc_id_basename
icuuc_path_new=dylib/$icuuc_id_basename
icuuc_id_new=@loader_path/dylib/$icuuc_id_basename
# copy icuuc to the new directory
cp "$icuuc_path" "$icuuc_path_new"
# change icuuc's ID referenced by ALS
install_name_tool -change "$icuuc_id" "$icuuc_id_new" "$executable"
echo "icuuc referenced by ALS"
echo " old ID : $icuuc_id"
echo " new ID : $icuuc_id_new"
echo " old path: $icuuc_path"
echo " new path: $icuuc_path_new"
################################################################################
# icui18n
################################################################################
icui18n_id=$(otool -L "$executable" | grep icui18n | awk '{print $1}')
icui18n_id_basename=$(basename "$icui18n_id")
icui18n_path=$dylib_dir/$icui18n_id_basename
icui18n_path_new=dylib/$icui18n_id_basename
icui18n_id_new=@loader_path/dylib/$icui18n_id_basename
# copy icui18n to the new directory
cp "$icui18n_path" "$icui18n_path_new"
# change icui18n's ID referenced by ALS
install_name_tool -change "$icui18n_id" "$icui18n_id_new" "$executable"
echo "icui18n referenced by ALS"
echo " old ID : $icui18n_id"
echo " new ID : $icui18n_id_new"
echo " old path: $icui18n_path"
echo " new path: $icui18n_path_new"
################################################################################
# icudata
################################################################################
# otool -L "$icui18n_id" | grep icudata | awk '{print $1}'
icudata_id=$(otool -L "$icuuc_path" | grep icudata | awk '{print $1}')
icudata_id_basename=$(basename "$icudata_id")
icudata_path=$dylib_dir/$icudata_id_basename
icudata_path_new=dylib/$icudata_id_basename
# copy icudata to the new directory
cp "$icudata_path" "$icudata_path_new"
# no need of changing the ID because supposely it's already of "@loader_path"
echo "icudata referenced by icuuc"
echo " old ID : $icudata_id"
echo " old path : $icudata_path"
echo " new path : $icudata_path_new"
- name: π¦ Bundle executable, DLLs and data files (on Linux and macOS)
if: runner.os != 'Windows'
id: zip
run: |
# locate the data-dir
datadir=$(find "$(stack path $STACK_YAML_ARG --snapshot-install-root)/share" -type d -name "Agda-*")
echo "datadir: $datadir"
# locate the executable
executable=$(find "$(stack path $STACK_YAML_ARG --local-install-root)/bin" -name "als")
echo "executable: $executable"
# make a temporary directory for compresssing
mkdir zip
cp -r "$datadir" zip/data
if [[ ${{ runner.os }} == "macOS" ]]; then
cp -r dylib zip/dylib
fi
cp "$executable" zip/
# compress
cd zip
zip -r $ARTEFACT.zip ./*
cd ..
mv zip/$ARTEFACT.zip .
- name: π¦ Bundle executable, DLLs and data files (on Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
# locate the data-dir
$snapshot = (stack path $STACK_YAML_ARG --snapshot-install-root)
$datadir = (ls $snapshot\share *Agda-* -Recurse -Directory).FullName
# locate the executable
$local = (stack path $STACK_YAML_ARG --local-install-root)
$executable = (ls $local\bin *als.exe* -Recurse -File).FullName
# make a temporary directory for compresssing
mkdir zip
cp -r $datadir zip/data
cp $executable zip/
# include text-icu DLLs
$mingw64bin = (stack path $STACK_YAML_ARG --extra-library-dirs).split(", ") -match "\\bin"
ls $mingw64bin
cp (ls $mingw64bin *libicudt*) zip/
cp (ls $mingw64bin *libicuin*) zip/
cp (ls $mingw64bin *libicuuc*) zip/
ls zip
# compress
cd zip
Compress-Archive * "$ARTEFACT.zip"
cd ..
mv zip/"$ARTEFACT.zip" .
- name: π§ͺ Run tests
run: stack test $STACK_YAML_ARG --ta --als-path=zip/als
# release (optional)
- name: π’ Release Artifacts
if: startsWith(github.ref, 'refs/tags/v') # so that only commits with a git tag would upload artifacts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload ${{ github.ref_name }} $ARTEFACT.zip --clobber