Skip to content

Commit 3f42706

Browse files
committed
feat: bootstrap nullwatch MVP
0 parents  commit 3f42706

16 files changed

Lines changed: 3141 additions & 0 deletions

.github/workflows/ci.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
name: Test (${{ matrix.os }})
12+
runs-on: ${{ matrix.os }}
13+
defaults:
14+
run:
15+
shell: bash
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
include:
20+
- os: ubuntu-latest
21+
target: linux-x86_64
22+
zig_target: x86_64-linux-musl
23+
- os: macos-latest
24+
target: macos-aarch64
25+
zig_target: aarch64-macos
26+
- os: windows-latest
27+
target: windows-x86_64
28+
zig_target: x86_64-windows
29+
30+
steps:
31+
- uses: actions/checkout@v4
32+
33+
- name: Install Zig 0.15.2
34+
uses: mlugg/setup-zig@v2
35+
with:
36+
version: 0.15.2
37+
38+
- name: Cache Zig build outputs
39+
uses: actions/cache@v4
40+
with:
41+
path: |
42+
.zig-cache
43+
~/.cache/zig
44+
key: zig-${{ matrix.target }}-${{ hashFiles('src/**/*.zig', 'build.zig', 'build.zig.zon', 'tests/test_e2e.sh') }}
45+
restore-keys: zig-${{ matrix.target }}-
46+
47+
- name: Run unit tests
48+
run: zig build test --summary all 2>&1 | tee test-output.txt
49+
50+
- name: Run E2E tests
51+
if: runner.os == 'Linux'
52+
run: bash tests/test_e2e.sh
53+
54+
- name: Build ReleaseSmall
55+
run: zig build -Dtarget=${{ matrix.zig_target }} -Doptimize=ReleaseSmall -Dversion=ci
56+
57+
- name: Preserve host binary
58+
run: |
59+
mkdir -p ci-artifacts
60+
cp "zig-out/bin/nullwatch${{ runner.os == 'Windows' && '.exe' || '' }}" "ci-artifacts/nullwatch${{ runner.os == 'Windows' && '.exe' || '' }}"
61+
62+
- name: Job summary
63+
if: always()
64+
run: |
65+
echo "## nullwatch CI - ${{ matrix.target }}" >> "$GITHUB_STEP_SUMMARY"
66+
echo "" >> "$GITHUB_STEP_SUMMARY"
67+
echo "| Metric | Value |" >> "$GITHUB_STEP_SUMMARY"
68+
echo "|--------|-------|" >> "$GITHUB_STEP_SUMMARY"
69+
70+
if [ -f test-output.txt ]; then
71+
TESTS=$(grep -o '[0-9]*/[0-9]* tests passed' test-output.txt | head -1 || true)
72+
echo "| Tests | ${TESTS:-n/a} |" >> "$GITHUB_STEP_SUMMARY"
73+
fi
74+
75+
BIN="ci-artifacts/nullwatch"
76+
if [ "${{ runner.os }}" = "Windows" ]; then
77+
BIN="ci-artifacts/nullwatch.exe"
78+
fi
79+
if [ -f "$BIN" ]; then
80+
SIZE=$(wc -c < "$BIN" | tr -d ' ')
81+
SIZE_HR=$(awk "BEGIN {printf \"%.1f MB\", $SIZE / 1048576}")
82+
echo "| Binary (ReleaseSmall) | ${SIZE_HR} (${SIZE} bytes) |" >> "$GITHUB_STEP_SUMMARY"
83+
fi
84+
85+
- name: Upload binary
86+
if: success()
87+
uses: actions/upload-artifact@v4
88+
with:
89+
name: nullwatch-${{ matrix.target }}
90+
path: ci-artifacts/nullwatch${{ runner.os == 'Windows' && '.exe' || '' }}

.github/workflows/release.yml

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags: ['v*']
6+
workflow_dispatch:
7+
8+
jobs:
9+
build:
10+
name: Build (${{ matrix.target }})
11+
runs-on: ${{ matrix.os }}
12+
defaults:
13+
run:
14+
shell: bash
15+
strategy:
16+
matrix:
17+
include:
18+
- os: ubuntu-latest
19+
target: linux-x86_64
20+
zig_target: x86_64-linux-musl
21+
ext: ""
22+
- os: ubuntu-latest
23+
target: linux-aarch64
24+
zig_target: aarch64-linux-musl
25+
ext: ""
26+
- os: ubuntu-latest
27+
target: linux-riscv64
28+
zig_target: riscv64-linux-musl
29+
ext: ""
30+
- os: macos-latest
31+
target: macos-aarch64
32+
zig_target: aarch64-macos
33+
ext: ""
34+
- os: macos-latest
35+
target: macos-x86_64
36+
zig_target: x86_64-macos
37+
ext: ""
38+
- os: windows-latest
39+
target: windows-x86_64
40+
zig_target: x86_64-windows
41+
ext: ".exe"
42+
- os: windows-latest
43+
target: windows-aarch64
44+
zig_target: aarch64-windows
45+
ext: ".exe"
46+
47+
steps:
48+
- uses: actions/checkout@v4
49+
50+
- name: Install Zig 0.15.2
51+
uses: mlugg/setup-zig@v2
52+
with:
53+
version: 0.15.2
54+
55+
- name: Resolve build version
56+
id: version
57+
run: |
58+
if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
59+
echo "value=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
60+
else
61+
echo "value=dev" >> "$GITHUB_OUTPUT"
62+
fi
63+
64+
- name: Build ReleaseSmall
65+
run: zig build -Doptimize=ReleaseSmall -Dversion=${{ steps.version.outputs.value }} -Dtarget=${{ matrix.zig_target }}
66+
67+
- name: Upload artifact
68+
uses: actions/upload-artifact@v4
69+
with:
70+
name: nullwatch-${{ matrix.target }}
71+
path: zig-out/bin/nullwatch${{ matrix.ext }}
72+
73+
source:
74+
name: Prepare source archive
75+
runs-on: ubuntu-latest
76+
defaults:
77+
run:
78+
shell: bash
79+
80+
steps:
81+
- uses: actions/checkout@v4
82+
83+
- name: Create source archive
84+
run: |
85+
archive_name="nullwatch-source-${GITHUB_REF_NAME}.tar.gz"
86+
tar \
87+
--exclude='.git' \
88+
--exclude='.zig-cache' \
89+
--exclude='zig-out' \
90+
-czf "/tmp/${archive_name}" .
91+
mv "/tmp/${archive_name}" .
92+
echo "ARCHIVE_NAME=${archive_name}" >> "$GITHUB_ENV"
93+
94+
- name: Upload source archive
95+
uses: actions/upload-artifact@v4
96+
with:
97+
name: nullwatch-source
98+
path: ${{ env.ARCHIVE_NAME }}
99+
100+
release:
101+
needs: [build, source]
102+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
103+
runs-on: ubuntu-latest
104+
permissions:
105+
contents: write
106+
107+
steps:
108+
- uses: actions/download-artifact@v4
109+
110+
- name: Rename binaries
111+
run: |
112+
mv nullwatch-linux-x86_64/nullwatch nullwatch-linux-x86_64.bin
113+
mv nullwatch-linux-aarch64/nullwatch nullwatch-linux-aarch64.bin
114+
mv nullwatch-linux-riscv64/nullwatch nullwatch-linux-riscv64.bin
115+
mv nullwatch-macos-aarch64/nullwatch nullwatch-macos-aarch64.bin
116+
mv nullwatch-macos-x86_64/nullwatch nullwatch-macos-x86_64.bin
117+
mv nullwatch-windows-x86_64/nullwatch.exe nullwatch-windows-x86_64.exe
118+
mv nullwatch-windows-aarch64/nullwatch.exe nullwatch-windows-aarch64.exe
119+
120+
- name: Create release
121+
uses: softprops/action-gh-release@v2
122+
with:
123+
files: |
124+
nullwatch-linux-x86_64.bin
125+
nullwatch-linux-aarch64.bin
126+
nullwatch-linux-riscv64.bin
127+
nullwatch-macos-aarch64.bin
128+
nullwatch-macos-x86_64.bin
129+
nullwatch-windows-x86_64.exe
130+
nullwatch-windows-aarch64.exe
131+
nullwatch-source/*.tar.gz
132+
generate_release_notes: true

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.zig-cache/
2+
zig-out/
3+
data/
4+
release/
5+
*.log

0 commit comments

Comments
 (0)