Repository navigation
196 lines (172 loc) · 6.75 KB
/
Copy pathprecompile.yml
File metadata and controls
196 lines (172 loc) · 6.75 KB
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
name: Build precompiled NIFs
on:
push:
tags: ['v*']
workflow_dispatch:
permissions:
contents: read
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- { target: x86_64-linux-gnu, os: ubuntu-latest }
- { target: x86_64-linux-musl, os: ubuntu-latest }
- { target: aarch64-linux-gnu, os: ubuntu-latest }
- { target: aarch64-linux-musl, os: ubuntu-latest }
- { target: aarch64-macos-none, os: macos-15 }
- { target: x86_64-windows-gnu, os: windows-2022 }
steps:
- uses: actions/checkout@v4
- uses: goto-bus-stop/setup-zig@v2
with:
version: 0.16.0
- uses: erlef/setup-beam@v1
with:
otp-version: '27'
elixir-version: '1.18'
- name: Build NIF artifact
shell: bash
env:
ZIGLER_RELEASE_MODE: fast
QUICKBEAM_CPU: baseline
ZIG_LOCAL_CACHE_DIR: ${{ runner.temp }}/zig-local-cache
ZIG_GLOBAL_CACHE_DIR: ${{ runner.temp }}/zig-global-cache
run: |
mix local.hex --force
mix local.rebar --force
mix deps.get
# Zigler 0.16.0's Hex package omitted its Windows compatibility
# headers. Remove this pinned workaround after Zigler PR #596 ships.
if [ "${{ matrix.target }}" = "x86_64-windows-gnu" ]; then
header_dir="deps/zigler/priv/erl_nif_win"
header_url="https://raw.githubusercontent.com/E-xyza/zigler/b83bd59b9fec5543ae712c1838cfa7f526a882c4/priv/erl_nif_win"
mkdir -p "$header_dir"
curl --fail --silent --show-error --location \
"$header_url/erl_nif_win.h" -o "$header_dir/erl_nif_win.h"
curl --fail --silent --show-error --location \
"$header_url/erl_nif_api_funcs_win.h" -o "$header_dir/erl_nif_api_funcs_win.h"
echo "ee0162831e553eb559c1b884ce461b100a0ff792c401a66be9e6b5ad00883a77 $header_dir/erl_nif_win.h" | sha256sum -c -
echo "dd43c4dd22fb6a158af420754fb8cb6c255e069d87e1c294d09f3e9f897345ef $header_dir/erl_nif_api_funcs_win.h" | sha256sum -c -
fi
QUICKBEAM_BUILD=1 mix zigler_precompiled.build lib/quickbeam/native.ex \
--target "${{ matrix.target }}" \
--out artifacts
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target }}
path: artifacts/*.tar.gz
if-no-files-found: error
smoke:
needs: build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- { target: x86_64-linux-gnu, os: ubuntu-latest }
- { target: aarch64-linux-gnu, os: ubuntu-24.04-arm }
- { target: aarch64-macos-none, os: macos-15 }
- { target: x86_64-windows-gnu, os: windows-2022 }
steps:
- uses: actions/checkout@v4
- uses: erlef/setup-beam@v1
with:
otp-version: '27'
elixir-version: '1.18'
- uses: actions/download-artifact@v4
with:
name: ${{ matrix.target }}
path: artifacts
- name: Load and exercise the precompiled NIF
shell: bash
env:
ZIGLER_PRECOMPILED_GLOBAL_CACHE_PATH: ${{ runner.temp }}/quickbeam-precompiled
run: |
mix local.hex --force
mix local.rebar --force
mix deps.get
mkdir -p "$ZIGLER_PRECOMPILED_GLOBAL_CACHE_PATH"
cp artifacts/*.tar.gz "$ZIGLER_PRECOMPILED_GLOBAL_CACHE_PATH/"
rm checksum-QuickBEAM.Native.exs
mix compile
mix run scripts/smoke_precompiled.exs
# Alpine has no runner, so the artifact is loaded in a musl container. The
# project is reduced to the native module: a full checkout would compile
# the Hex dependencies for musl, which is the problem being tested around.
smoke-musl:
name: Smoke ${{ matrix.target }} on Alpine
needs: build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- { target: x86_64-linux-musl, os: ubuntu-latest, platform: linux/amd64 }
- { target: aarch64-linux-musl, os: ubuntu-24.04-arm, platform: linux/arm64 }
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: ${{ matrix.target }}
path: artifacts
- name: Load and exercise the precompiled NIF on Alpine
shell: bash
env:
ALPINE_IMAGE: hexpm/elixir:1.18.3-erlang-27.3-alpine-3.21.7
run: |
smoke_dir="${{ runner.temp }}/quickbeam-musl-smoke"
mkdir -p "$smoke_dir/lib/quickbeam/native" "$smoke_dir/artifacts" "$smoke_dir/scripts"
cp lib/quickbeam/native.ex "$smoke_dir/lib/quickbeam/native.ex"
cp lib/quickbeam/native/platform.ex "$smoke_dir/lib/quickbeam/native/platform.ex"
cp scripts/smoke_precompiled_native.exs "$smoke_dir/scripts/smoke.exs"
cp artifacts/*.tar.gz "$smoke_dir/artifacts/"
cat > "$smoke_dir/mix.exs" <<'ELIXIR'
defmodule QuickBEAMMuslSmoke.MixProject do
use Mix.Project
def project do
[
app: :quickbeam,
version: System.fetch_env!("QUICKBEAM_VERSION"),
elixir: "~> 1.15",
deps: [{:zigler_precompiled, "~> 0.1.6"}]
]
end
def application, do: [extra_applications: [:logger, :inets, :ssl, :public_key]]
end
ELIXIR
quickbeam_version=$(sed -n 's/^ @version "\(.*\)"/\1/p' mix.exs | head -n1)
docker run --rm --platform "${{ matrix.platform }}" \
-v "$smoke_dir:/workspace" \
-w /workspace \
-e QUICKBEAM_VERSION="$quickbeam_version" \
-e ZIGLER_PRECOMPILED_GLOBAL_CACHE_PATH=/tmp/quickbeam-precompiled \
"$ALPINE_IMAGE" /bin/sh -lc '
set -eu
mix local.hex --force
mix local.rebar --force
mix deps.get
mkdir -p "$ZIGLER_PRECOMPILED_GLOBAL_CACHE_PATH"
cp artifacts/*.tar.gz "$ZIGLER_PRECOMPILED_GLOBAL_CACHE_PATH/"
mix compile
mix run scripts/smoke.exs
'
# Artifacts reach the release only after every target loaded and ran.
release:
if: startsWith(github.ref, 'refs/tags/')
needs: [build, smoke, smoke-musl]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Upload artifacts to release
uses: softprops/action-gh-release@v2
with:
files: artifacts/*.tar.gz