Files
WeKnora/.github/workflows/cli.yml
T
NianJiu 33138d3532 fix(ci,smoke): prevent lite_smoke cleanup deadlock/race and close sibling CI gates
Why:
1. In tests/lite_smoke/lite_e2e_test.go, exited was a 1-buffered channel sent
   once without closing: if waitForHealth consumed <-exited on an early server
   crash, t.Cleanup blocked forever on <-exited; serverLogs also used an
   unsynchronized bytes.Buffer read concurrently on startup/shutdown timeouts
   under -race, and subprocess/client HTTP calls could inherit developer
   ENV_FILE, REDIS_ADDR, or proxy settings.
2. frontend/src/utils/catalogToolDisplay.test.ts asserts UI locale coverage
   against docs/swagger.json, but frontend.yml did not trigger on swagger.json
   changes.
3. pre-push and cli.yml enforced gofmt on client/ and root Go files, but
   skipped gofmt checks on changed cli/**/*.go files, and cli-e2e.yml omitted
   client/go.sum from its Go cache key.

What:
- Replace single-read exited channel and raw bytes.Buffer in lite_e2e_test.go
  with a closed done channel + mutex-guarded syncBuffer, and isolate subprocess
  ENV_FILE/REDIS_ADDR/NO_PROXY and loopback HTTP transport from local proxies.
- Add docs/swagger.json to frontend.yml push and pull_request path triggers.
- Check gofmt on all changed Go files in pre-push and changed cli Go files in
  cli.yml, and add client/go.sum to cli-e2e.yml cache-dependency-path.
2026-11-18 16:46:32 +08:00

106 lines
3.3 KiB
YAML

name: CLI
# Builds and tests the cli/ Go module on every push / PR that touches it.
# Foundation PR (PR-1) gates: 3-platform `go build` + `go test ./...` green.
on:
push:
branches: [main]
paths:
- 'cli/**'
- 'client/**'
- '.github/workflows/cli.yml'
pull_request:
paths:
- 'cli/**'
- 'client/**'
- '.github/workflows/cli.yml'
workflow_dispatch:
defaults:
run:
working-directory: cli
# Windows default is PowerShell, which tokenizes `go test -coverprofile=coverage.out ./...`
# in a way that detaches `.out` as a separate positional package arg.
# Force bash everywhere so the run lines parse identically across platforms
# (Git Bash is preinstalled on windows-latest runners).
shell: bash
permissions:
contents: read
jobs:
test:
name: test (${{ matrix.os }} / go ${{ matrix.go }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
go: ['1.26']
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/setup-go@v6
with:
go-version: ${{ matrix.go }}
cache-dependency-path: |
cli/go.sum
client/go.sum
- name: Check client and changed cli Go formatting
if: runner.os == 'Linux'
working-directory: .
env:
BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.before }}
run: |
unformatted_client=$(cd client && gofmt -l .)
if [ -n "$unformatted_client" ]; then
echo "The following client Go files are not gofmt-formatted:"
echo "$unformatted_client"
exit 1
fi
if [ "${{ github.event_name }}" = "pull_request" ]; then
diff_range="${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }}"
elif [ "${{ github.event_name }}" = "push" ]; then
base="$BASE_SHA"
if [ -z "$base" ] || [[ "$base" =~ ^0+$ ]]; then
base=$(git rev-parse HEAD^)
fi
diff_range="$base..$GITHUB_SHA"
else
diff_range=""
fi
if [ -n "$diff_range" ]; then
unformatted_cli=$(
git diff --name-only --diff-filter=ACMR -z "$diff_range" -- ':(glob)cli/**/*.go' |
xargs -0 -r gofmt -l
)
if [ -n "$unformatted_cli" ]; then
echo "The following cli Go files are not gofmt-formatted:"
echo "$unformatted_cli"
exit 1
fi
fi
- name: client go build, vet, and test
working-directory: client
run: |
go build ./...
go vet ./...
go test -race ./...
- name: go build
run: go build ./...
- name: go test
run: go test -race -coverprofile=coverage.out ./...
- name: go vet
run: go vet ./...
- name: Check agent-facing doc wire vocabulary
if: runner.os == 'Linux'
run: scripts/check-skill-wire-vocab.sh
- name: Check for committed credentials in docs
if: runner.os == 'Linux'
run: scripts/check-secret-tokens.sh
- name: coverage report
if: matrix.os == 'ubuntu-latest'
run: go tool cover -func=coverage.out