-
Notifications
You must be signed in to change notification settings - Fork 12
101 lines (86 loc) · 3.1 KB
/
ci.yml
File metadata and controls
101 lines (86 loc) · 3.1 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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
name: Test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: linux-x86_64
zig_target: x86_64-linux-musl
- os: macos-latest
target: macos-aarch64
zig_target: aarch64-macos
- os: windows-latest
target: windows-x86_64
zig_target: x86_64-windows
steps:
- uses: actions/checkout@v4
- name: Install Zig 0.16.0
uses: mlugg/setup-zig@v2
with:
version: 0.16.0
- name: Setup Node.js 22
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: ui/package-lock.json
- name: Cache .zig-cache
uses: actions/cache@v4
with:
path: .zig-cache
key: zig-${{ matrix.target }}-${{ hashFiles('src/**/*.zig', 'build.zig') }}
restore-keys: zig-${{ matrix.target }}-
- name: Build embedded UI assets
run: |
npm --prefix ui ci --no-audit --no-fund
npm --prefix ui run build
- name: Run unit tests
run: zig build test -Dbuild-ui=false --summary all 2>&1 | tee test-output.txt
- name: Run E2E tests
if: runner.os == 'Linux'
run: bash tests/test_e2e.sh
- name: Build ReleaseSmall
run: zig build -Dtarget=${{ matrix.zig_target }} -Doptimize=ReleaseSmall -Dbuild-ui=false
- name: Cross-compile linux-aarch64 (Termux/ARM)
if: runner.os == 'Linux'
run: zig build -Dtarget=aarch64-linux-musl -Doptimize=ReleaseSmall -Dbuild-ui=false
- name: Job summary
if: always()
run: |
echo "## nullHub CI - ${{ matrix.target }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Metric | Value |" >> $GITHUB_STEP_SUMMARY
echo "|--------|-------|" >> $GITHUB_STEP_SUMMARY
if [ -f test-output.txt ]; then
TESTS=$(grep -o '[0-9]*/[0-9]* tests passed' test-output.txt | head -1 || true)
RSS=$(grep 'run test' test-output.txt | grep -o 'MaxRSS:[^ ]*' | head -1 | cut -d: -f2 || true)
echo "| Tests | ${TESTS:-n/a} |" >> $GITHUB_STEP_SUMMARY
echo "| Test MaxRSS | ${RSS:-n/a} |" >> $GITHUB_STEP_SUMMARY
fi
BIN="zig-out/bin/nullhub"
if [ "${{ runner.os }}" = "Windows" ]; then
BIN="zig-out/bin/nullhub.exe"
fi
if [ -f "$BIN" ]; then
SIZE=$(wc -c < "$BIN" | tr -d ' ')
SIZE_HR=$(awk "BEGIN {printf \"%.1f MB\", $SIZE / 1048576}")
echo "| Binary (ReleaseSmall) | ${SIZE_HR} (${SIZE} bytes) |" >> $GITHUB_STEP_SUMMARY
fi
- name: Upload binary
if: success()
uses: actions/upload-artifact@v4
with:
name: nullhub-${{ matrix.target }}
path: zig-out/bin/nullhub${{ runner.os == 'Windows' && '.exe' || '' }}