This repository has been archived by the owner on Jan 21, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
76 lines (61 loc) · 2.21 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
GIT_NAME ?= $(shell git describe --exact-match 2>/dev/null)
GIT_HASH ?= git-$(shell git rev-parse --short=12 HEAD)
LDFLAGS ?= "-X github.com/authgear/authgear-nft-indexer/pkg/version.Version=${GIT_HASH}"
.PHONY: start
start:
go run ./cmd/server start
.PHONY: setup
setup: vendor
cp authgear-nft-indexer.yaml.example authgear-nft-indexer.yaml
.PHONY: vendor
vendor:
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin v1.63.4
go mod download
go install github.com/google/wire/cmd/wire
go install golang.org/x/vuln/cmd/govulncheck@latest
.PHONY: go-mod-outdated
go-mod-outdated:
# https://stackoverflow.com/questions/55866604/whats-the-go-mod-equivalent-of-npm-outdated
# Since go 1.21, this command will exit 2 when one of the dependencies require a go version newer than us.
# This implies we have to use the latest verion of Go whenever possible.
go list -u -m -f '{{if .Update}}{{if not .Indirect}}{{.}}{{end}}{{end}}' all
.PHONY: generate
generate:
go generate ./pkg/... ./cmd/...
.PHONY: test
test:
go test ./pkg/... -timeout 1m30s
.PHONY: lint
lint:
golangci-lint run ./cmd/... ./pkg/...
.PHONY: govulncheck
govulncheck:
govulncheck -show traces,version,verbose ./...
.PHONY: fmt
fmt:
go fmt ./...
.PHONY: build
build:
go build -o $(BIN_NAME) -tags "$(GO_BUILD_TAGS)" -ldflags ${LDFLAGS} ./cmd/$(TARGET)
.PHONY: check-tidy
check-tidy:
$(MAKE) fmt
$(MAKE) generate
go mod tidy
git status --porcelain | grep '.*'; test $$? -eq 1
.PHONY: build-image
build-image:
# Add --pull so that we are using the latest base image.
docker build --pull --file ./cmd/$(TARGET)/Dockerfile --tag $(IMAGE_NAME) --build-arg GIT_HASH=$(GIT_HASH) .
.PHONY: tag-image
tag-image: DOCKER_IMAGE = quay.io/theauthgear/$(IMAGE_NAME)
tag-image:
docker tag $(IMAGE_NAME) $(DOCKER_IMAGE):latest
docker tag $(IMAGE_NAME) $(DOCKER_IMAGE):$(GIT_HASH)
if [ ! -z $(GIT_NAME) ]; then docker tag $(IMAGE_NAME) $(DOCKER_IMAGE):$(GIT_NAME); fi
.PHONY: push-image
push-image: DOCKER_IMAGE = quay.io/theauthgear/$(IMAGE_NAME)
push-image:
docker push $(DOCKER_IMAGE):latest
docker push $(DOCKER_IMAGE):$(GIT_HASH)
if [ ! -z $(GIT_NAME) ]; then docker push $(DOCKER_IMAGE):$(GIT_NAME); fi