Skip to content

Commit c53c481

Browse files
committed
build: migrate to tools
More decoupled and easier to maintain.
1 parent 4f6555c commit c53c481

File tree

28 files changed

+794
-70
lines changed

28 files changed

+794
-70
lines changed

.cloudbuild/review.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
steps:
2+
- name: gcr.io/einride/cloud-builder
3+
args: ["/cloud-builder/git-init.sh"]
4+
env:
5+
- REPO_NAME=$REPO_NAME
6+
- COMMIT_SHA=$COMMIT_SHA
7+
8+
- name: gcr.io/einride/cloud-builder
9+
args: ["make"]

.cloudbuild/rules.mk

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
gcp_project := einride
2+
github_org := einride
3+
repo_name := $(shell basename -s .git $(shell git config --get remote.origin.url))
4+
git_root := $(shell git rev-parse --show-toplevel)
5+
cloudbuild_root := $(shell realpath --relative-to $(git_root) $(dir $(lastword $(MAKEFILE_LIST))))
6+
7+
.PHONY: gcloud-builds-triggers-create
8+
gcloud-builds-triggers-create:
9+
gcloud beta builds triggers create github \
10+
--project=$(gcp_project) \
11+
--repo-owner=$(github_org) \
12+
--repo-name=$(repo_name) \
13+
--pull-request-pattern='.*' \
14+
--description='$(repo_name)-review' \
15+
--build-config='$(cloudbuild_root)/review.yaml'

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
.idea
2-
.gobincache
2+
tools/*/*/

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

.golangci.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
run:
2+
timeout: 5m
3+
skip-dirs:
4+
- gen
5+
6+
linters:
7+
enable-all: true
8+
disable:
9+
- dupl # allow duplication
10+
- funlen # allow long functions
11+
- gomnd # allow some magic numbers
12+
- wsl # unwanted amount of whitespace
13+
- godox # allow TODOs
14+
- interfacer # deprecated by the author for having too many false positives
15+
- gocognit # allow higher cognitive complexity
16+
- testpackage # unwanted convention
17+
- nestif # allow deep nesting
18+
- unparam # allow constant parameters
19+
- goerr113 # allow "dynamic" errors
20+
- exhaustive # TODO: fix and enable
21+
- gofumpt # TODO: enable when whitespace diff issue is resolved

Makefile

Lines changed: 11 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,28 @@
11
# all: run a complete build
22
all: \
33
markdown-lint \
4-
mocks \
4+
mockgen-generate \
55
go-lint \
66
go-review \
77
go-mod-tidy \
8-
git-verify-nodiff \
9-
git-verify-submodules
8+
git-verify-nodiff
109

11-
export GO111MODULE := on
12-
13-
# clean: remove all generated build files
14-
.PHONY: clean
15-
clean:
16-
rm -rf build
17-
18-
.PHONY: build
19-
build:
20-
@git submodule update --init --recursive $@
21-
22-
include build/rules.mk
23-
build/rules.mk: build
24-
@# included in submodule: build
25-
26-
# markdown-lint: lint Markdown files
27-
.PHONY: markdown-lint
28-
markdown-lint: $(PRETTIER)
29-
$(PRETTIER) --check **/*.md --parser markdown
10+
include tools/git-verify-nodiff/rules.mk
11+
include tools/golangci-lint/rules.mk
12+
include tools/prettier/rules.mk
13+
include tools/goreview/rules.mk
3014

3115
# go-mod-tidy: update Go module files
3216
.PHONY: go-mod-tidy
3317
go-mod-tidy:
3418
go mod tidy -v
3519

36-
# go-lint: lint Go files
37-
.PHONY: go-lint
38-
go-lint: $(GOLANGCI_LINT)
39-
# dupl: disabled due to similarities in tests
40-
# interfacer: deprecated
41-
# maligned: removed to not spend time on config aligment
42-
# funlen: tests with many testcases become too long, but should not be split.
43-
# unused: buggy with GolangCI-Lint 1.18.0
44-
# godox: we keep todos in the history
45-
# wsl: too strict
46-
$(GOLANGCI_LINT) run --enable-all --skip-dirs build --disable dupl,interfacer,maligned,funlen,unused,godox,wsl
47-
48-
# go-review: review Go files
49-
.PHONY: go-review
50-
go-review: $(GOREVIEW)
51-
$(GOREVIEW) -c 1 ./...
52-
53-
# mocks: generate Go mocks
54-
.PHONY: mocks
55-
mocks: pkg/mockclock/clock.go
20+
# mockgen-generate: generate Go mocks
21+
.PHONY: mockgen-generate
22+
mockgen-generate: pkg/mockclock/clock.go
5623

57-
pkg/mockclock/clock.go: pkg/clock/clock.go $(GOBIN)
58-
$(GOBIN) -m -run github.com/golang/mock/mockgen \
24+
pkg/mockclock/clock.go: pkg/clock/clock.go
25+
go run github.com/golang/mock/mockgen \
5926
-destination $@ \
6027
-package mockclock \
6128
github.com/einride/clock-go/pkg/clock Clock,Ticker

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# clock-go
2+
3+
Clocks and mocks.

build

Lines changed: 0 additions & 1 deletion
This file was deleted.

cloudbuild.yaml

Lines changed: 0 additions & 14 deletions
This file was deleted.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/einride/clock-go
22

3-
go 1.12
3+
go 1.13
44

55
require (
66
github.com/golang/mock v1.3.1

0 commit comments

Comments
 (0)