github.com/quay/claircore@v1.5.28/Makefile (about)

     1  docker ?= docker
     2  docker-compose ?= docker-compose
     3  
     4  # clears any go code in various caches
     5  .PHONY: clear-cache
     6  clear-cache:
     7  	go clean -cache -testcache -modcache
     8  	test -d $${XDG_CACHE_HOME:-$${HOME}/.cache}/clair-testing && rm -rf $${XDG_CACHE_HOME:-$${HOME}/.cache}/clair-testing
     9  
    10  # generates mocks of interfaces for testing
    11  .PHONY: genmocks
    12  genmocks:
    13  	@command -v mockgen >/dev/null || go install github.com/golang/mock/mockgen
    14  	go generate ./...
    15  
    16  # Runs integration tests. An embedded postgres binary will be fetched if the
    17  # environment variable "POSTGRES_CONNECTION_STRING" isn't set.
    18  .PHONY: integration
    19  integration:
    20  	go test -count=1 -race -tags integration ./...
    21  
    22  # runs unit tests. no db necessary
    23  .PHONY: unit
    24  unit:
    25  	go test -race ./...
    26  
    27  # run bench marks - db must be available. use the db commands below to ensure
    28  .PHONY: bench
    29  bench:
    30  	go test -tags integration -run=xxx -bench ./...
    31  
    32  # same as integration but with verbose
    33  .PHONY: integration-v
    34  integration-v:
    35  	go test -count=1 -race -v -tags integration ./...
    36  
    37  # same as unit but with verbose
    38  .PHONY: unit-v
    39  unit-v:
    40  	go test -race -v ./...
    41  
    42  .PHONY: claircore-db-up
    43  claircore-db-up:
    44  	$(docker-compose) up -d claircore-db
    45  	$(docker) exec -it claircore-db bash -c 'while ! pg_isready; do echo "waiting for postgres"; sleep 2; done'
    46  
    47  .PHONY: claircore-db-restart
    48  claircore-db-restart:
    49  	$(docker) kill claircore-db && $(docker) rm claircore-db
    50  	make claircore-db-up
    51  
    52  GO_VERSION ?= 1.18
    53  GO_CHECKSUM ?= e85278e98f57cdb150fe8409e6e5df5343ecb13cebf03a5d5ff12bd55a80264f
    54  .PHONY: baseimage
    55  baseimage:
    56  	podman build -f etc/Dockerfile -t quay.io/projectquay/golang:$(GO_VERSION) \
    57  		--build-arg GO_VERSION=$(GO_VERSION) \
    58  	   	--build-arg GO_CHECKSUM=$(GO_CHECKSUM) \
    59  		etc
    60  
    61  book: $(wildcard docs/*) book.toml
    62  	mdbook build
    63  
    64  docs/mermaid.min.js:
    65  	curl -sSfL 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.min.js' >$@