From a61ac6168a0dfb9aed20fcbcf6a46bd908a22081 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Mon, 5 Oct 2026 12:16:34 -0400 Subject: [PATCH] CI: format, cross-platform vet, staticcheck, tests, race, examples --- .github/workflows/ci.yml | 59 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..93a881a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,59 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + +permissions: + contents: read + +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +jobs: + test: + name: ${{ matrix.name }} + runs-on: ${{ matrix.os }} + timeout-minutes: 30 + strategy: + fail-fast: false + matrix: + include: + - { name: macOS, os: macos-latest, skip: "" } + # Snapshot goldens exist only for darwin; see docs/compat.md. + - { name: Linux, os: ubuntu-latest, skip: "-skip Snapshot" } + - { name: Windows, os: windows-latest, skip: "-skip Snapshot" } + steps: + - uses: actions/checkout@v7 + - uses: actions/setup-go@v6 + with: + go-version-file: go.mod + - name: Format + if: runner.os == 'Linux' + run: test -z "$(gofmt -l .)" || { gofmt -l .; exit 1; } + - name: Build and vet every platform + if: runner.os == 'Linux' + run: | + for os in darwin linux windows; do + GOOS=$os go build ./... + GOOS=$os go vet ./... + done + - name: Staticcheck + if: runner.os == 'Linux' + run: go run honnef.co/go/tools/cmd/staticcheck@v0.8.1 ./... + - name: Test + run: go test ${{ matrix.skip }} ./... + - name: Race + if: runner.os != 'Windows' + run: go test -race ${{ matrix.skip }} ./... + - name: Examples compile + run: go build ./examples/... + - name: Upload snapshot diffs + if: failure() + uses: actions/upload-artifact@v5 + with: + name: snapshot-diffs-${{ matrix.name }} + path: testdata/snapshots/**/*.got.png + if-no-files-found: ignore