Skip to content

Commit

Permalink
Define Makefile with golangci-lint
Browse files Browse the repository at this point in the history
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 <matthieu.morel35@gmail.com>
  • Loading branch information
mmorel-35 committed Sep 1, 2023
1 parent f6506e2 commit b105e4b
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include mk/lint.mk
6 changes: 6 additions & 0 deletions mk/dependencies/golangci.sh
Original file line number Diff line number Diff line change
@@ -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}"
14 changes: 14 additions & 0 deletions mk/lint.mk
Original file line number Diff line number Diff line change
@@ -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
16 changes: 0 additions & 16 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b105e4b

Please sign in to comment.