-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·52 lines (38 loc) · 1.36 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
PROJECT = rdap-exporter
VERSION = $(shell cat VERSION)
LDFLAGS=-ldflags "-w -s -X github.com/hsn723/rdap-exporter/cmd.version=${VERSION}"
CST_VERSION = 1.16.0
WORKDIR = /tmp/$(PROJECT)/work
BINDIR = /tmp/$(PROJECT)/bin
CONTAINER_STRUCTURE_TEST = $(BINDIR)/container-structure-test
PATH := $(PATH):$(BINDIR)
export PATH
all: build
.PHONY: clean
clean:
@if [ -f $(PROJECT) ]; then rm $(PROJECT); fi
.PHONY: lint
lint:
@if [ -z "$(shell which pre-commit)" ]; then pip3 install pre-commit; fi
pre-commit install
pre-commit run --all-files
.PHONY: test
test:
go test --tags=test -coverprofile cover.out -count=1 -race -p 4 -v ./...
.PHONY: $(CONTAINER_STRUCTURE_TEST)
$(CONTAINER_STRUCTURE_TEST): $(BINDIR)
curl -sSLf -o $(CONTAINER_STRUCTURE_TEST) -O https://storage.googleapis.com/container-structure-test/v$(CST_VERSION)/container-structure-test-linux-amd64 && chmod +x $(CONTAINER_STRUCTURE_TEST)
.PHONY: container-structure-test
container-structure-test: $(CONTAINER_STRUCTURE_TEST)
printf "amd64\narm64" | xargs -n1 -I {} $(CONTAINER_STRUCTURE_TEST) test --image ghcr.io/hsn723/$(PROJECT):$(shell git describe --tags --abbrev=0 --match "v*" || echo v0.0.0)-next-{} --config cst.yaml
.PHONY: verify
verify:
go mod download
go mod verify
.PHONY: build
build: clean
env CGO_ENABLED=0 go build $(LDFLAGS) .
$(BINDIR):
mkdir -p $(BINDIR)
$(WORKDIR):
mkdir -p $(WORKDIR)