From 3379ebf34a56766f6eeb799c5503883f1bf59c77 Mon Sep 17 00:00:00 2001 From: fioncat Date: Thu, 13 Jul 2023 11:21:00 +0800 Subject: [PATCH] chore: add check-go workflow --- .github/workflows/build-go.yml | 10 ++-------- .github/workflows/check-go.yml | 33 +++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 2 +- Makefile | 3 --- 4 files changed, 36 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/check-go.yml diff --git a/.github/workflows/build-go.yml b/.github/workflows/build-go.yml index a0b00a6..fe3d900 100644 --- a/.github/workflows/build-go.yml +++ b/.github/workflows/build-go.yml @@ -1,4 +1,4 @@ -name: Build Go binary +name: Build Go Binary on: push: @@ -18,13 +18,7 @@ jobs: - name: Set up go uses: actions/setup-go@v3 with: - go-version: 1.20.4 - - - name: Install goimports - run: go install golang.org/x/tools/cmd/goimports@latest - - - name: Check go format - run: bash scripts/check-fmt.sh + go-version: 1.20.5 - name: Build run: go build ./... diff --git a/.github/workflows/check-go.yml b/.github/workflows/check-go.yml new file mode 100644 index 0000000..fb67a12 --- /dev/null +++ b/.github/workflows/check-go.yml @@ -0,0 +1,33 @@ +name: Check Go Code + +on: + push: + branches: + - "main" + pull_request: + branches: + - "main" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up go + uses: actions/setup-go@v3 + with: + go-version: 1.20.5 + + - name: Install goimports + run: go install golang.org/x/tools/cmd/goimports@latest + + - name: Check go format + run: bash scripts/check-fmt.sh + + - name: Install check tools + run: make install-check + + - name: Check go code + run: make check diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 21e7ffe..c9718fd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: release +name: Create a Release on: push: diff --git a/Makefile b/Makefile index c24464c..782b3e5 100644 --- a/Makefile +++ b/Makefile @@ -72,7 +72,6 @@ check-fmt: .PHONY: install-check install-check: - @go install github.com/fzipp/gocyclo/cmd/gocyclo@latest @go install github.com/client9/misspell/cmd/misspell@latest @go install github.com/gordonklaus/ineffassign@latest @go install golang.org/x/tools/cmd/goimports@latest @@ -83,8 +82,6 @@ check: @ineffassign ./... @echo "==> check spell" @find . -type f -name '*.go' | xargs misspell -error - @echo "==> check gocyclo" - @gocyclo -over 70 . @echo "==> go vet" @go vet ./...