-
Notifications
You must be signed in to change notification settings - Fork 7
498 lines (478 loc) · 17.4 KB
/
test.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
name: Build, Test & Release
# Build, Test & Release (BTR) run for:
# - pushes to the main branch
# - new tags are pushed
# - for pull requests
#
# Releases are tagged with vX.Y.Z. We determine if we are building for a release
# or not by looking if the tag name starts with 'v'.
#
# To release:
# - create new branch using name: release-vX.Y.Z
# - update version in common.mk
# - update CHANGELOG.md, second entry must equal version in common.mk
# - first entry is assumed to be "Unreleased"
# - push a tag like vX.Y.Z which is equal to version in common.mk
#
on:
pull_request:
push:
branches:
- main
tags:
- v*
# NOTE: Jobs for version tagged releases just pattern match on any tag starting
# with 'v'. That's probably a version tag, but could be something else. Is there
# a better way to match?
jobs:
test-macos:
strategy:
fail-fast: false
matrix:
os: [macos-11, macos-12, macos-13]
runs-on: ${{ matrix.os }}
steps:
- name: "Show env"
run: env
- name: "Set BUILD_RELEASE when we are building for a version tag"
run: |
echo "BUILD_RELEASE=1" >> $GITHUB_ENV
if: startsWith(github.ref, 'refs/tags/v')
- name: "Enable dumping core files"
run: |
sudo sysctl kern.corefile=core.%P
ulimit -c unlimited
- name: "Check out repository code"
uses: actions/checkout@v3
- name: "Cache stuff"
uses: actions/cache@v3
with:
path: |
~/.cache/acton/
~/.stack
~/zig-cache
key: ${{ matrix.os }}
- name: "Install build prerequisites"
run: brew install haskell-stack
- name: "Build Acton"
run: |
export ZIG_LOCAL_CACHE_DIR=~/zig-cache
make -j2 -C ${{ github.workspace }} BUILD_RELEASE=${{ env.BUILD_RELEASE }}
- name: "Build a release"
run: make -C ${{ github.workspace }} release
- name: "Upload artifact"
uses: actions/upload-artifact@v3
with:
name: acton-${{ matrix.os }}
path: ${{ github.workspace }}/acton-darwin-x86_64*
if-no-files-found: error
- name: "Run tests"
run: make -C ${{ github.workspace }} test
- name: "Upload core file & binaries as artifacts on test failure"
if: failure()
uses: actions/upload-artifact@v3
with:
name: test-debug-${{ matrix.os }}-${{ github.run_id }}.zip
path: |
${{ github.workspace }}/test/core*
${{ github.workspace }}/test/db*.log
${{ github.workspace }}/test/rts/ddb_test_client
${{ github.workspace }}/test/rts/ddb_test_server
test-linux:
strategy:
fail-fast: false
matrix:
include:
- os: "debian"
version: "11"
- os: "debian"
version: "12"
- os: "ubuntu"
version: "22.04"
- os: "ubuntu"
version: "22.10"
- os: "ubuntu"
version: "23.04"
runs-on: ubuntu-latest
container:
image: ${{ matrix.os }}:${{ matrix.version }}
steps:
- name: "Show platform and environment"
run: |
env
cat /proc/cpuinfo
- name: "Set BUILD_RELEASE when we are building for a version tag"
if: startsWith(github.ref, 'refs/tags/v')
run: |
echo "BUILD_RELEASE=1" >> $GITHUB_ENV
- name: "Check out repository code"
uses: actions/checkout@v3
- name: "Cache stuff"
uses: actions/cache@v3
with:
path: |
~/.cache/acton/
~/.stack
~/zig-cache
key: ${{ matrix.os }}-${{ matrix.version }}
- name: "chown our home dir to avoid stack complaining"
run: chown -R root:root /github/home
- name: "Install build prerequisites"
run: |
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -qy bzip2 curl haskell-stack make procps zlib1g-dev
- name: "Upgrade stack on old distributions"
if: ${{ (matrix.os == 'ubuntu') && (matrix.version == '20.04') }}
run: |
stack upgrade
echo "PATH=~/.local/bin:$PATH" >> $GITHUB_ENV
- name: "Build Acton"
run: |
export ZIG_LOCAL_CACHE_DIR=~/zig-cache
make -j2 -C ${GITHUB_WORKSPACE} BUILD_RELEASE=${{ env.BUILD_RELEASE }}
- name: "Build a release"
run: make -C ${GITHUB_WORKSPACE} release
- name: "Upload artifact"
uses: actions/upload-artifact@v3
with:
name: acton-${{ matrix.os }}-${{ matrix.version }}
path: ${{ github.workspace }}/acton-linux-x86_64*
if-no-files-found: error
- name: "Run tests"
run: make -C ${GITHUB_WORKSPACE} test
build-debs:
runs-on: ubuntu-latest
container:
image: debian:bullseye
steps:
- name: "Show platform and environment"
run: |
env
cat /proc/cpuinfo
- name: "Set BUILD_RELEASE when we are building for a version tag"
run: |
echo "BUILD_RELEASE=1" >> $GITHUB_ENV
if: startsWith(github.ref, 'refs/tags/v')
- name: "Check out repository code"
uses: actions/checkout@v3
- name: "Cache stuff"
uses: actions/cache@v3
with:
path: |
~/.cache/acton/
~/.stack
~/zig-cache
key: build-debs
- name: "Install build prerequisites"
run: |
apt-get update
apt-get install -qy bzip2 curl haskell-stack make procps zlib1g-dev
apt-get install -qy bash-completion build-essential debhelper devscripts
- name: "Build Debian packages"
run: |
export ZIG_LOCAL_CACHE_DIR=~/zig-cache
make -C ${GITHUB_WORKSPACE} debs BUILD_RELEASE=${{ env.BUILD_RELEASE }} STATIC_ACTONC=true
- name: "Compute variables"
id: vars
run: |
echo "debdir=$(realpath ${GITHUB_WORKSPACE}/../deb)" >> $GITHUB_OUTPUT
echo "artifact_dir=$(dirname ${{ github.workspace }})" >> $GITHUB_OUTPUT
- name: "Move deb files into place for easy artifact extraction"
run: |
mkdir -p ${{ steps.vars.outputs.debdir }}
ls ${{ steps.vars.outputs.debdir }}/../
mv ${{ steps.vars.outputs.debdir }}/../acton_* ${{ steps.vars.outputs.debdir }}/
- name: "Upload artifact"
uses: actions/upload-artifact@v3
with:
name: acton-debs
# Using a wildcard and then deb here to force the entire directory to
# be part of resulting artifact.
path: ${{ steps.vars.outputs.artifact_dir }}/*deb/
if-no-files-found: error
run-macos:
needs: test-macos
strategy:
fail-fast: false
matrix:
os: [macos-11, macos-12, macos-13]
runs-on: ${{ matrix.os }}
steps:
- name: "Download artifacts for Macos, built on macos-11"
uses: actions/download-artifact@v3
with:
name: acton-macos-11
- name: "Extract acton"
run: |
tar Jxvf $(ls acton-darwin*.tar.xz | tail -n1)
- name: "Compile acton program"
run: |
echo '#!/usr/bin/env runacton' > test-runtime.act
echo 'actor main(env):' >> test-runtime.act
echo ' print("Hello, world")' >> test-runtime.act
echo ' env.exit(0)' >> test-runtime.act
chmod a+x test-runtime.act
export PATH=$(pwd)/acton/bin:$PATH
./test-runtime.act
./test-runtime.act | grep "Hello, world"
run-linux:
needs: build-debs
strategy:
fail-fast: false
matrix:
include:
- os: "debian"
version: "10"
- os: "debian"
version: "11"
- os: "debian"
version: "12"
- os: "ubuntu"
version: "18.04"
- os: "ubuntu"
version: "20.04"
- os: "ubuntu"
version: "22.04"
- os: "ubuntu"
version: "22.10"
- os: "ubuntu"
version: "23.04"
runs-on: ubuntu-latest
container:
image: ${{ matrix.os }}:${{ matrix.version }}
options: --privileged --ulimit core=-1 --security-opt seccomp=unconfined
steps:
- name: "Show platform and environment"
run: |
env
cat /proc/cpuinfo
- name: "Download .deb files"
uses: actions/download-artifact@v3
with:
name: acton-debs
- name: "Install acton from .deb"
run: |
apt update
apt install -y ./deb/acton_*.deb
actonc --version
- name: "Enable dumping core files to /tmp/core..."
run: |
apt install -qy procps
cat /proc/sys/kernel/core_pattern
sysctl kernel.core_pattern='/tmp/core.%h.%e.%t' || true
cat /proc/sys/kernel/core_pattern
ulimit -c unlimited
- name: "Compile acton program"
run: |
echo '#!/usr/bin/env runacton' > test-runtime.act
echo 'actor main(env):' >> test-runtime.act
echo ' print("Hello, world")' >> test-runtime.act
echo ' env.exit(0)' >> test-runtime.act
chmod a+x test-runtime.act
./test-runtime.act
./test-runtime.act | grep "Hello, world"
for I in $(seq 50); do ./test-runtime.act || break; done
- name: "ls core"
if: failure()
run: |
pwd
ls
find /tmp
mv /tmp/core* .
- name: "Upload core file & binaries as artifacts on test failure"
if: failure()
uses: actions/upload-artifact@v3
with:
name: coredumps-${{ matrix.os }}-${{ matrix.version }}-${{ github.run_id }}.zip
path: |
${{ github.workspace }}/core*
# If we are on the main branch, we'll create or update a pre-release called
# 'tip' which holds the latest build output from the main branch! We upload
# artifacts twice, first with the version number held in the filename and a
# second time after being renamed to remove the version number in the
# filename, thus providing a stable URL for downloading the tip tar balls.
pre-release-tip:
# Only run on the main branch
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: [test-macos, test-linux, build-debs]
steps:
- name: "Delete current tip release & tag"
uses: dev-drprasad/[email protected]
with:
delete_release: true
tag_name: tip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: "Check out repository code"
uses: actions/checkout@v3
- name: "Download artifacts for Macos, built on macos-11"
uses: actions/download-artifact@v3
with:
name: acton-macos-11
- name: "Download artifacts for Linux, built on Debian:11"
uses: actions/download-artifact@v3
with:
name: acton-debian-11
- name: "Download artifacts for Debian Linux"
uses: actions/download-artifact@v3
with:
name: acton-debs
- name: "List downloaded artifacts"
run: |
ls
ls deb
- name: "Workaround for changelog extractor that looks for number versions in headlines, which won't work for 'Unreleased'"
run: sed -i -e 's/^## Unreleased/## [999.9] Unreleased\nThis is an unreleased snapshot built from the main branch. Like a nightly but more up to date./' CHANGELOG.md
- name: "Extract release notes"
id: extract-release-notes
uses: ffurrer2/extract-release-notes@v1
- name: "(re-)create 'tip' release notes and upload artifacts as assets"
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: "acton*.tar*,deb/*deb"
body: ${{ steps.extract-release-notes.outputs.release_notes }}
draft: false
prerelease: true
name: "tip"
tag: "tip"
token: ${{ secrets.GITHUB_TOKEN }}
replacesArtifacts: true
- name: "Remove version number from darwin tar ball"
run: mv $(ls acton-darwin*.tar.xz | tail -n1) acton-darwin-x86_64.tar.xz
- name: "Remove version number from linux tar ball"
run: mv $(ls acton-linux-x86_64*.tar.xz | tail -n1) acton-linux-x86_64.tar.xz
- name: "Remove version number from debian package"
run: mv $(ls deb/acton_*.deb | tail -n1) deb/acton_tip_amd64.deb
- name: "List files for debug"
run: |
ls
ls deb
- name: "Upload artifacts without version number for stable links"
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: "acton*.tar*,deb/acton_*.deb"
body: ${{ steps.extract-release-notes.outputs.release_notes }}
draft: false
prerelease: true
name: "tip"
tag: "tip"
token: ${{ secrets.GITHUB_TOKEN }}
replacesArtifacts: true
# Release job, only run for version tagged releases.
release:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs: [test-macos, test-linux, build-debs]
steps:
- name: "Check out repository code"
uses: actions/checkout@v3
- name: "Download artifacts for Macos, built on macos-11"
uses: actions/download-artifact@v3
with:
name: acton-macos-11
- name: "Download artifacts for Linux, built on Debian:11"
uses: actions/download-artifact@v3
with:
name: acton-debian-11
- name: "Download artifacts for Debian Linux"
uses: actions/download-artifact@v3
with:
name: acton-debs
- name: "List downloaded artifacts"
run: ls
- name: "Extract release notes"
id: extract-release-notes
uses: ffurrer2/extract-release-notes@v1
- name: "Create release"
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: "acton*.tar*,deb/*deb"
body: ${{ steps.extract-release-notes.outputs.release_notes }}
draft: false
token: ${{ secrets.GITHUB_TOKEN }}
replacesArtifacts: true
# Update apt repo
update-apt-repo:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
container:
image: debian:bullseye
needs: [test-macos, test-linux, build-debs]
steps:
- name: Install build prerequisites
run: |
apt-get update
apt-get install -qy git gnupg reprepro
- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v4
with:
gpg_private_key: ${{ secrets.APT_GPG_PRIVATE_KEY }}
- name: Check out code of apt.acton-lang.io repo
uses: actions/checkout@v3
with:
repository: actonlang/apt.acton-lang.io
path: apt
ssh-key: ${{ secrets.APT_DEPLOY_KEY }}
- name: "Download artifacts for Debian Linux"
uses: actions/download-artifact@v3
with:
name: acton-debs
- name: "Include new deb in Apt repository"
run: |
cd apt
reprepro include bullseye ../deb/*.changes
- name: "Push updates to git repository for apt.acton-lang.io"
run: |
cd apt
git config user.name "Apt Bot"
git config user.email [email protected]
git add .
git status
git diff
git commit -a -m "Updated apt package index"
git push
# Update our homebrew tap
update-homebrew:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
# Depend on all test jobs so we don't update brew repo in case anything fails
needs: [test-macos, test-linux, build-debs]
steps:
- name: "Check out code of main acton repo"
uses: actions/checkout@v3
- name: "Get the version from common.mk"
id: get_version
run: echo "version=$(grep VERSION= common.mk | cut -d = -f 2)" >> $GITHUB_OUTPUT
- run: wget https://github.com/actonlang/acton/archive/refs/tags/v${{ steps.get_version.outputs.version }}.tar.gz
- run: sha256sum v${{ steps.get_version.outputs.version }}.tar.gz
- id: shasum
run: echo "sum=$(sha256sum v${{ steps.get_version.outputs.version }}.tar.gz | cut -d' ' -f1)" >> $GITHUB_OUTPUT
- name: "Check out code of our brew repo"
uses: actions/checkout@v3
with:
repository: actonlang/homebrew-acton
path: homebrew-acton
- name: "Update formula in homebrew-acton from acton repo"
run: |
cp homebrew/Formula/acton.rb homebrew-acton/Formula/acton.rb
- name: "Update brew formula for acton with new version"
run: |
sed -i -e 's,^ url.*, url "https://github.com/actonlang/acton/archive/refs/tags/v${{ steps.get_version.outputs.version }}.tar.gz",' -e 's/^ sha256.*/ sha256 "${{ steps.shasum.outputs.sum }}"/' homebrew-acton/Formula/acton.rb
- name: "Create Pull Request"
uses: peter-evans/create-pull-request@v3
with:
path: homebrew-acton
token: ${{ secrets.ACTBOT_PAT }}
branch: acton-v${{ steps.get_version.outputs.version }}
title: "acton v${{ steps.get_version.outputs.version }}"
body: |
Automatic update triggered by release on actonlang/acton.
committer: Acton Bot <[email protected]>
commit-message: "acton v${{ steps.get_version.outputs.version }}"
signoff: false