Skip to content

Commit

Permalink
Move build tools, use testify, refine make targets (#72)
Browse files Browse the repository at this point in the history
- Move build tools to build folder
- Use github.com/stretchr/testify
- Refine make targets
  • Loading branch information
pellared authored Oct 11, 2020
1 parent 299b85a commit 15f0a44
Show file tree
Hide file tree
Showing 9 changed files with 1,065 additions and 1,077 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ updates:
schedule:
interval: "weekly"

# Maintain dependencies for build tools
- package-ecosystem: "gomod"
directory: "/build"
schedule:
interval: "weekly"

# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
Expand Down
27 changes: 17 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
.DEFAULT_GOAL := help

.PHONY: dev
dev: ## dev build
dev: clean install generate build fmt lint-fast test mod-tidy build-snapshot

.PHONY: ci
ci: ## CI build
ci: install generate build lint test mod-tidy build-snapshot diff

.PHONY: dev
dev: ## fast build
dev: build fmt lint-fast test
ci: dev diff

.PHONY: clean
clean: ## go clean
clean: ## remove files created during build
$(call print-target)
go clean -r -i -cache -testcache -modcache
rm -rf dist
rm -f coverage.*

.PHONY: install
install: ## install build tools
$(call print-target)
go install mvdan.cc/gofumpt/gofumports
go install github.com/golangci/golangci-lint/cmd/golangci-lint
go install github.com/goreleaser/goreleaser
cd build && go install mvdan.cc/gofumpt/gofumports
cd build && go install github.com/golangci/golangci-lint/cmd/golangci-lint
cd build && go install github.com/goreleaser/goreleaser

.PHONY: generate
generate: ## go generate
Expand Down Expand Up @@ -55,6 +56,7 @@ test: ## go test with race detector and code covarage
mod-tidy: ## go mod tidy
$(call print-target)
go mod tidy
cd build && go mod tidy

.PHONY: build-snapshot
build-snapshot: ## goreleaser --snapshot --skip-publish --rm-dist
Expand All @@ -77,6 +79,11 @@ release: ## goreleaser --rm-dist
run: ## go run
@go run -race ./cmd/seed

.PHONY: go-clean
go-clean: ## go clean build, test and modules caches
$(call print-target)
go clean -r -i -cache -testcache -modcache

.PHONY: docker
docker: ## run in golang container, example: make docker run="make ci"
docker run --rm \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ It includes:
- dependency management using [Go Modules](https://github.com/golang/go/wiki/Modules),
- code formatting using [gofumpt](https://github.com/mvdan/gofumpt),
- linting with [golangci-lint](https://github.com/golangci/golangci-lint),
- unit testing with [race detector](https://blog.golang.org/race-detector) and [code covarage HTML report](https://blog.golang.org/cover),
- unit testing with [testify](https://github.com/stretchr/testify), [race detector](https://blog.golang.org/race-detector) and [code covarage HTML report](https://blog.golang.org/cover),
- releasing using [GoReleaser](https://github.com/goreleaser/goreleaser),
- dependencies scanning and updating thanks to [Dependabot](https://dependabot.com),
- [Visual Studio Code](https://code.visualstudio.com) configuration with [Go](https://code.visualstudio.com/docs/languages/go) and [Remote Container](https://code.visualstudio.com/docs/remote/containers) support.
Expand Down
9 changes: 9 additions & 0 deletions build/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module github.com/golang-templates/seed/build

go 1.15

require (
github.com/golangci/golangci-lint v1.31.0
github.com/goreleaser/goreleaser v0.144.0
mvdan.cc/gofumpt v0.0.0-20200709182408-4fd085cb6d5f
)
1,024 changes: 1,024 additions & 0 deletions build/go.sum

Large diffs are not rendered by default.

File renamed without changes.
8 changes: 5 additions & 3 deletions cmd/seed/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package main

import (
"testing"

"github.com/stretchr/testify/assert"
)

func Test_greet(t *testing.T) {
got := greet()

want := "Hi!"
if got := greet(); got != want {
t.Errorf("greet() = %v, want %v", got, want)
}
assert.Equal(t, want, got, "should properly greet")
}
6 changes: 1 addition & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,4 @@ module github.com/golang-templates/seed

go 1.15

require (
github.com/golangci/golangci-lint v1.31.0
github.com/goreleaser/goreleaser v0.144.0
mvdan.cc/gofumpt v0.0.0-20200709182408-4fd085cb6d5f
)
require github.com/stretchr/testify v1.6.1
1,060 changes: 2 additions & 1,058 deletions go.sum

Large diffs are not rendered by default.

0 comments on commit 15f0a44

Please sign in to comment.