diff --git a/.github/workflows/zig-fmt.yml b/.github/workflows/zig-fmt.yml new file mode 100644 index 0000000..0a94a2a --- /dev/null +++ b/.github/workflows/zig-fmt.yml @@ -0,0 +1,48 @@ +name: zig-fmt + +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 + container: + image: ghcr.io/browsercore/zig:0.11.0 + credentials: + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + outputs: + zig_fmt_errs: ${{ steps.fmt.outputs.zig_fmt_errs }} + + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + 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 diff --git a/.github/workflows/zig-test.yml b/.github/workflows/zig-test.yml new file mode 100644 index 0000000..432b1c5 --- /dev/null +++ b/.github/workflows/zig-test.yml @@ -0,0 +1,35 @@ +name: zig-test + +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 + container: + image: ghcr.io/browsercore/zig:0.11.0 + credentials: + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + fetch-depth: 0 + + - run: zig test constants.zig + - run: zig test fifo.zig + - run: zig test io.zig + - run: zig test time.zig