Skip to content

Commit 15f0a44

Browse files
authored
Move build tools, use testify, refine make targets (#72)
- Move build tools to build folder - Use github.com/stretchr/testify - Refine make targets
1 parent 299b85a commit 15f0a44

File tree

9 files changed

+1065
-1077
lines changed

9 files changed

+1065
-1077
lines changed

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ updates:
1111
schedule:
1212
interval: "weekly"
1313

14+
# Maintain dependencies for build tools
15+
- package-ecosystem: "gomod"
16+
directory: "/build"
17+
schedule:
18+
interval: "weekly"
19+
1420
# Maintain dependencies for GitHub Actions
1521
- package-ecosystem: "github-actions"
1622
directory: "/"

Makefile

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
.DEFAULT_GOAL := help
22

3+
.PHONY: dev
4+
dev: ## dev build
5+
dev: clean install generate build fmt lint-fast test mod-tidy build-snapshot
6+
37
.PHONY: ci
48
ci: ## CI build
5-
ci: install generate build lint test mod-tidy build-snapshot diff
6-
7-
.PHONY: dev
8-
dev: ## fast build
9-
dev: build fmt lint-fast test
9+
ci: dev diff
1010

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

1617
.PHONY: install
1718
install: ## install build tools
1819
$(call print-target)
19-
go install mvdan.cc/gofumpt/gofumports
20-
go install github.com/golangci/golangci-lint/cmd/golangci-lint
21-
go install github.com/goreleaser/goreleaser
20+
cd build && go install mvdan.cc/gofumpt/gofumports
21+
cd build && go install github.com/golangci/golangci-lint/cmd/golangci-lint
22+
cd build && go install github.com/goreleaser/goreleaser
2223

2324
.PHONY: generate
2425
generate: ## go generate
@@ -55,6 +56,7 @@ test: ## go test with race detector and code covarage
5556
mod-tidy: ## go mod tidy
5657
$(call print-target)
5758
go mod tidy
59+
cd build && go mod tidy
5860

5961
.PHONY: build-snapshot
6062
build-snapshot: ## goreleaser --snapshot --skip-publish --rm-dist
@@ -77,6 +79,11 @@ release: ## goreleaser --rm-dist
7779
run: ## go run
7880
@go run -race ./cmd/seed
7981

82+
.PHONY: go-clean
83+
go-clean: ## go clean build, test and modules caches
84+
$(call print-target)
85+
go clean -r -i -cache -testcache -modcache
86+
8087
.PHONY: docker
8188
docker: ## run in golang container, example: make docker run="make ci"
8289
docker run --rm \

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ It includes:
1818
- dependency management using [Go Modules](https://github.com/golang/go/wiki/Modules),
1919
- code formatting using [gofumpt](https://github.com/mvdan/gofumpt),
2020
- linting with [golangci-lint](https://github.com/golangci/golangci-lint),
21-
- unit testing with [race detector](https://blog.golang.org/race-detector) and [code covarage HTML report](https://blog.golang.org/cover),
21+
- 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),
2222
- releasing using [GoReleaser](https://github.com/goreleaser/goreleaser),
2323
- dependencies scanning and updating thanks to [Dependabot](https://dependabot.com),
2424
- [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.

build/go.mod

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module github.com/golang-templates/seed/build
2+
3+
go 1.15
4+
5+
require (
6+
github.com/golangci/golangci-lint v1.31.0
7+
github.com/goreleaser/goreleaser v0.144.0
8+
mvdan.cc/gofumpt v0.0.0-20200709182408-4fd085cb6d5f
9+
)

build/go.sum

Lines changed: 1024 additions & 0 deletions
Large diffs are not rendered by default.
File renamed without changes.

cmd/seed/main_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ package main
22

33
import (
44
"testing"
5+
6+
"github.com/stretchr/testify/assert"
57
)
68

79
func Test_greet(t *testing.T) {
10+
got := greet()
11+
812
want := "Hi!"
9-
if got := greet(); got != want {
10-
t.Errorf("greet() = %v, want %v", got, want)
11-
}
13+
assert.Equal(t, want, got, "should properly greet")
1214
}

go.mod

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,4 @@ module github.com/golang-templates/seed
22

33
go 1.15
44

5-
require (
6-
github.com/golangci/golangci-lint v1.31.0
7-
github.com/goreleaser/goreleaser v0.144.0
8-
mvdan.cc/gofumpt v0.0.0-20200709182408-4fd085cb6d5f
9-
)
5+
require github.com/stretchr/testify v1.6.1

go.sum

Lines changed: 2 additions & 1058 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)