Skip to content

Commit fc7c2a1

Browse files
committed
feat:Add CI
Signed-off-by: Chen Kai <281165273grape@gmail.com>
1 parent 0c1bd9e commit fc7c2a1

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

.github/workflows/check.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Zig Test and Benchmark
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
env:
10+
ZIG_VERSION: 0.14.0-dev.2079+ba2d00663
11+
12+
jobs:
13+
build:
14+
strategy:
15+
matrix:
16+
os: [ubuntu-latest, macos-latest, windows-latest]
17+
runs-on: ${{ matrix.os }}
18+
19+
steps:
20+
- uses: actions/checkout@v3
21+
22+
- name: Cache Zig
23+
uses: actions/cache@v3
24+
with:
25+
path: ~/zig
26+
key: ${{ runner.os }}-zig-${{ env.ZIG_VERSION }}
27+
28+
- name: Install Zig
29+
if: steps.cache.outputs.cache-hit != 'true'
30+
run: |
31+
case ${{ runner.os }} in
32+
Linux)
33+
wget https://ziglang.org/builds/zig-linux-x86_64-${{ env.ZIG_VERSION }}.tar.xz
34+
tar -xf zig-linux-x86_64-${{ env.ZIG_VERSION }}.tar.xz
35+
mv zig-linux-x86_64-${{ env.ZIG_VERSION }} ~/zig
36+
;;
37+
macOS)
38+
wget https://ziglang.org/builds/zig-macos-x86_64-${{ env.ZIG_VERSION }}.tar.xz
39+
tar -xf zig-macos-x86_64-${{ env.ZIG_VERSION }}.tar.xz
40+
mv zig-macos-x86_64-${{ env.ZIG_VERSION }} ~/zig
41+
;;
42+
Windows)
43+
curl -L https://ziglang.org/builds/zig-windows-x86_64-${{ env.ZIG_VERSION }}.zip -o zig.zip
44+
7z x zig.zip
45+
mv zig-windows-x86_64-${{ env.ZIG_VERSION }} ~/zig
46+
;;
47+
esac
48+
shell: bash
49+
50+
- name: Add Zig to PATH
51+
run: echo "${HOME}/zig" >> $GITHUB_PATH
52+
shell: bash
53+
54+
- name: Cache Zig build artifacts
55+
uses: actions/cache@v3
56+
with:
57+
path: |
58+
zig-cache
59+
~/.cache/zig
60+
key: ${{ runner.os }}-zig-build-${{ hashFiles('**/*.zig') }}
61+
restore-keys: |
62+
${{ runner.os }}-zig-build-
63+
64+
- name: Formatting
65+
run: zig fmt --check --color on .
66+
67+
- name: Unit testing
68+
run: zig build test --summary all
69+
70+
- name: Building
71+
run: zig build -Doptimize=ReleaseFast

0 commit comments

Comments
 (0)