From 043149bd43ec8d0c93cfc5584d6127aade35b9d1 Mon Sep 17 00:00:00 2001 From: viettranx Date: Thu, 5 Mar 2026 10:22:30 +0700 Subject: [PATCH] ci: add CI workflow, Makefile targets, and fix typing keepalive race (#41) - Add GitHub Actions CI with parallel Go (build/test -race/vet) and Web UI (pnpm build) jobs - Add Makefile targets: test, vet, check-web, setup, ci - Fix data race in typing keepalive: remove nil assignment after close(keepaliveDone) so the goroutine can safely read the channel without holding the mutex Co-Authored-By: Duc Nguyen Co-Authored-By: Claude Opus 4.6 --- .github/workflows/ci.yaml | 41 ++++++++++++++++++++++++++ Makefile | 17 ++++++++++- internal/channels/typing/controller.go | 1 - 3 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 00000000..8854b519 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,41 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +permissions: + contents: read + +jobs: + go: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + cache-dependency-path: go.sum + - run: go build ./... + - run: go test -race ./... + - run: go vet ./... + + web: + runs-on: ubuntu-latest + defaults: + run: + working-directory: ui/web + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v4 + with: + version: 10 + - uses: actions/setup-node@v4 + with: + node-version: 22 + cache: pnpm + cache-dependency-path: ui/web/pnpm-lock.yaml + - run: pnpm install --frozen-lockfile + - run: pnpm build diff --git a/Makefile b/Makefile index 82d4925b..2fb73a7f 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev) LDFLAGS = -s -w -X github.com/nextlevelbuilder/goclaw/cmd.Version=$(VERSION) BINARY = goclaw -.PHONY: build run clean version up down logs reset +.PHONY: build run clean version up down logs reset test vet check-web setup ci build: CGO_ENABLED=0 go build -ldflags="$(LDFLAGS)" -o $(BINARY) . @@ -30,3 +30,18 @@ logs: reset: $(COMPOSE) down -v $(COMPOSE) up -d --build + +test: + go test -race ./... + +vet: + go vet ./... + +check-web: + cd ui/web && pnpm install --frozen-lockfile && pnpm build + +setup: + go mod download + cd ui/web && pnpm install --frozen-lockfile + +ci: build test vet check-web diff --git a/internal/channels/typing/controller.go b/internal/channels/typing/controller.go index b0ae0cf6..a32d16c1 100644 --- a/internal/channels/typing/controller.go +++ b/internal/channels/typing/controller.go @@ -152,7 +152,6 @@ func (c *Controller) forceStop() { // Stop keepalive loop if c.keepaliveDone != nil { close(c.keepaliveDone) - c.keepaliveDone = nil } // Send stop signal