forked from ntindall/sql-gen-doc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
88 lines (70 loc) · 2.25 KB
/
Makefile
File metadata and controls
88 lines (70 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
GO_SRC_FILES = $(shell find . -type f -name '*.go' | sed /vendor/d )
GO_SRC_PACKAGES =$(shell go list ./... | sed /vendor/d | sed /imports/d)
GOLINT_SRC = ./vendor/golang.org/x/lint/golint
GOOSE_SRC = ./vendor/github.com/pressly/goose/v3/cmd/goose
# vanity
GREEN = \033[0;32m
MAGENTA = \033[0;35m
RESET = \033[0;0m
# setup
.PHONY: setup
setup: vendor bin/golint bin/goose
.PHONY: clean
clean:
rm -rf logs/*
vendor: go.mod go.sum
@echo "$(GREEN)installing vendored dependencies...$(RESET)"
go mod download
go mod vendor -v
bin/golint: vendor
@echo "$(MAGENTA)building $(@)...$(RESET)"
@go build -o $(@) $(GOLINT_SRC)
bin/goose: vendor
@echo "$(MAGENTA)building $(@)...$(RESET)"
@go build -o $(@) $(GOOSE_SRC)
# build
.PHONY: build
build: bin/sql-gen-doc
bin/sql-gen-doc: $(GO_SRC_FILES)
@echo "$(MAGENTA)building $(@)...$(RESET)"
go build -o bin/sql-gen-doc ./main.go
# images
.PHONY: images
VERSION = 0.0.1
images: .circleci/images/primary/Dockerfile
# TODO: is there a way to get the last tag following semver?
@echo "$(MAGENTA)current version is $(VERSION), did you bump this value?\n\
press (enter to continue)?$(RESET)"
@read
@echo "$(MAGENTA)building a new base image with tag $(VERSION)...$(RESET)"
docker build -t pumpkinobsessed/sql-gen-doc:$(VERSION) $(^:%/Dockerfile=%)
docker login
docker tag pumpkinobsessed/sql-gen-doc:$(VERSION) pumpkinobsessed/sql-gen-doc:latest
docker push pumpkinobsessed/sql-gen-doc:$(VERSION)
docker push pumpkinobsessed/sql-gen-doc:latest
# testing / linting
.PHONY: docker-test
docker-test:
@docker-compose -f docker-compose.yml build test_container
@docker-compose -f docker-compose.yml run test_container make test integrate
.PHONY: integrate
integrate:
./scripts/integrate.sh
.PHONY: test
test: go-test go-lint build
.PHONY: go-test
go-test:
@echo "$(MAGENTA)running go tests...$(RESET)"
go test -v $(GO_SRC_PACKAGES)
.PHONY: go-lint
go-lint: bin/golint
@echo "$(MAGENTA)linting $(GO_SRC_PACKAGES)$(RESET)"
@bin/golint -set_exit_status $(GO_SRC_PACKAGES)
# releasing
.PHONY: release
release:
./scripts/release.sh
# migrations
.PHONY: migrate-up migrate-down migrate-reset
migrate-up migrate-down migrate-reset:
@./bin/goose -dir goose mysql "$(MYSQL_USER):$(MYSQL_PASSWORD)@(mysql:3306)/example" $(@:migrate-%=%)