Skip to content

Commit

Permalink
add ci
Browse files Browse the repository at this point in the history
  • Loading branch information
krichprollsch committed Nov 14, 2024
1 parent 12fc98c commit 82ef6b3
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/zig-fmt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: zig-fmt

env:
ZIG_VERSION: 0.13.0

on:
pull_request:
branches:
- main
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
zig-fmt:
name: zig fmt
runs-on: ubuntu-latest

steps:
- uses: mlugg/setup-zig@v1
with:
version: ${{ env.ZIG_VERSION }}

- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Run zig fmt
id: fmt
run: |
zig fmt --check ./*.zig ./**/*.zig 2> zig-fmt.err > zig-fmt.err2 || echo "Failed"
delimiter="$(openssl rand -hex 8)"
echo "zig_fmt_errs<<${delimiter}" >> "${GITHUB_OUTPUT}"
if [ -s zig-fmt.err ]; then
echo "// The following errors occurred:" >> "${GITHUB_OUTPUT}"
cat zig-fmt.err >> "${GITHUB_OUTPUT}"
fi
if [ -s zig-fmt.err2 ]; then
echo "// The following files were not formatted:" >> "${GITHUB_OUTPUT}"
cat zig-fmt.err2 >> "${GITHUB_OUTPUT}"
fi
echo "${delimiter}" >> "${GITHUB_OUTPUT}"
- name: Fail the job
if: steps.fmt.outputs.zig_fmt_errs != ''
run: exit 1
36 changes: 36 additions & 0 deletions .github/workflows/zig-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: zig-test

env:
ZIG_VERSION: 0.13.0

on:
push:
branches:
- main
paths:
- "src/**/*.zig"
- "src/*.zig"
pull_request:
branches:
- main
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
zig-test:
name: zig test
runs-on: ubuntu-latest

steps:
- uses: mlugg/setup-zig@v1
with:
version: ${{ env.ZIG_VERSION }}

- uses: actions/checkout@v4
with:
fetch-depth: 0

- run: zig test constants.zig
- run: zig test fifo.zig
- run: zig test io.zig
- run: zig test time.zig

0 comments on commit 82ef6b3

Please sign in to comment.