From 1b5510c389ce48c2a0334951919af45b04a7c296 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Thu, 8 Jul 2021 19:29:14 +0200 Subject: [PATCH 1/4] add "fmt-check" make target --- Makefile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b5903a2..a82664d 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,7 @@ # all: Builds the code locally after testing # # fmt: Formats the source files +# fmt-check: Check if the source files are formated # build: Builds the code locally # vet: Vets the code # lint: Runs lint over the code (you do not need to fix everything) @@ -11,6 +12,9 @@ # # install: Builds, tests and installs the code locally +GO_PACKAGES ?= $(shell go list ./... | grep -v /vendor/) +GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./.git/*") + .PHONY: all fmt build vet lint test cover install # The first target is always the default action if `make` is called without @@ -19,7 +23,10 @@ all: fmt vet test install fmt: - @gofmt -s -w ./$* + @gofmt -s -w ${GOFILES_NOVENDOR} + +fmt-check: + @([ -z "$(shell gofmt -d $(GOFILES_NOVENDOR) | head)" ]) || (echo "Source is unformatted"; exit 1) build: @go build From 9926455864b8aa25f5ccdd4692e4283af0483b35 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Thu, 8 Jul 2021 19:31:15 +0200 Subject: [PATCH 2/4] Add "Check Code Formation" step to CI --- .github/workflows/test.yml | 12 ++++++++++++ Makefile | 1 - 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 06be6e3..8224e34 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,3 +17,15 @@ jobs: uses: actions/checkout@v2 - name: Test run: go test -v ./... + + check: + runs-on: ubuntu-latest + steps: + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: 1.16.x + - name: Checkout code + uses: actions/checkout@v2 + - name: Check Code Formation + run: make fmt-check diff --git a/Makefile b/Makefile index a82664d..dcd042a 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,6 @@ # # install: Builds, tests and installs the code locally -GO_PACKAGES ?= $(shell go list ./... | grep -v /vendor/) GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./.git/*") .PHONY: all fmt build vet lint test cover install From be04ac979ee7175d8248020e9faa9410343dc6a5 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Fri, 9 Jul 2021 03:32:25 +0200 Subject: [PATCH 3/4] enforce "lf" line ending --- .editorconfig | 4 ++++ .gitattributes | 1 + 2 files changed, 5 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitattributes diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..006bc2f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,4 @@ +root = true + +[*] +end_of_line = lf diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..6313b56 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto eol=lf From 7e9370ab20d81df22804c9007aeff34a22d6f427 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Sat, 17 Jul 2021 18:32:42 +0200 Subject: [PATCH 4/4] CI.restart()