forked from ocaml-multicore/multicoretests
-
Notifications
You must be signed in to change notification settings - Fork 0
280 lines (252 loc) · 11.1 KB
/
common.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
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
name: Common CI workflow
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
on:
workflow_call:
inputs:
runs_on:
description: 'Type of machine + OS on which to run the tests'
type: string
default: 'ubuntu-latest'
cygwin:
description: >
Whether Cygwin should be used on Windows
type: boolean
default: false
timeout:
description: 'Timeout'
type: number
default: 180
dune_profile:
description: 'Dune profile to use'
type: string
default: 'dev'
runparam:
description: 'OCAMLRUNPARAM to use'
type: string
default: ''
dune_alias:
description: 'dune alias that should be built in the main step'
type: string
default: 'runtest'
compiler:
description: 'Compiler to use'
type: string
default: 'ocaml-base-compiler.5.0.0'
compiler_commit:
description: 'Version (commit) of the OCaml compiler to use'
type: string
default: ''
compiler_git_ref:
description: |
Git ref (such as "refs/heads/trunk") of the compiler, to set up caching properly when "compiler" is not a unique identifier
This ref will be looked up in the upstream "ocaml/ocaml" github repository
type: string
default: ''
custom_compiler_version:
description: |
Version number of the custom OCaml compiler to install (eg 5.1.0+gite4954296e68)
This version number will be used by setup-ocaml in its cache key so, if it identifies a precise commit, `compiler_git_ref` can be empty
type: string
default: ''
custom_compiler_src:
description: |
Source (URL) of the custom OCaml compiler to install (eg https://github.com/ocaml/ocaml/archive/e4954296e68.tar.gz)
Must be set if custom_compiler_version is
type: string
default: ''
custom_ocaml_package_version:
description: |
Version number of the OCaml OPAM package to use
Defaults to custom_compiler_version chunked at [+~-]
type: string
default: ''
jobs:
test:
env:
QCHECK_MSG_INTERVAL: '60'
DUNE_PROFILE: ${{ inputs.dune_profile }}
OCAMLRUNPARAM: ${{ inputs.runparam }}
DUNE_CI_ALIAS: ${{ inputs.dune_alias }}
COMPILER: ${{ inputs.compiler }}
OCAML_COMPILER_GIT_REF: ${{ inputs.compiler_git_ref }}
CUSTOM_COMPILER_VERSION: ${{ inputs.custom_compiler_version }}
CUSTOM_COMPILER_SRC: ${{ inputs.custom_compiler_src }}
CUSTOM_OCAML_PKG_VERSION: ${{ inputs.custom_ocaml_package_version }}
# For the record, here is how to set up the environment to test
# a PR-version of the compiler
# OCAML_COMPILER_GIT_REF: 'refs/pull/12345/head'
# CUSTOM_COMPILER_VERSION: '5.1.0+pr12345'
# CUSTOM_COMPILER_SRC: 'https://github.com/ocaml/ocaml/archive/refs/pull/12345/head.tar.gz'
runs-on: ${{ inputs.runs_on }}
timeout-minutes: ${{ inputs.timeout }}
steps:
- name: Configure environment (Cygwin)
run: |
# Ensure that .expected files are not modified by check out
# as, in Cygwin, the .expected should use LF line endings,
# rather than Windows’ CRLF
git config --global core.autocrlf input
# Set up OPAM environment variables for the particular
# Cygwin case
echo OPAMYES=1 >> $env:GITHUB_ENV
echo OPAMROOT=/cygdrive/d/opam >> $env:GITHUB_ENV
if: "runner.os == 'Windows' && inputs.cygwin"
- name: Checkout code
uses: actions/checkout@v4
- name: Pre-setup ($PATH, cache prefix, custom OPAM package for the compiler)
id: presetup
shell: bash
run: |
if [ "${COMPILER##*32bit}" = "" ]; then
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install pkg-config:i386 libzstd1:i386 libzstd-dev:i386 libgcc-s1:i386
fi
# Generate an OPAM config for a custom compiler
if [ -n "$CUSTOM_COMPILER_VERSION" ]; then
if [ -z "$CUSTOM_COMPILER_SRC" ]; then
echo '::error title=$CUSTOM_COMPILER_SRC not set::$CUSTOM_COMPILER_SRC must be set whenever $CUSTOM_COMPILER_VERSION is'
exit 1
fi
if [ -z "$CUSTOM_OCAML_PKG_VERSION" ]; then
CUSTOM_OCAML_PKG_VERSION="${CUSTOM_COMPILER_VERSION%%[~+-]*}"
fi
if [ "$RUNNER_OS" = "Windows" ]; then
OPAMTEMPLATE=.github/opam/ocaml-variants.opam.windows
else
OPAMTEMPLATE=.github/opam/ocaml-variants.opam.unix
fi
OPAMDIR=".github/opam/custom/packages/ocaml-variants/ocaml-variants.$CUSTOM_COMPILER_VERSION"
mkdir -p "$OPAMDIR"
awk -v compiler="$CUSTOM_COMPILER_VERSION" \
-v compilersrc="$CUSTOM_COMPILER_SRC" \
-v ocamlpkg="$CUSTOM_OCAML_PKG_VERSION" \
'{ sub("__OCAML_COMPILER_FULL_VERSION__", compiler); \
sub("__OCAML_COMPILER_SRC__", compilersrc); \
sub("__OCAML_OPAM_PACKAGE_VERSION__", ocamlpkg); \
print }' < $OPAMTEMPLATE \
> "$OPAMDIR/opam"
echo Generated OPAM package configuration:
echo ------------------------------------------------
cat "$OPAMDIR/opam"
echo ------------------------------------------------
# Reset $COMPILER keeping the options
if [ "${COMPILER##*,*}" "=" "$COMPILER" ];
then OPTS="";
else OPTS=",${COMPILER#*,}";
fi
echo "COMPILER=ocaml-variants.$CUSTOM_COMPILER_VERSION$OPTS" >> "$GITHUB_ENV"
cat "$GITHUB_ENV"
fi
# Pick up a robust cache prefix
if [ -n "$OCAML_COMPILER_GIT_REF" ]; then
cache_prefix="$(git ls-remote https://github.com/ocaml/ocaml.git "$OCAML_COMPILER_GIT_REF" | cut -f 1 | head -n 1)"
else
cache_prefix=v1
fi
echo "cache_prefix=$cache_prefix" >> "$GITHUB_OUTPUT"
cat "$GITHUB_OUTPUT"
# Save pristine PATH for cache action (Cygwin messes it up)
echo "cache_path=$PATH" >> "$GITHUB_OUTPUT"
- name: Install OCaml compiler ${{ env.COMPILER }} (Linux / macOS)
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: ${{ env.COMPILER }}
opam-repositories: |
local: file://${{ github.workspace }}/.github/opam/custom
default: https://github.com/ocaml/opam-repository.git
override: https://github.com/shym/custom-opam-repository.git
opam-depext: false
dune-cache: true
cache-prefix: ${{ steps.presetup.outputs.cache_prefix }}
if: runner.os != 'Windows'
- name: Install OCaml compiler ${{ env.COMPILER }} (Windows)
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: ${{ env.COMPILER }}
opam-repositories: |
local: ${{ github.workspace }}\.github\opam\custom
dra27: https://github.com/dra27/opam-repository.git#windows-5.0
override: https://github.com/shym/custom-opam-repository.git
default: https://github.com/ocaml-opam/opam-repository-mingw.git#sunset
upstream: https://github.com/ocaml/opam-repository.git
opam-depext: false
cache-prefix: ${{ steps.presetup.outputs.cache_prefix }}
if: "runner.os == 'Windows' && !inputs.cygwin"
- name: Restore Cygwin packages (Cygwin)
uses: actions/cache/restore@v3
id: cache_cygwin
env:
PATH: ${{ steps.presetup.outputs.cache_path }}
with:
path: |
C:\cygwin-packages
key: cygwin-packages-opam-2.0.7-1
if: "runner.os == 'Windows' && inputs.cygwin"
- name: Install Cygwin (in particular OPAM) (Cygwin)
uses: cygwin/cygwin-install-action@v4
with:
packages: opam
install-dir: 'D:\cygwin'
if: "runner.os == 'Windows' && inputs.cygwin"
- name: Save Cygwin packages (Cygwin)
uses: actions/cache/save@v3
env:
PATH: ${{ steps.presetup.outputs.cache_path }}
with:
path: |
C:\cygwin-packages
key: cygwin-packages-opam-2.0.7-1
if: "runner.os == 'Windows' && inputs.cygwin && steps.cache_cygwin.outputs.cache-hit != 'true'"
- name: Restore OPAM state (Cygwin)
uses: actions/cache/restore@v3
id: cache_opam
env:
PATH: ${{ steps.presetup.outputs.cache_path }}
with:
path: |
D:\opam
key: ${{ steps.presetup.outputs.cache_prefix }}-cygwin-opam-${{ env.COMPILER }}
if: "runner.os == 'Windows' && inputs.cygwin"
- name: Install OCaml compiler ${{ env.COMPILER }} (Cygwin)
run: |
opam init --disable-sandboxing --auto-setup --bare
opam repository add --all main "https://github.com/ocaml/opam-repository.git"
opam repository add --all windows "https://github.com/ocaml-opam/opam-repository-mingw.git#sunset"
opam repository add --all override "https://github.com/shym/custom-opam-repository.git"
opam repository add --all dra27 "https://github.com/dra27/opam-repository.git#windows-5.0"
opam repository add --all local "./.github/opam/custom/"
opam switch create default --repositories=dra27,override,windows,main --packages "${env:COMPILER}"
if: "runner.os == 'Windows' && inputs.cygwin && steps.cache_opam.outputs.cache-hit != 'true'"
- name: Set up macOS environment ($OPAMJOBS)
if: runner.os == 'macOS'
run: |
echo "OPAMJOBS=1" >> $GITHUB_ENV
- name: Install Multicore Tests dependencies
run: |
opam install . --deps-only --with-test
- name: Show configuration and clean up
run: |
opam exec -- ocamlc -config
opam config list
opam exec -- dune printenv
opam list --columns=name,installed-version,repository,synopsis-or-target
opam clean --all-switches --unused-repositories --logs --download-cache --repo-cache
- name: Save OPAM state (Cygwin)
uses: actions/cache/save@v3
env:
PATH: ${{ steps.presetup.outputs.cache_path }}
with:
path: |
D:\opam
key: ${{ steps.presetup.outputs.cache_prefix }}-cygwin-opam-${{ env.COMPILER }}
if: "runner.os == 'Windows' && inputs.cygwin"
- name: Build the test suite
run: opam exec -- dune build
- name: Run the internal package tests
run: opam exec -- dune runtest -j1 --no-buffer --display=quiet --cache=disabled --error-reporting=twice test/
- name: Run the multicore test suite
id: mainstep
run: opam exec -- dune build "@ci" -j1 --no-buffer --display=quiet --cache=disabled --error-reporting=twice