Skip to content
This repository was archived by the owner on Mar 9, 2025. It is now read-only.

zig fmt #3

Open
wants to merge 2 commits into
base: lightpanda
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/zig-fmt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: zig-fmt

env:
ZIG_VERSION: 0.13.0

on:
pull_request:

# By default GH trigger on types opened, synchronize and reopened.
# see https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request
# Since we skip the job when the PR is in draft state, we want to force CI
# running when the PR is marked ready_for_review w/o other change.
# see https://github.com/orgs/community/discussions/25722#discussioncomment-3248917
types: [opened, synchronize, reopened, ready_for_review]

paths:
- ".github/**"
- "build.zig"
- "src/**/*.zig"
- "src/*.zig"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
zig-fmt:
name: zig fmt

# Don't run the CI with draft PR.
if: github.event.pull_request.draft == false

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
18 changes: 9 additions & 9 deletions build.zig.zon
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
.{
.name = "websocket",
.version = "0.1.0",
.dependencies = .{},
.paths = .{
"readme.md",
"build.zig",
"build.zig.zon",
"src",
},
.name = "websocket",
.version = "0.1.0",
.dependencies = .{},
.paths = .{
"readme.md",
"build.zig",
"build.zig.zon",
"src",
},
}
2 changes: 1 addition & 1 deletion src/server/server.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1712,7 +1712,7 @@ test "tests:beforeAll" {
.port = 9292,
.address = "127.0.0.1",
});
test_thread = try test_server.listenInNewThread(.{.ws_host = "127.0.0.1", .ws_port = 9292});
test_thread = try test_server.listenInNewThread(.{ .ws_host = "127.0.0.1", .ws_port = 9292 });
}

test "tests:afterAll" {
Expand Down
12 changes: 5 additions & 7 deletions support/autobahn/client/build.zig.zon
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
.{
.name = "autobahn_test_client",
.paths = .{""},
.version = "0.0.0",
.dependencies = .{
.websocket = .{
.path = "../../../"
.name = "autobahn_test_client",
.paths = .{""},
.version = "0.0.0",
.dependencies = .{
.websocket = .{ .path = "../../../" },
},
},
}
12 changes: 6 additions & 6 deletions support/autobahn/server/build.zig.zon
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.{
.name = "autobahn_test_server",
.paths = .{""},
.version = "0.0.0",
.dependencies = .{
.websocket = .{.path = "../../../"},
},
.name = "autobahn_test_server",
.paths = .{""},
.version = "0.0.0",
.dependencies = .{
.websocket = .{ .path = "../../../" },
},
}
2 changes: 1 addition & 1 deletion support/autobahn/server/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const Handler = struct {
if (std.unicode.utf8ValidateSlice(data)) {
try self.conn.writeText(data);
} else {
self.conn.close(.{.code = 1007}) catch {};
self.conn.close(.{ .code = 1007 }) catch {};
}
},
}
Expand Down
Loading
Loading