-
Notifications
You must be signed in to change notification settings - Fork 1
512 lines (463 loc) · 13.2 KB
/
main.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
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
{
# can haz comments?
"name": "CI",
"on": [
"push"
],
"jobs": {
"test-os": {
"name": "Build on ${{ matrix.os }}",
"runs-on": "${{ matrix.os }}",
"strategy": {
"matrix": {
"os": [
"ubuntu-latest",
"windows-latest",
"macOS-latest"
]
}
},
"steps": [
{"uses": "actions/checkout@v1"},
{
"uses": "fortran-lang/setup-fpm@v5",
"with": {
"github-token": "${{ secrets.GITHUB_TOKEN }}"
}
},
{
"if": "matrix.os == 'macOS-latest'",
"name": "unfuck stupid macos sed", # https://stackoverflow.com/a/60562182/4347028
"run": "brew install gnu-sed && sudo cp $(which gsed) /usr/local/bin/sed"
},
{
"run": "bash gen-header.sh"
},
{
"if": "matrix.os == 'ubuntu-latest'",
"name": "Set ubuntu PATH",
"run": "echo \"$HOME/bin\" >> $GITHUB_PATH"
},
{
"if": "matrix.os == 'ubuntu-latest'",
"name": "Test fpm default",
"env": {
"FPM_FC": "gfortran-11"
},
"run":
"
set -exu \n
gfortran --version \n
# This is the pack linux stage, but it also does some \n
# testing. CI/CD could use some disentangling \n
fpm install
--profile release
--link-flag '-static-libgcc -static-libgfortran'
--prefix='$HOME' \n
# TODO: copy to a subdir for easier upload \n
cp $HOME/bin/syntran . \n
cp /lib/x86_64-linux-gnu/libquadmath.so.0 . \n
cp /lib/x86_64-linux-gnu/libc.so.6 . # not included \n
which syntran \n
which patchelf \n
chmod +x ./syntran \n
patchelf --set-rpath '$ORIGIN' ./syntran \n
#echo 'libquadmath ls:' \n
#ls /lib/x86_64-linux-gnu/libquadmath.so.0 \n
#ls /lib/x86_64-linux-gnu/ \n
#ls /lib/ \n
#exit 0 \n
# Test 'shebang' usage with no 'syntran' cmd prefix \n
chmod +x ./samples/shebang.syntran \n
./samples/shebang.syntran \n
# Test quines. May not be perfect with whitespace on Windows \n
syntran -q samples/quine-1.syntran > quine-1.syntran \n
diff quine-1.syntran samples/quine-1.syntran \n
syntran -q samples/quine-2.syntran > quine-2.syntran \n
diff quine-2.syntran samples/quine-2.syntran \n
syntran -q samples/quine-3.syntran > quine-3.syntran \n
diff quine-3.syntran samples/quine-3.syntran \n
# No significant difference between release and (default) debug profile. \n
# Maybe that will change after I copy the other half of AOC tests \n
#fpm test test \n
#fpm test long \n
fpm test test --profile release \n
fpm test long --profile release \n
"
},
{
"if": "matrix.os == 'ubuntu-latest'",
"run": "sudo apt-get install gfortran"
},
{
"if": "matrix.os == 'macOS-latest'",
"run": "
brew install gcc@12 &&
brew reinstall gcc@12"
},
{
"name": "Build",
"run":
"
#export OMP_NUM_THREADS=1 \n
bash ./build.sh debug \n
#ls -ltrh build/Debug \n
"
},
{
"if": "matrix.os != 'windows-latest'",
"name": "Test debug",
"run":
"
./build/Debug/syntran < samples/arithmetic.syntran \n
#./build/Debug/syntran < samples/bad-syntax.syntran \n
time ./build/Debug/test \n
"
},
{
"if": "matrix.os != 'windows-latest'",
"name": "Test release",
"run":
"
bash ./build.sh release \n
time ./build/Release/test \n
"
},
{
# TODO: make a bash pack script, then libgfortran-5.dll
# location can be automatically found
"if": "matrix.os == 'windows-latest'",
"name": "Pack Windows",
"run":
"
#where gfortran \n
dir C:\\mingw64\\bin\\libquad* \n
#dir C:\\mingw64\\lib \n
where api-ms-win-crt-time-l1-1-0.dll
bash ./build.sh release \n
#bash ./build.sh debug \n
# Could try adding -static-gcc etc in cmake to reduce the burden here \n
copy .\\build\\Release\\syntran.exe .\\ \n
copy C:\\mingw64\\bin\\libgfortran-5.dll .\\ \n
copy C:\\mingw64\\bin\\libquadmath-0.dll .\\ \n
copy C:\\mingw64\\bin\\libgcc_s_seh-1.dll .\\ \n
copy C:\\mingw64\\bin\\libwinpthread-1.dll .\\ \n
"
},
{
"if": "matrix.os == 'macOS-latest'",
"name": "Pack macOS",
"run":
"
set -exu \n
#set -x \n
gfortran-12 --version \n
which gfortran-12 \n
bash ./build.sh release \n
# TODO: copy to a subdir for easier upload \n
cp ./build/Release/syntran . \n
otool -L ./syntran \n
GCC_LIB_DIR=/opt/homebrew/opt/gcc@12/lib/gcc/12 \n
#ls ${GCC_LIB_DIR} \n
# A loop might be nice to dry this up \n
# libgcc_s is a dependency of libgfortran, not a direct \n
# dependency of syntran \n
cp ${GCC_LIB_DIR}/libgcc_s.1.1.dylib . \n
cp ${GCC_LIB_DIR}/libgfortran.5.dylib . \n
cp ${GCC_LIB_DIR}/libgomp.1.dylib . \n
cp ${GCC_LIB_DIR}/libquadmath.0.dylib . \n
#/usr/lib/libSystem.B.dylib
install_name_tool -change
\"${GCC_LIB_DIR}/libgfortran.5.dylib\"
\"@executable_path/libgfortran.5.dylib\"
\"./syntran\" \n
# There's no need to run install_name_tool for libgcc_s,
# it's already relative to @rpath in libgfortran \n
install_name_tool -change
\"${GCC_LIB_DIR}/libgomp.1.dylib\"
\"@executable_path/libgomp.1.dylib\"
\"./syntran\" \n
install_name_tool -change
\"${GCC_LIB_DIR}/libquadmath.0.dylib\"
\"@executable_path/libquadmath.0.dylib\"
\"./syntran\" \n
chmod +x ./syntran \n
./syntran --version \n
#cat ./src/compiler.F90 \n
"
},
{
"uses": "actions/upload-artifact@v4",
"if": "matrix.os == 'macOS-latest'",
"with": {
"path": "./syntran\n./libgfortran.5.dylib\n./libgcc_s.1.1.dylib\n./libgomp.1.dylib\n./libquadmath.0.dylib",
"name": "syntran-macos"
}
},
{
"uses": "actions/upload-artifact@v4",
"if": "matrix.os == 'windows-latest'",
"with": {
"path": "./syntran.exe\n./libgfortran-5.dll\n./libquadmath-0.dll\n./libgcc_s_seh-1.dll\n./libwinpthread-1.dll",
"name": "syntran-windows"
}
},
{
"uses": "actions/upload-artifact@v4",
"if": "matrix.os == 'ubuntu-latest'",
"with": {
# unfortunately gfortran-12 does not support -static-libquadmath
#"path": "./syntran\n./libquadmath.so.0\n./libc.so.6",
"path": "./syntran\n./libquadmath.so.0",
"name": "syntran-linux"
}
},
#{
# # TODO: just remove conditional from other test stage. This
# # never used to work on Windows bc gfortran-compiled bins
# # just wouldn't run on the github win runners. Maybe go back
# # to debug. Release has intermittent issues
# "if": "matrix.os == 'windows-latest'",
# "name": "Test Windows",
# "run":
# "
# bash ./test.sh \n
# "
#},
]
},
"build-rocky": {
# Build and package syntran from source in rocky linux Dockerfile
"name": "Build on rocky linux",
"runs-on": "ubuntu-latest",
"steps": [
{"uses": "actions/checkout@v1"},
{
"name": "Build docker",
"run":
"
docker --version \n
docker build . --file Dockerfile.rocky -t sy \n
## Test run \n
#docker run --entrypoint syntran sy --version \n
docker run --entrypoint /workdir/syntran/bin/syntran sy --version \n
# Start run in background (-d) with container name sy-ctr \n
sudo docker run --name sy-ctr -d -it sy \n
# Copy artifact from container \n
sudo docker cp sy-ctr:/workdir/syntran/bin/syntran-rocky.tgz . \n
# Extract to repackage as zip during upload \n
mkdir bin \n
cd bin \n
tar xvf ../syntran-rocky.tgz \n
#docker run sy --version # syntran is already the default entrypoint \n
#docker run sy -c \"1 + 2;\" \n
#ans=$(docker run sy -c \"1 + 2;\") \n
#if [[ \"$ans\" == \" ans = \\`3\\`\" ]] ; then \n
# echo \"win\" \n
# exit 0 \n
#else \n
# echo \"fail\" \n
# exit 1 \n
#fi \n
"
},
{
"uses": "actions/upload-artifact@v4",
"with": {
"path": "./bin/syntran\n./bin/libquadmath.so.0\n./bin/libgfortran.so.5",
"name": "syntran-rocky"
}
},
]
},
"test-gfortran": {
"name": "Test with gfortran-${{ matrix.gfortran }}",
"runs-on": "${{ matrix.os }}",
"strategy": {
"matrix": {
"os": [
"ubuntu-latest"
],
#"gfortran": [10, 11, 12, 13] # TODO: gfort 13 has an issue
#"gfortran": [9, 10, 11, 12] # gfort 9 started segfaulting with the introduction of fortran submodules circa 9ae38b9d
"gfortran": [10, 11, 12] # gfort <= 8 not available by default on github ci workers
}
},
"steps": [
{
"uses": "actions/checkout@v1"
},
{
"uses": "fortran-lang/setup-fpm@v5",
"with": {
"github-token": "${{ secrets.GITHUB_TOKEN }}"
}
},
{
"if": "matrix.os == 'ubuntu-latest'",
"name": "Test ubuntu gfortran-${{ matrix.gfortran }}",
"env": {
"FPM_FC": "gfortran-${{ matrix.gfortran }}"
},
"run":
"
set -exu \n
#fpm test test --verbose --flag -Wno-tabs \n
#fpm test long \n
fpm test test --profile release --verbose --flag -Wno-tabs \n
fpm test long --profile release --flag -Wno-tabs \n
"
}
]
},
"test-compilers": {
"name": "Test with ${{ matrix.toolchain.compiler }}-${{ matrix.toolchain.version }}",
"runs-on": "${{ matrix.os }}",
"strategy": {
"matrix": {
"os": [
"ubuntu-latest"
],
"toolchain": [
{"compiler": "intel", "version": "2024.2"},
#{"compiler": "intel", "version": "2024.1"}, # works
#{"compiler": "intel", "version": "2024.0"}, # works
#{"compiler": "intel", "version": "2023.2"}, # works
{"compiler": "intel", "version": "2023.1"},
##{"compiler": "intel", "version": "2023.0"}, # crashes on ` do while (is_whitespace(context%text(j:j)))`
##{"compiler": "intel", "version": "2022.2"}, # ifx 2022.2 doesn't have `do while ()` :(
{"compiler": "intel-classic", "version": "2021.10"},
#{"compiler": "intel-classic", "version": "2021.1"}, # complains about coarrays???
]
}
},
"steps": [
{
"uses": "actions/checkout@v1"
},
{
"uses": "fortran-lang/setup-fpm@v5",
"with": {
"github-token": "${{ secrets.GITHUB_TOKEN }}"
}
},
{
"uses": "fortran-lang/setup-fortran@v1",
"id": "setup-fortran",
"with": {
"compiler": "${{ matrix.toolchain.compiler }}",
"version": "${{ matrix.toolchain.version }}"
}
},
{
"if": "matrix.os == 'ubuntu-latest'",
"name": "Test ${{ matrix.toolchain.compiler }} ${{ matrix.toolchain.version }}",
"env": {
"FPM_FC": "${{ env.FC }}"
},
"run":
"
set -exu \n
fpm test test --verbose --flag \"-DSYNTRAN_INTEL -fpp\" \n
fpm test long --verbose --flag \"-DSYNTRAN_INTEL -fpp\" \n
"
}
]
},
"test-docker-build": {
# Build syntran from source in default top-level alpine Dockerfile
"name": "Test docker build",
"runs-on": "ubuntu-latest",
"steps": [
{"uses": "actions/checkout@v1"},
{
"name": "Test docker",
"run":
"
docker --version \n
docker build . -t sy \n
docker run --entrypoint syntran sy --version \n
docker run sy --version # syntran is already the default entrypoint \n
docker run sy -c \"1 + 2;\" \n
ans=$(docker run sy -c \"1 + 2;\") \n
if [[ \"$ans\" == \" ans = \\`3\\`\" ]] ; then \n
echo \"win\" \n
exit 0 \n
else \n
echo \"fail\" \n
exit 1 \n
fi \n
"
},
]
},
"test-linux-bin": {
# Test binary syntran installations on dockerfiles from ./docker/
# dir. These download the latest github "release", so there will be
# a lag between when you build the release and manually upload a
# binary package to github
"name": "Test linux bin",
"runs-on": "ubuntu-latest",
"steps": [
{"uses": "actions/checkout@v1"},
{
"name": "Test linux bin",
"run":
"
bash ./test-bin.sh \n
"
},
]
},
"test-macos-bin": {
"name": "Test macos bin",
"runs-on": "macOS-latest",
"steps": [
{
"name": "Test macos bin",
"run":
"
set -exu \n
# Test this to run syntran without homebrew gcc lib paths \n
brew remove gcc@12 \n
mv /opt/homebrew/bin /opt/homebrew/bin-BACKUP || true \n
mv /opt/homebrew/opt /opt/homebrew/opt-BACKUP || true \n
mv /opt/homebrew/Cellar /opt/homebrew/Cellar-BACKUP || true \n
#ls /opt/homebrew/ \n
curl -LO \"https://github.com/JeffIrwin/syntran/releases/latest/download/syntran-macos.zip\" \n
unzip syntran-macos*.zip \n
chmod +x ./syntran \n
./syntran -h \n
./syntran --version \n
./syntran -c 'println(\"hello world\");' \n
./syntran -c '1 + 2 * 3;' \n
./syntran -c '4 + 5 * [6: 10];' \n
./syntran -c 'sum([0: 101]);' \n
otool -L ./syntran \n
"
},
]
},
"test-windows-bin": {
"name": "Test windows bin",
"runs-on": "windows-latest",
"steps": [
{
"name": "Test windows bin",
"run":
"
curl -LO \"https://github.com/JeffIrwin/syntran/releases/latest/download/syntran-windows.zip\" \n
tar -xvf syntran-windows.zip \n
dir \n
.\\syntran.exe -h \n
.\\syntran.exe --version \n
.\\syntran.exe -c \"println(\"\"hello world\"\");\" \n
.\\syntran.exe -c \"1 + 2 * 3;\" \n
.\\syntran.exe -c \"4 + 5 * [6: 10];\" \n
.\\syntran.exe -c \"sum([0: 101]);\" \n
"
},
]
},
}
}