From ca80fe14c7f8bdf1fe42b3354159c79a9f5453b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Garci=CC=81a=20Hierro?= Date: Fri, 7 Oct 2022 18:50:52 +0100 Subject: [PATCH] chore: add formatting and ci tools for go - Install golangci-lint and gci via check-setup - Add Makefile targets for golang-ci and golang-ci-fix. The former runs the same checks as CI while the latter tries to fix any errors (e.g. like incorrect formatting, not everything is automatically fixable) --- Makefile | 6 ++++++ scripts/check-setup.sh | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/Makefile b/Makefile index e61cf0435..6399c2e56 100644 --- a/Makefile +++ b/Makefile @@ -31,6 +31,12 @@ test: test-go test-ts format-templates: pnpx prettier --write pkg/templates/assets/templates --ignore-unknown +golang-ci: + golangci-lint run + +golang-ci-fix: + golangci-lint run --fix + install-proto: go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28.1 diff --git a/scripts/check-setup.sh b/scripts/check-setup.sh index b479a033f..d305a6a4b 100755 --- a/scripts/check-setup.sh +++ b/scripts/check-setup.sh @@ -8,3 +8,8 @@ if ! [ -x "$(command -v protoc)" ]; then echo 'curl -LO "https://github.com/protocolbuffers/protobuf/releases/download/v21.5/protoc-21.5-linux-x86_64.zip"' exit 1 fi + +if ! [ -x "$(command -v golangci-lint)" ]; then + echo "Installing golangci-lint" + go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest +fi