-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile.dontuse
107 lines (83 loc) · 4.34 KB
/
Makefile.dontuse
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
DOCKER_REPO := ghcr.io/na4ma4/traefik-acme
# GO_MATRIX ?= darwin/amd64 darwin/arm64 \
# linux/amd64 \
# windows/amd64
DOCKER_PLATFORMS := linux/$(shell go env GOARCH)
DOCKER_BUILD_ARGS += --build-arg "DOCKER_PLATFORM=$(DOCKER_PLATFORMS)"
APP_DATE ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
GIT_HASH ?= $(shell git show -s --format=%h)
GO_DEBUG_ARGS ?= -v -ldflags "-X main.version=$(GO_APP_VERSION)+debug -X main.commit=$(GIT_HASH) -X main.date=$(APP_DATE) -X main.builtBy=makefiles"
GO_RELEASE_ARGS ?= -v -ldflags "-X main.version=$(GO_APP_VERSION) -X main.commit=$(GIT_HASH) -X main.date=$(APP_DATE) -X main.builtBy=makefiles -s -w"
-include .makefiles/Makefile
-include .makefiles/pkg/go/v1/Makefile
-include .makefiles/pkg/docker/v1/Makefile
-include .makefiles/ext/na4ma4/lib/golangci-lint/v1/Makefile
# -include .makefiles/ext/na4ma4/lib/goreleaser/v1/Makefile
.makefiles/ext/na4ma4/%: .makefiles/Makefile
@curl -sfL https://raw.githubusercontent.com/na4ma4/makefiles-ext/main/v1/install | bash /dev/stdin "$@"
.makefiles/%:
@curl -sfL https://makefiles.dev/v1 | bash /dev/stdin "$@"
.PHONY: install
install: artifacts/build/release/$(GOHOSTOS)/$(GOHOSTARCH)/traefik-acme
install "$(<)" /usr/local/bin/
.PHONY: run
run: artifacts/build/debug/$(GOHOSTOS)/$(GOHOSTARCH)/traefik-acme
$< $(RUN_ARGS)
.PHONY: upx
upx: $(patsubst artifacts/build/%,artifacts/upx/%.upx,$(_GO_RELEASE_TARGETS_ALL))
artifacts/upx/%.upx: artifacts/build/%
-@mkdir -p "$(@D)"
-$(RM) -f "$(@)"
upx -o "$@" "$<"
.PHONY: docker-run
docker-run: docker
docker run -ti --rm $(DOCKER_REPO):$(DOCKER_TAGS) $(RUN_ARGS)
######################
# Tests
######################
TEST_RUNNER := artifacts/build/debug/$(GOHOSTOS)/$(GOHOSTARCH)/traefik-acme
.DELETE_ON_ERROR: artifacts/test/issue-5/test1.out
REGRESSION_TESTS += artifacts/test/issue-5/test1.out
artifacts/test/issue-5/test1.out: testdata/issue-5/acme.json $(TEST_RUNNER) $(GO_SOURCE_FILES)
-@mkdir -p "$(@D)"
-@$(RM) "$(@D)/cert.pem" "$(@D)/key.pem"
$(TEST_RUNNER) --acme="$(<)" --certificate-resolver="acme-different" --cert "$(@D)/cert.pem" --key "$(@D)/key.pem" "*.example.com" | tee "$(@)"
grep "certificate-for-example.com" "$(@D)/cert.pem"
grep "key-for-example.com" "$(@D)/key.pem"
.DELETE_ON_ERROR: artifacts/test/issue-5/test2.out
REGRESSION_TESTS += artifacts/test/issue-5/test2.out
artifacts/test/issue-5/test2.out: testdata/issue-5/acme.json $(TEST_RUNNER) $(GO_SOURCE_FILES)
-@mkdir -p "$(@D)"
-@$(RM) "$(@D)/cert.pem" "$(@D)/key.pem"
$(TEST_RUNNER) --acme="$(<)" --certificate-resolver="acme-different" --cert "$(@D)/cert.pem" --key "$(@D)/key.pem" "example.com" | tee "$(@)"
grep "certificate-for-example.com" "$(@D)/cert.pem"
grep "key-for-example.com" "$(@D)/key.pem"
.DELETE_ON_ERROR: artifacts/test/issue-14/v1/test1.out
REGRESSION_TESTS += artifacts/test/issue-14/v1/test1.out
artifacts/test/issue-14/v1/test1.out: testdata/issue-14/v1/acme.json $(TEST_RUNNER) $(GO_SOURCE_FILES)
-@mkdir -p "$(@D)"
-@$(RM) "$(@D)/cert.pem" "$(@D)/key.pem"
$(TEST_RUNNER) --acme="$(<)" --cert "$(@D)/cert.pem" --key "$(@D)/key.pem" "test.example.com" | tee "$(@)"
grep "Certificate" "$(@D)/cert.pem"
grep "Certificate Key" "$(@D)/key.pem"
.DELETE_ON_ERROR: artifacts/test/issue-14/v2/test1.out
REGRESSION_TESTS += artifacts/test/issue-14/v2/test1.out
artifacts/test/issue-14/v2/test1.out: testdata/issue-14/v2/new-acme.json $(TEST_RUNNER) $(GO_SOURCE_FILES)
-@mkdir -p "$(@D)"
-@$(RM) "$(@D)/cert.pem" "$(@D)/key.pem"
$(TEST_RUNNER) --acme="$(<)" --certificate-resolver "myresolver" --cert "$(@D)/cert.pem" --key "$(@D)/key.pem" "test.example.com" | tee "$(@)"
grep "Certificate" "$(@D)/cert.pem"
grep "Certificate Key" "$(@D)/key.pem"
.DELETE_ON_ERROR: artifacts/test/issue-52/cert.pem artifacts/test/issue-52/key.pem
REGRESSION_TESTS += artifacts/test/issue-52/cert.pem artifacts/test/issue-52/key.pem
artifacts/test/issue-52/cert.pem artifacts/test/issue-52/key.pem: testdata/issue-52/acme.json docker
-@mkdir -p "$(@D)"
docker run --rm --user "$(shell id -u):$(shell id -g)" -v "$(shell pwd)/testdata/issue-52:/input" -v "$(shell pwd)/$(@D):/output" --workdir /output $(DOCKER_REPO):$(DOCKER_TAGS) --debug --acme "/input/acme.json" test.example.com | tee "$(@).log"
grep "^Certificate" "$(@)"
.PHONY: regression-tests
regression-tests: $(REGRESSION_TESTS)
ci:: $(REGRESSION_TESTS)
######################
# Linting
######################
ci:: lint