-
Notifications
You must be signed in to change notification settings - Fork 0
223 lines (167 loc) · 6.88 KB
/
Copy pathci.yml
File metadata and controls
223 lines (167 loc) · 6.88 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
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
name: CI
on:
push:
branches: [yolo]
pull_request:
branches: [yolo]
jobs:
nix-build:
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-latest
system: x86_64-linux
- runner: ubuntu-24.04-arm
system: aarch64-linux
- runner: macos-14
system: aarch64-darwin
runs-on: ${{ matrix.runner }}
name: nix (${{ matrix.system }})
steps:
- uses: actions/checkout@v6
- uses: DeterminateSystems/nix-installer-action@main
- name: Build all packages
run: nix build -L
- name: Run checks
run: |
for check in $(nix eval .#checks.${{ matrix.system }} --apply 'cs: builtins.attrNames cs' --json | jq -r '.[]'); do
echo "::group::check: $check"
nix build -L ".#checks.${{ matrix.system }}.$check"
echo "::endgroup::"
done
- name: Upload C binary
uses: actions/upload-artifact@v6
with:
name: printable-binary-c-${{ matrix.system }}
path: result/bin/printable-binary-c
- name: Upload Zig binary
uses: actions/upload-artifact@v6
with:
name: printable-binary-zig-${{ matrix.system }}
path: result/bin/printable-binary-zig
- name: Upload APE binary (Linux only)
if: matrix.system == 'x86_64-linux'
run: nix build .#printableBinaryApe -L
# APE is already in the default suite on Linux, but build explicitly to be sure
- name: Upload APE artifact
if: matrix.system == 'x86_64-linux'
uses: actions/upload-artifact@v6
with:
name: printable-binary-ape-${{ matrix.system }}
path: result/bin/printable-binary-ape.com
- name: Build WASM (x86_64-linux only)
if: matrix.system == 'x86_64-linux'
run: nix build .#printableBinaryWasm -L
- name: Upload WASM artifact
if: matrix.system == 'x86_64-linux'
uses: actions/upload-artifact@v6
with:
name: printable-binary-wasm
path: result/bin/printable-binary.wasm
windows-build:
strategy:
fail-fast: false
matrix:
include:
- runner: windows-latest
arch: x86_64
runs-on: ${{ matrix.runner }}
name: windows (${{ matrix.arch }})
# aarch64-windows is covered by the cross-windows-aarch64 job below (reliable
# Linux cross-compile) instead of the GitHub windows-11-arm preview runner,
# which exits zig build with no output (toolchain instability, not a code bug —
# the same target cross-compiles clean from Linux). Revisit native ARM when
# the runner leaves preview.
steps:
- uses: actions/checkout@v6
- name: Install Zig
shell: bash
run: |
set -euo pipefail
version="0.16.0"
if [ "$version" = "latest" ]; then
version="$(curl -fsSL https://ziglang.org/download/index.json | ruby -rjson -e 'data = JSON.parse(STDIN.read); puts data.keys.grep(/\A\d+\.\d+\.\d+\z/).sort_by { |v| v.split(".").map(&:to_i) }.last')"
fi
case "${RUNNER_OS}-${RUNNER_ARCH}" in
Linux-X64) platform="x86_64-linux"; ext="tar.xz" ;;
Linux-ARM64) platform="aarch64-linux"; ext="tar.xz" ;;
macOS-X64) platform="x86_64-macos"; ext="tar.xz" ;;
macOS-ARM64) platform="aarch64-macos"; ext="tar.xz" ;;
Windows-X64) platform="x86_64-windows"; ext="zip" ;;
Windows-ARM64) platform="aarch64-windows"; ext="zip" ;;
*) echo "Unsupported runner: ${RUNNER_OS}-${RUNNER_ARCH}" >&2; exit 1 ;;
esac
archive="$RUNNER_TEMP/zig.$ext"
install_dir="$RUNNER_TEMP/zig"
curl -fsSL "https://ziglang.org/download/${version}/zig-${platform}-${version}.${ext}" -o "$archive"
mkdir -p "$install_dir"
if [ "$ext" = "zip" ]; then
unzip -q "$archive" -d "$install_dir"
else
tar -xf "$archive" -C "$install_dir"
fi
zig_dir="$(find "$install_dir" -mindepth 1 -maxdepth 1 -type d | head -n 1)"
echo "$zig_dir" >> "$GITHUB_PATH"
"$zig_dir/zig" version
- name: Build Zig CLI
run: zig build -Doptimize=ReleaseFast
- name: Build C via zig cc
shell: bash
run: |
zig cc -O3 -I. -o printable-binary-c.exe src/printable_binary.c -lpsapi
- name: Run Zig unit tests
run: zig build test
- name: Smoke test (roundtrip)
shell: bash
run: |
echo -n "Hello, World!" > /tmp/test_input.bin
./zig-out/bin/printable-binary-zig.exe /tmp/test_input.bin > /tmp/test_encoded.txt
./zig-out/bin/printable-binary-zig.exe -d /tmp/test_encoded.txt > /tmp/test_decoded.bin
if cmp -s /tmp/test_input.bin /tmp/test_decoded.bin; then
echo "Roundtrip PASS"
else
echo "Roundtrip FAIL"
exit 1
fi
- name: Upload Zig binary
uses: actions/upload-artifact@v6
with:
name: printable-binary-zig-${{ matrix.arch }}-windows
path: zig-out/bin/printable-binary-zig.exe
- name: Upload C binary
uses: actions/upload-artifact@v6
with:
name: printable-binary-c-${{ matrix.arch }}-windows
path: printable-binary-c.exe
# aarch64-windows build coverage via reliable Linux cross-compilation, in
# place of the flaky windows-11-arm preview runner. Build-only (a cross-built
# Windows binary can't execute on the Linux runner); runtime tests are covered
# natively on windows x86_64 above and on Linux/macOS via the nix checks.
cross-windows-aarch64:
runs-on: ubuntu-latest
name: cross (aarch64-windows)
steps:
- uses: actions/checkout@v6
- name: Install Zig (x86_64-linux host)
shell: bash
run: |
set -euo pipefail
version="0.16.0"
curl -fsSL "https://ziglang.org/download/${version}/zig-x86_64-linux-${version}.tar.xz" -o "$RUNNER_TEMP/zig.tar.xz"
mkdir -p "$RUNNER_TEMP/zig"
tar -xf "$RUNNER_TEMP/zig.tar.xz" -C "$RUNNER_TEMP/zig"
zig_dir="$(find "$RUNNER_TEMP/zig" -mindepth 1 -maxdepth 1 -type d | head -n 1)"
echo "$zig_dir" >> "$GITHUB_PATH"
"$zig_dir/zig" version
- name: Cross-compile aarch64-windows (Zig CLI + lib)
run: zig build -Dtarget=aarch64-windows -Doptimize=ReleaseFast
- name: Cross-compile aarch64-windows C CLI (zig cc, -lpsapi)
run: zig cc -target aarch64-windows-gnu -O3 -I. -o printable-binary-c-aarch64-windows.exe src/printable_binary.c -lpsapi
- name: Upload aarch64-windows binaries
uses: actions/upload-artifact@v6
with:
name: printable-binary-aarch64-windows
path: |
zig-out/bin/printable-binary-zig.exe
printable-binary-c-aarch64-windows.exe