From b105e4b3c013b7c4eee93ec100d03d09a1e5eab3 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Thu, 20 Apr 2023 13:34:42 +0200 Subject: [PATCH] Define Makefile with golangci-lint As govet and gofmt are now handled by golangci-lint, there is no need to apply them here. Install golangci-lint Signed-off-by: Matthieu MOREL --- .github/workflows/test.yaml | 3 +++ Makefile | 1 + mk/dependencies/golangci.sh | 6 ++++++ mk/lint.mk | 14 ++++++++++++++ test.sh | 16 ---------------- 5 files changed, 24 insertions(+), 16 deletions(-) create mode 100644 Makefile create mode 100644 mk/dependencies/golangci.sh create mode 100644 mk/lint.mk diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index dd59bcda..a17161f1 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -21,6 +21,9 @@ jobs: with: format: auto - uses: golangci/golangci-lint-action@v3 + with: + args: --verbose + version: v1.51.2 build: name: Build all linux architectures needs: lint diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..efa2aa87 --- /dev/null +++ b/Makefile @@ -0,0 +1 @@ +include mk/lint.mk \ No newline at end of file diff --git a/mk/dependencies/golangci.sh b/mk/dependencies/golangci.sh new file mode 100644 index 00000000..f3079735 --- /dev/null +++ b/mk/dependencies/golangci.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -e + +GOLANGCI_LINT_VERSION="v1.51.2" + +go install "github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}" \ No newline at end of file diff --git a/mk/lint.mk b/mk/lint.mk new file mode 100644 index 00000000..e4a36d03 --- /dev/null +++ b/mk/lint.mk @@ -0,0 +1,14 @@ +.PHONY: lint +lint: golangci/install golangci/lint + +.PHONY: golangci/install +golangci/install: + ./mk/dependencies/golangci.sh + +.PHONY: golangci/lint +golangci/lint: + golangci-lint run --verbose + +.PHONY: golangci/fix +golangci/fix: + golangci-lint run --verbose --fix \ No newline at end of file diff --git a/test.sh b/test.sh index 34d8b66f..cf778c8f 100755 --- a/test.sh +++ b/test.sh @@ -20,22 +20,6 @@ else go test ${PKGS} fi -GO_FILES=$(find . -name '*.go' -type f -print) - -echo "Checking gofmt..." -fmtRes=$(gofmt -d -e -s ${GO_FILES}) -if [ -n "${fmtRes}" ]; then - echo -e "go fmt checking failed:\n${fmtRes}" - exit 255 -fi - -echo "Checking govet..." -vetRes=$(go vet ${PKGS}) -if [ -n "${vetRes}" ]; then - echo -e "go vet checking failed:\n${vetRes}" - exit 255 -fi - echo "Checking license header..." licRes=$( for file in $(find . -type f -iname '*.go'); do