forked from moov-io/watchman
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
135 lines (108 loc) · 4.57 KB
/
makefile
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
PLATFORM=$(shell uname -s | tr '[:upper:]' '[:lower:]')
VERSION := $(shell grep -Eo '(v[0-9]+[\.][0-9]+[\.][0-9]+(-[a-zA-Z0-9]*)?)' version.go)
.PHONY: run build build-server build-examples docker release check test
run:
CGO_ENABLED=1 go run github.com/moov-io/watchman/cmd/server
build: build-server build-batchsearch build-watchmantest build-examples
ifeq ($(OS),Windows_NT)
@echo "Skipping webui build on Windows."
else
cd webui/ && npm install --legacy-peer-deps && npm run build && cd ../
endif
build-server:
CGO_ENABLED=1 go build -o ./bin/server github.com/moov-io/watchman/cmd/server
build-batchsearch:
CGO_ENABLED=0 go build -o ./bin/batchsearch github.com/moov-io/watchman/cmd/batchsearch
build-watchmantest:
CGO_ENABLED=0 go build -o ./bin/watchmantest github.com/moov-io/watchman/cmd/watchmantest
build-examples: build-webhook-example
build-webhook-example:
CGO_ENABLED=0 go build -o ./bin/webhook-example github.com/moov-io/watchman/examples/webhook
.PHONY: check
check:
ifeq ($(OS),Windows_NT)
@echo "Skipping checks on Windows, currently unsupported."
else
@wget -O lint-project.sh https://raw.githubusercontent.com/moov-io/infra/master/go/lint-project.sh
@chmod +x ./lint-project.sh
STRICT_GOLANGCI_LINTERS=no GOLANGCI_LINTERS=gocheckcompilerdirectives,mirror,tenv ./lint-project.sh
endif
.PHONY: admin
admin:
@rm -rf ./admin
docker run --rm \
-u $(USERID):$(GROUPID) \
-v ${PWD}:/local openapitools/openapi-generator-cli:v4.3.1 batch -- /local/.openapi-generator/admin-generator-config.yml
rm -f ./admin/go.mod ./admin/go.sum ./admin/.travis.yml
gofmt -w ./admin/
go build github.com/moov-io/watchman/admin
.PHONY: client
client:
@rm -rf ./client
docker run --rm \
-u $(USERID):$(GROUPID) \
-v ${PWD}:/local openapitools/openapi-generator-cli:v4.3.1 batch -- /local/.openapi-generator/client-generator-config.yml
rm -f ./client/go.mod ./client/go.sum ./client/.travis.yml
gofmt -w ./client/
go build github.com/moov-io/watchman/client
.PHONY: clean
clean:
ifeq ($(OS),Windows_NT)
@echo "Skipping cleanup on Windows, currently unsupported."
else
@rm -rf ./bin/ cover.out coverage.txt lint-project.sh misspell* staticcheck* openapi-generator-cli-*.jar
endif
dist: clean build
ifeq ($(OS),Windows_NT)
CGO_ENABLED=1 GOOS=windows go build -o bin/watchman.exe github.com/moov-io/watchman/cmd/server
else
CGO_ENABLED=1 GOOS=$(PLATFORM) go build -o bin/watchman-$(PLATFORM)-amd64 github.com/moov-io/watchman/cmd/server
endif
docker: clean docker-hub docker-openshift docker-static docker-watchmantest docker-webhook
docker-hub:
docker build --pull -t moov/watchman:$(VERSION) -f Dockerfile .
docker tag moov/watchman:$(VERSION) moov/watchman:latest
docker-openshift:
docker build --pull -t quay.io/moov/watchman:$(VERSION) -f Dockerfile-openshift --build-arg VERSION=$(VERSION) .
docker tag quay.io/moov/watchman:$(VERSION) quay.io/moov/watchman:latest
docker-static:
docker build --pull -t moov/watchman:static -f Dockerfile-static .
docker-watchmantest:
docker build --pull -t moov/watchmantest:$(VERSION) -f ./cmd/watchmantest/Dockerfile .
docker tag moov/watchmantest:$(VERSION) moov/watchmantest:latest
docker-webhook:
docker build --pull -t moov/watchman-webhook-example:$(VERSION) -f ./examples/webhook/Dockerfile .
docker tag moov/watchman-webhook-example:$(VERSION) moov/watchman-webhook-example:latest
release: docker AUTHORS
go vet ./...
go test -coverprofile=cover-$(VERSION).out ./...
git tag -f $(VERSION)
release-push:
docker push moov/watchman:$(VERSION)
docker push moov/watchman:latest
docker push moov/watchman:static
docker push moov/watchmantest:$(VERSION)
docker push moov/watchman-webhook-example:$(VERSION)
quay-push:
docker push quay.io/moov/watchman:$(VERSION)
docker push quay.io/moov/watchman:latest
.PHONY: cover-test cover-web
cover-test:
go test -coverprofile=cover.out ./...
cover-web:
go tool cover -html=cover.out
clean-integration:
docker-compose kill && docker-compose rm -v -f
# TODO: this test is working but due to a default timeout on the admin server we get an empty reply
# for now this shouldn't hold up out CI pipeline
test-integration: clean-integration
docker compose up -d
sleep 30
time curl -v --max-time 30 http://localhost:9094/data/refresh # hangs until download and parsing completes
./bin/batchsearch -local -threshold 0.95
# From https://github.com/genuinetools/img
.PHONY: AUTHORS
AUTHORS:
@$(file >$@,# This file lists all individuals having contributed content to the repository.)
@$(file >>$@,# For how it is generated, see `make AUTHORS`.)
@echo "$(shell git log --format='\n%aN <%aE>' | LC_ALL=C.UTF-8 sort -uf)" >> $@