Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI enforce code format #128

Merged
merged 4 commits into from Jul 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions .editorconfig
@@ -0,0 +1,4 @@
root = true
buro9 marked this conversation as resolved.
Show resolved Hide resolved

[*]
end_of_line = lf
1 change: 1 addition & 0 deletions .gitattributes
@@ -0,0 +1 @@
* text=auto eol=lf
buro9 marked this conversation as resolved.
Show resolved Hide resolved
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
buro9 marked this conversation as resolved.
Show resolved Hide resolved
- 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