From dcf1ab905c438b7d172b22f3e189b54f5c604301 Mon Sep 17 00:00:00 2001 From: Gordon Bleux <33967640+UiP9AV6Y@users.noreply.github.com> Date: Wed, 7 Feb 2024 21:10:55 +0100 Subject: [PATCH] CI: add linter jobs to workflow --- .github/workflows/test.yml | 44 ++++++++++++++++++++++++++++++++------ .golangci.yml | 17 +++++++++++++++ 2 files changed, 55 insertions(+), 6 deletions(-) create mode 100644 .golangci.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e0ae78c..2210dd4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,19 +4,27 @@ name: Test on: push: - branches: [ $default-branch ] + branches: [ master ] + paths: + - '**/go.mod' + - '**/go.sum' + - '**/*.go' pull_request: - branches: [ $default-branch ] + branches: [ master ] + paths: + - '**/go.mod' + - '**/go.sum' + - '**/*.go' jobs: test-library: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version-file: 'go.mod' @@ -26,13 +34,37 @@ jobs: test-tools: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version-file: 'tools/go.mod' + - name: Build + run: cd tools ; go build -v ./... + - name: Test run: cd tools ; go test -v ./... + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + + - name: Lint (Library) + uses: golangci/golangci-lint-action@v3 + with: + version: v1.56.0 + + - name: Lint (Tools) + uses: golangci/golangci-lint-action@v3 + with: + version: v1.56.0 + working-directory: tools + diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..b79a2e4 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,17 @@ +--- + +run: + timeout: 5m + +linters: + disable-all: true + enable: + - gofmt + - govet + - ineffassign + - staticcheck + - typecheck + - unconvert + - unused + - whitespace +