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 1/2] 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 From ea51d3ec5e1604d2eb2b67a941e59fe424d05386 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Garci=CC=81a=20Hierro?= Date: Fri, 7 Oct 2022 20:59:55 +0100 Subject: [PATCH 2/2] fix: move commands with side-effects to setup-dev Add also a Makefile target to run it --- Makefile | 3 +++ scripts/check-setup.sh | 5 ----- scripts/setup-dev.sh | 8 ++++++++ 3 files changed, 11 insertions(+), 5 deletions(-) create mode 100755 scripts/setup-dev.sh diff --git a/Makefile b/Makefile index 6399c2e56..b606ea436 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,9 @@ engine-dev: codegen check-setup: $(shell ./scripts/check-setup.sh) +setup-dev: + ./scripts/setup-dev.sh + bootstrap-minio: ./scripts/minio-setup.sh diff --git a/scripts/check-setup.sh b/scripts/check-setup.sh index d305a6a4b..b479a033f 100755 --- a/scripts/check-setup.sh +++ b/scripts/check-setup.sh @@ -8,8 +8,3 @@ 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 diff --git a/scripts/setup-dev.sh b/scripts/setup-dev.sh new file mode 100755 index 000000000..20950b514 --- /dev/null +++ b/scripts/setup-dev.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +set -e + +if ! [ -x "$(command -v golangci-lint)" ]; then + echo "Installing golangci-lint" + go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest +fi