-
Notifications
You must be signed in to change notification settings - Fork 8
192 lines (187 loc) · 6.75 KB
/
release.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
name: Build precompiled NIFs
on:
push:
branches:
- main
- release*
tags:
- "*"
pull_request:
branches: ["main"]
paths-ignore:
- "*.md"
- "**/*.md"
- "LICENSE*"
concurrency:
group: precompiled-${{ github.ref }}
cancel-in-progress: true
env:
PRE_BUILT_RELEASE_GITHUB_TOKEN: ${{ secrets.PRE_BUILT_RELEASE_GITHUB_TOKEN }}
jobs:
generate_id:
name: Generate ID of release
runs-on: ubuntu-latest
outputs:
formatted_date: ${{ steps.date.outputs.formatted_date }}
steps:
- name: Get current date
id: date
run: echo "formatted_date=$(date +'%Y-%m-%d-%H%M')" >> $GITHUB_OUTPUT
build_release:
needs: [generate_id]
name: NIF ${{ matrix.job.otp }} (${{ matrix.job.elixir }})
runs-on: ${{ matrix.job.os }}
strategy:
fail-fast: false
matrix:
job:
- { otp: 24.2, os: ubuntu-22.04, elixir: 1.14 }
- { otp: 26, os: ubuntu-22.04, elixir: 1.15 }
steps:
- uses: actions/checkout@v3
name: Check-out beaver
- uses: actions/checkout@v3
name: Check-out kinda
with:
repository: beaver-lodge/kinda
path: kinda
- run: mv kinda ..
- uses: actions/checkout@v3
name: Check-out Kinda
if: contains(github.event.pull_request.labels.*.name, 'checkout_kinda')
with:
repository: beaver-lodge/kinda
path: kinda_local
ref: remove-meta
- run: echo "BEAVER_KINDA_PATH=${PWD}/kinda_local" >> $GITHUB_ENV
if: contains(github.event.pull_request.labels.*.name, 'checkout_kinda')
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
elixir-version: ${{ matrix.job.elixir }} # Define the elixir version [required]
otp-version: ${{ matrix.job.otp }} # Define the OTP version [required]
- run: elixir --eval ":erlang.system_info(:nif_version) |> IO.puts"
- name: Set up Zig
uses: mlugg/setup-zig@v1
with:
version: 0.13.0
- uses: Jimver/cuda-toolkit@master
id: cuda-toolkit
with:
use-github-cache: false
log-file-suffix: '${{matrix.job.os}}-${{ matrix.job.otp }}-(${{ matrix.job.elixir }}).txt'
sub-packages: '["nvcc"]'
method: network
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Restore dependencies cache
uses: actions/cache@v3
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-
- name: Install dependencies
run: mix deps.get
- name: Strip dev suffix
run: sed -i 's/-dev//g' mix.exs
- uses: seanmiddleditch/gha-setup-ninja@master
- name: Install pre-build LLVM
run: |
python3 -m pip install -r dev-requirements.txt
echo "LLVM_CONFIG_PATH=$(python3 -c 'import mlir;print(mlir.__path__[0])')/bin/llvm-config" >> "$GITHUB_ENV"
- name: Production build
env:
MIX_ENV: prod
ELIXIR_MAKE_CACHE_DIR: .
run: |
mix elixir_make.precompile
- name: Purge artifacts
run: |
python3 -m pip uninstall -y mlir
mix clean
- name: Start mock server in the background
run: |
python3 -m http.server --directory . &> /dev/null &
sleep 3
ps aux
- run: curl http://127.0.0.1:8000/
- name: Run tests with prebuilt
env:
BEAVER_ARTEFACT_URL: http://127.0.0.1:8000/@{artefact_filename}
run: |
MIX_ENV=prod mix elixir_make.checksum --all --ignore-unavailable --only-local --print
mix clean
mix test --exclude vulkan --exclude todo
- name: Publish archives and packages
uses: softprops/action-gh-release@v1
if: ${{ github.repository == 'beaver-lodge/beaver' && env.PRE_BUILT_RELEASE_GITHUB_TOKEN != null }}
with:
files: |
*.tar.gz
repository: beaver-lodge/beaver-prebuilt
token: ${{ secrets.PRE_BUILT_RELEASE_GITHUB_TOKEN }}
tag_name: ${{ needs.generate_id.outputs.formatted_date }}
- name: Test dev compile
if: ${{ github.repository == 'beaver-lodge/beaver' && env.PRE_BUILT_RELEASE_GITHUB_TOKEN != null }}
env:
BEAVER_ARTEFACT_URL: "https://github.com/beaver-lodge/beaver-prebuilt/releases/download/${{ needs.generate_id.outputs.formatted_date }}/@{artefact_filename}"
run: |
mix run bench/enif_add_benchmark.exs
arm_docker:
needs: [generate_id]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
image:
- {
platform: "linux/arm64/v8",
suffix: "arm64",
zig: "https://ziglang.org/download/0.13.0/zig-linux-aarch64-0.13.0.tar.xz"
}
- {
platform: "linux/amd64",
suffix: "amd64",
zig: "https://ziglang.org/download/0.13.0/zig-linux-x86_64-0.13.0.tar.xz"
}
steps:
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
if: ${{ matrix.image.platform != 'linux/amd64' }}
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v6
with:
push: ${{ secrets.DOCKERHUB_USERNAME != '' }}
tags: jackalcooper/beaver-livebook-${{ matrix.image.suffix }}:latest
cache-from: type=registry,ref=jackalcooper/beaver-livebook-${{ matrix.image.suffix }}:latest
cache-to: type=inline
platforms: |
${{ matrix.image.platform }}
file: docker/livebook.dockerfile
build-args: |
ZIG_URL=${{ matrix.image.zig }}
- uses: actions/checkout@v3
name: Check-out beaver
with:
repository: beaver-lodge/beaver
path: beaver
- uses: actions/checkout@v3
name: Check-out kinda
with:
repository: beaver-lodge/kinda
path: kinda
- name: Build ARM
continue-on-error: true
if: ${{ matrix.image.platform == 'linux/arm64/v8' }}
run: docker run --platform ${{ matrix.image.platform }} -v $PWD:/src -w /src/beaver jackalcooper/beaver-livebook-${{ matrix.image.suffix }}:latest bash scripts/build-for-publish.sh
- name: Build x86
if: ${{ matrix.image.platform == 'linux/amd64' }}
run: docker run -v $PWD:/src -w /src/beaver jackalcooper/beaver-livebook-${{ matrix.image.suffix }}:latest bash scripts/build-for-publish.sh