Skip to content

Commit

Permalink
Merge pull request #128 from 6543-forks/ci-enforce-code-format
Browse files Browse the repository at this point in the history
CI enforce code format
  • Loading branch information
buro9 committed Jul 17, 2021
2 parents 1a86fcd + 7e9370a commit cada0f0
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .editorconfig
@@ -0,0 +1,4 @@
root = true

[*]
end_of_line = lf
1 change: 1 addition & 0 deletions .gitattributes
@@ -0,0 +1 @@
* text=auto eol=lf
12 changes: 12 additions & 0 deletions .github/workflows/test.yml
Expand Up @@ -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
8 changes: 7 additions & 1 deletion Makefile
Expand Up @@ -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)
Expand All @@ -11,6 +12,8 @@
#
# install: Builds, tests and installs the code locally

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
Expand All @@ -19,7 +22,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
Expand Down

0 comments on commit cada0f0

Please sign in to comment.