From 46d41c0a4e37ed5f7d4f4299d38f22a7934cb5ad Mon Sep 17 00:00:00 2001 From: Mateus Oliveira Date: Fri, 1 Mar 2024 14:07:59 -0300 Subject: [PATCH] fixup! feat: add editorconfig Signed-off-by: Mateus Oliveira --- .editorconfig | 4 ++-- .github/workflows/ci.yml | 3 ++- Makefile | 30 +++++++++++++++--------------- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/.editorconfig b/.editorconfig index 8c680d3..c95923f 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,11 +10,11 @@ charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true -[Makefile] +[{*.go,go.mod,Makefile}] indent_style = unset [{*.{yaml,yml},PROJECT}] indent_size = 2 -[{*.go,go.mod,*.md,LICENSE}] +[{*.md,LICENSE}] indent_size = unset diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 617a0d1..1c6955f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,4 +62,5 @@ jobs: - name: Check if 'make manifests' was run run: make check-manifests - # TODO editorconfig + - name: Check all files format + run: make ec diff --git a/Makefile b/Makefile index 47bd400..356b022 100644 --- a/Makefile +++ b/Makefile @@ -204,6 +204,21 @@ endef ##@ oadp-nac specifics +EC ?= $(LOCALBIN)/ec-$(EC_VERSION) +EC_VERSION ?= 2.8.0 + +.PHONY: editorconfig +editorconfig: $(LOCALBIN) ## Download editorconfig locally if necessary. + @[ -f $(EC) ] || { \ + set -e ;\ + ec_binary=ec-$(shell go env GOOS)-$(shell go env GOARCH) ;\ + ec_tar=$(LOCALBIN)/$${ec_binary}.tar.gz ;\ + curl -sSLo $${ec_tar} https://github.com/editorconfig-checker/editorconfig-checker/releases/download/$(EC_VERSION)/$${ec_binary}.tar.gz ;\ + tar xzf $${ec_tar} ;\ + rm -rf $${ec_tar} ;\ + mv $(LOCALBIN)/$${ec_binary} $(EC) ;\ + } + .PHONY: ci ci: simulation-test lint docker-build hadolint check-generate check-manifests ec ## Run all checks run by the project continuous integration (CI) locally. @@ -223,21 +238,6 @@ check-generate: generate ## Check if 'make generate' was run. check-manifests: manifests ## Check if 'make manifests' was run. test -z "$(shell git status --short)" || (echo "run 'make manifests' to generate code" && exit 1) -EC ?= $(LOCALBIN)/ec-$(EC_VERSION) -EC_VERSION ?= 2.8.0 - -.PHONY: editorconfig -editorconfig: $(LOCALBIN) ## Download editorconfig locally if necessary. - @[ -f $(EC) ] || { \ - set -e ;\ - ec_binary=ec-$(shell go env GOOS)-$(shell go env GOARCH) ;\ - ec_tar=$(LOCALBIN)/$${ec_binary}.tar.gz ;\ - curl -sSLo $${ec_tar} https://github.com/editorconfig-checker/editorconfig-checker/releases/download/$(EC_VERSION)/$${ec_binary}.tar.gz ;\ - tar xzf $${ec_tar} ;\ - rm -rf $${ec_tar} ;\ - mv $(LOCALBIN)/$${ec_binary} $(EC) ;\ - } - .PHONY: ec ec: editorconfig ## Run file formatter checks against all project's files. $(EC)