Skip to content

Commit

Permalink
feat:Add CI
Browse files Browse the repository at this point in the history
Signed-off-by: Chen Kai <281165273grape@gmail.com>
  • Loading branch information
GrapeBaBa committed Dec 4, 2024
1 parent 0c1bd9e commit fc7c2a1
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Zig Test and Benchmark

on:
push:
branches: [main]
pull_request:
branches: [main]

env:
ZIG_VERSION: 0.14.0-dev.2079+ba2d00663

jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3

- name: Cache Zig
uses: actions/cache@v3
with:
path: ~/zig
key: ${{ runner.os }}-zig-${{ env.ZIG_VERSION }}

- name: Install Zig
if: steps.cache.outputs.cache-hit != 'true'
run: |
case ${{ runner.os }} in
Linux)
wget https://ziglang.org/builds/zig-linux-x86_64-${{ env.ZIG_VERSION }}.tar.xz
tar -xf zig-linux-x86_64-${{ env.ZIG_VERSION }}.tar.xz
mv zig-linux-x86_64-${{ env.ZIG_VERSION }} ~/zig
;;
macOS)
wget https://ziglang.org/builds/zig-macos-x86_64-${{ env.ZIG_VERSION }}.tar.xz
tar -xf zig-macos-x86_64-${{ env.ZIG_VERSION }}.tar.xz
mv zig-macos-x86_64-${{ env.ZIG_VERSION }} ~/zig
;;
Windows)
curl -L https://ziglang.org/builds/zig-windows-x86_64-${{ env.ZIG_VERSION }}.zip -o zig.zip
7z x zig.zip
mv zig-windows-x86_64-${{ env.ZIG_VERSION }} ~/zig
;;
esac
shell: bash

- name: Add Zig to PATH
run: echo "${HOME}/zig" >> $GITHUB_PATH
shell: bash

- name: Cache Zig build artifacts
uses: actions/cache@v3
with:
path: |
zig-cache
~/.cache/zig
key: ${{ runner.os }}-zig-build-${{ hashFiles('**/*.zig') }}
restore-keys: |
${{ runner.os }}-zig-build-
- name: Formatting
run: zig fmt --check --color on .

- name: Unit testing
run: zig build test --summary all

- name: Building
run: zig build -Doptimize=ReleaseFast

0 comments on commit fc7c2a1

Please sign in to comment.