From fde33fbb3057a27e4025e57258cd2b44df85bde9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Sun, 24 Jul 2022 19:44:33 +0800 Subject: [PATCH] Add lint workflow --- .github/workflows/debug.yml | 1 - .github/workflows/lint.yml | 48 +++++++++++++++++++++++++++++++++++++ .golangci.yml | 5 +++- 3 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml index 3efc1457..dcf59ad0 100644 --- a/.github/workflows/debug.yml +++ b/.github/workflows/debug.yml @@ -3,7 +3,6 @@ name: Debug build on: push: branches: - - main - dev paths-ignore: - '**.md' diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..7949d86b --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,48 @@ +name: Lint + +on: + push: + branches: + - dev + paths-ignore: + - '**.md' + - '.github/**' + - '!.github/workflows/debug.yml' + pull_request: + branches: + - dev + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Cancel previous + uses: styfle/cancel-workflow-action@0.7.0 + with: + access_token: ${{ github.token }} + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Get latest go version + id: version + run: | + echo ::set-output name=go_version::$(curl -s https://raw.githubusercontent.com/actions/go-versions/main/versions-manifest.json | grep -oE '"version": "[0-9]{1}.[0-9]{1,}(.[0-9]{1,})?"' | head -1 | cut -d':' -f2 | sed 's/ //g; s/"//g') + - name: Setup Go + uses: actions/setup-go@v2 + with: + go-version: ${{ steps.version.outputs.go_version }} + - name: Cache go module + uses: actions/cache@v2 + with: + path: | + ~/go/pkg/mod + key: go-${{ hashFiles('**/go.sum') }} + - name: Get dependencies + run: | + go mod download -x + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + version: latest \ No newline at end of file diff --git a/.golangci.yml b/.golangci.yml index 049c3704..db02a3c9 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -3,10 +3,13 @@ linters: enable: - gofumpt - govet - - gci +# - gci - staticcheck - paralleltest +issues: + fix: true + linters-settings: gci: sections: