From 1f87946b15f651b299baace1c11dcfda22c78c10 Mon Sep 17 00:00:00 2001 From: Breezy <923803814@qq.com> Date: Wed, 19 Nov 2025 14:48:06 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=B7=BB=E5=8A=A0Go=20CI=E5=B7=A5?= =?UTF-8?q?=E4=BD=9C=E6=B5=81=E4=BB=A5=E6=94=AF=E6=8C=81=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E3=80=81=E6=B5=8B=E8=AF=95=E5=92=8C=E4=BB=A3=E7=A0=81=E6=A3=80?= =?UTF-8?q?=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/go.yml | 78 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 .github/workflows/go.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..f7a7d6d --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,78 @@ +name: Go CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build-test-lint: + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: "1.21" + + - name: Install dependencies + run: go mod download + + ##################################################### + # FORMAT CHECK (GOFMT) + ##################################################### + - name: Check code format (gofmt) + if: runner.os == 'Linux' + run: | + echo "Running gofmt..." + fmt_output=$(gofmt -l .) + if [ -n "$fmt_output" ]; then + echo "❌ Some files need formatting:" + echo "$fmt_output" + exit 1 + fi + echo "✓ gofmt passed" + + ##################################################### + # STATICCHECK + ##################################################### + - name: Install staticcheck + if: runner.os == 'Linux' + run: go install honnef.co/go/tools/cmd/staticcheck@latest + + - name: Run staticcheck + if: runner.os == 'Linux' + run: staticcheck ./... + + ##################################################### + # GOLANGCI-LINT + ##################################################### + - name: Install golangci-lint + if: runner.os == 'Linux' + run: | + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh \ + | sh -s -- -b $(go env GOPATH)/bin v1.57.2 + + - name: Lint + if: runner.os == 'Linux' + run: make lint + + ##################################################### + # VET + TEST + BUILD + ##################################################### + - name: Vet + run: make vet + + # - name: Test + # run: make test + + - name: Build + run: make build