forked from quay/claircore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
62 lines (51 loc) · 1.73 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
docker ?= docker
docker-compose ?= docker-compose
# clears any go code in various caches
.PHONY: clear-cache
clear-cache:
go clean -cache -testcache -modcache
test -d $${XDG_CACHE_HOME:-$${HOME}/.cache}/clair-testing && rm -rf $${XDG_CACHE_HOME:-$${HOME}/.cache}/clair-testing
# generates mocks of interfaces for testing
.PHONY: genmocks
genmocks:
@command -v mockgen >/dev/null || go install github.com/golang/mock/mockgen
go generate ./...
# Runs integration tests. An embedded postgres binary will be fetched if the
# environment variable "POSTGRES_CONNECTION_STRING" isn't set.
.PHONY: integration
integration:
go test -count=1 -race -tags integration ./...
# runs unit tests. no db necessary
.PHONY: unit
unit:
go test -race ./...
# run bench marks - db must be available. use the db commands below to ensure
.PHONY: bench
bench:
go test -tags integration -run=xxx -bench ./...
# same as integration but with verbose
.PHONY: integration-v
integration-v:
go test -count=1 -race -v -tags integration ./...
# same as unit but with verbose
.PHONY: unit-v
unit-v:
go test -race -v ./...
.PHONY: claircore-db-up
claircore-db-up:
$(docker-compose) up -d claircore-db
$(docker) exec -it claircore-db bash -c 'while ! pg_isready; do echo "waiting for postgres"; sleep 2; done'
.PHONY: claircore-db-restart
claircore-db-restart:
$(docker) kill claircore-db && $(docker) rm claircore-db
make claircore-db-up
GO_VERSION ?= 1.18
GO_CHECKSUM ?= e85278e98f57cdb150fe8409e6e5df5343ecb13cebf03a5d5ff12bd55a80264f
.PHONY: baseimage
baseimage:
podman build -f etc/Dockerfile -t quay.io/projectquay/golang:$(GO_VERSION) \
--build-arg GO_VERSION=$(GO_VERSION) \
--build-arg GO_CHECKSUM=$(GO_CHECKSUM) \
etc
book: $(wildcard docs/*) book.toml
mdbook build