forked from contiamo/openapi-generator-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
82 lines (60 loc) · 2.08 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
include .bingo/Variables.mk
.PROJECT_ROOT=$(shell pwd)
.OWNER=contiamo
.NAME=openapi-generator-go
REGISTRY=
GIT_COMMIT=$(shell git rev-parse HEAD)
GIT_VERSION=$(shell git describe --tags --always --dirty 2>/dev/null)
.GIT_UNTRACKEDCHANGES := $(shell git status --porcelain --untracked-files=no)
ifneq ($(.GIT_UNTRACKEDCHANGES),)
GIT_VERSION := $(GIT_VERSION)-$(shell date +"%s")
endif
GOBINS=$(shell go env GOBIN)
default: install
.PHONY: version
version:
@echo $(GIT_VERSION)
## Build env
setup: $(GORELEASER) $(GOLANGCI_LINT) ## install the required build environment binaries
################################
################################
.PHONY: lint
lint: $(GOLANGCI_LINT) ## Verifies `golangci-lint` passes
@echo "+ $@"
@$(GOLANGCI_LINT) run ./...
.PHONY: lint-fix
lint-fix: $(GOLANGCI_LINT) ## Verifies `golangci-lint` passes
@echo "+ $@"
@$(GOLANGCI_LINT) run --fix ./...
.PHONY: fmt
fmt:
@echo "+ $@"
@gofmt -s -l . | tee /dev/stderr
test:
@go test -cover ./...
@cd pkg/generators/models/testdata/cases/oneof_mapped_discriminator/expected && go test -cover ./...
@cd pkg/generators/models/testdata/cases/validation/expected && go test -cover ./...
@cd pkg/generators/models/testdata/cases/objects_with_properties_and_additional_properties/expected && go test -cover ./...
${GOBINS}/${.NAME}: $(shell find . -name '*.go') go.*
@echo "+ $@"
go install -tags 'osusergo netgo' -v -ldflags "\
-X github.com/contiamo/openapi-generator-go/v2/cmd/openapi-generator-go/cmd.GitCommit=$(GIT_COMMIT) \
-X github.com/contiamo/openapi-generator-go/v2/cmd/openapi-generator-go/cmd.Version=$(GIT_VERSION)" \
.
install: ${GOBINS}/${.NAME}
dist: $(GORELEASER) $(shell find . -name '*.go') go.*
$(GORELEASER) build --skip-validate --rm-dist
image: dist
docker buildx build \
--load \
--platform linux/amd64 \
--tag $(REGISTRY)$(.OWNER)/$(.NAME):$(GIT_VERSION) \
.
image-multi: dist
docker buildx build \
--push \
--platform linux/amd64,linux/arm64 \
--tag $(REGISTRY)$(.OWNER)/$(.NAME):$(GIT_VERSION) \
.
update-cases:
cd pkg/generators/models/testdata/cases && ./update.sh