Skip to content

Commit 4842a64

Browse files
authored
Add reset-ci target and automatic installation mode (#15)
1 parent 215ca01 commit 4842a64

File tree

3 files changed

+64
-3
lines changed

3 files changed

+64
-3
lines changed

README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
## Installation
44

5+
### Automatic
6+
7+
Run this command in your repo root.
8+
```
9+
curl https://raw.githubusercontent.com/bool64/dev/master/makefiles/base.mk -sLo Makefile && make reset-ci
10+
```
11+
12+
### Manual
13+
514
Add a test file (e.g. `dev_test.go`) to your module with unused import.
615

716
```go
@@ -13,7 +22,7 @@ import _ "github.com/bool64/dev" // Include development helpers to project.
1322
Add `Makefile` to your module with includes standard targets.
1423

1524
```Makefile
16-
GOLANGCI_LINT_VERSION := "v1.37.1" # Optional.
25+
#GOLANGCI_LINT_VERSION := "v1.37.1" # Optional configuration to pinpoint golangci-lint version.
1726

1827
# The head of Makefile determines location of dev-go to include standard targets.
1928
GO ?= go
@@ -24,7 +33,7 @@ ifneq "$(GOFLAGS)" ""
2433
endif
2534

2635
ifneq "$(wildcard ./vendor )" ""
27-
$(info >> using vendor)
36+
$(info Using vendor)
2837
modVendor = -mod=vendor
2938
ifeq (,$(findstring -mod,$(GOFLAGS)))
3039
export GOFLAGS := ${GOFLAGS} ${modVendor}
@@ -46,7 +55,7 @@ endif
4655
-include $(DEVGO_PATH)/makefiles/lint.mk
4756
-include $(DEVGO_PATH)/makefiles/test-unit.mk
4857
-include $(DEVGO_PATH)/makefiles/bench.mk
49-
-include $(DEVGO_PATH)/makefiles/github-actions.mk
58+
-include $(DEVGO_PATH)/makefiles/reset-ci.mk
5059

5160
# Add your custom targets here.
5261

makefiles/base.mk

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#GOLANGCI_LINT_VERSION := "v1.37.1" # Optional configuration to pinpoint golangci-lint version.
2+
3+
# The head of Makefile determines location of dev-go to include standard targets.
4+
GO ?= go
5+
export GO111MODULE = on
6+
7+
ifneq "$(GOFLAGS)" ""
8+
$(info GOFLAGS: ${GOFLAGS})
9+
endif
10+
11+
ifneq "$(wildcard ./vendor )" ""
12+
$(info Using vendor)
13+
modVendor = -mod=vendor
14+
ifeq (,$(findstring -mod,$(GOFLAGS)))
15+
export GOFLAGS := ${GOFLAGS} ${modVendor}
16+
endif
17+
ifneq "$(wildcard ./vendor/github.com/bool64/dev)" ""
18+
DEVGO_PATH := ./vendor/github.com/bool64/dev
19+
endif
20+
endif
21+
22+
ifeq ($(DEVGO_PATH),)
23+
DEVGO_PATH := $(shell GO111MODULE=on $(GO) list ${modVendor} -f '{{.Dir}}' -m github.com/bool64/dev)
24+
ifeq ($(DEVGO_PATH),)
25+
$(info Module github.com/bool64/dev not found, downloading.)
26+
DEVGO_PATH := $(shell export GO111MODULE=on && $(GO) mod tidy && $(GO) list -f '{{.Dir}}' -m github.com/bool64/dev)
27+
endif
28+
endif
29+
30+
-include $(DEVGO_PATH)/makefiles/main.mk
31+
-include $(DEVGO_PATH)/makefiles/lint.mk
32+
-include $(DEVGO_PATH)/makefiles/test-unit.mk
33+
-include $(DEVGO_PATH)/makefiles/bench.mk
34+
-include $(DEVGO_PATH)/makefiles/reset-ci.mk
35+
36+
# Add your custom targets here.
37+
38+
## Run tests
39+
test: test-unit

makefiles/reset-ci.mk

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
GO ?= go
2+
3+
-include $(DEVGO_PATH)/makefiles/github-actions.mk
4+
5+
## Reset CI files from bool64/dev templates, make sure to review changes before committing.
6+
reset-ci: github-actions
7+
@cp $(DEVGO_PATH)/makefiles/base.mk Makefile; git add Makefile
8+
@cp $(DEVGO_PATH)/scripts/.golangci.yml .golangci.yml; git add .golangci.yml
9+
@echo "package $(shell go list -f '{{.Name}}')_test" > dev_test.go
10+
@echo "" >> dev_test.go
11+
@echo 'import _ "github.com/bool64/dev" // Include CI/Dev scripts to project.' >> dev_test.go
12+
13+
.PHONY: reset-ci

0 commit comments

Comments
 (0)