Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
BINARY := vote
GO := $(shell which go)
GOFMT := $(shell which gofmt)

# Source packages (mirrors .github/workflows/go.yaml)
PKGS := ./database/ ./logging/ ./sse/

ifeq ($(GO),)
$(error Go not found in PATH)
endif

.PHONY: build test vet lint tidy-check check coverage clean

build:
$(GO) build -o bin/$(BINARY) .

run:
docker-compose up

test:
$(GO) test -count=1 ./database

vet:
$(GO) vet $(PKGS)
$(GO) vet *.go

lint:
$(GOFMT) -w -s *.go logging sse database

tidy-check:
$(GO) mod tidy -diff

# Runs the same checks as CI
check: tidy-check vet test

coverage:
$(GO) test -coverprofile=coverage.out ./database
$(GO) tool cover -html=coverage.out

clean:
rm -rf bin/ coverage.out
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,18 @@ These will be checked by CI

```
# tidy dependencies
make tidy-check
go mod tidy

# format all code according to go standards
make lint
gofmt -w -s *.go logging sse database

# run tests (database is the first place we've defined tests)
go test ./database
make test

# run heuristic validation
go vet ./database/ ./logging/ ./sse/
go vet *.go
make vet
```

## To-Dos
Expand Down
Loading