blob: 126467b8bb23036a4c06f051258fe8951a23ab57 [file] [log] [blame]
gioe71b12b2026-07-29 10:02:37 +04001GO ?= go
2GOFMT ?= gofmt
3GO_FILES := $(wildcard *.go e2e/*.go)
4
gio2446de02025-04-11 11:20:39 +04005repo_name ?= giolekva
DTabidze52593392024-03-08 12:53:20 +04006podman ?= docker
gio2446de02025-04-11 11:20:39 +04007docker_flags=--provenance=false --sbom=false
giob7df27f2026-07-28 10:36:17 +04008
gioe71b12b2026-07-29 10:02:37 +04009.PHONY: clean format format-check test test-race vet check test-e2e test-e2e-offline clean-e2e-artifacts build build_arm64 build_amd64 push_arm64 push_amd64 push
Giorgi Lekveishvili0ba5e402024-03-20 15:56:30 +040010ifeq ($(podman), podman)
giob7df27f2026-07-28 10:36:17 +040011manifest_dest=docker://docker.io/$(repo_name)/auth-ui:latest
Giorgi Lekveishvili0ba5e402024-03-20 15:56:30 +040012endif
DTabidze52593392024-03-08 12:53:20 +040013
giolekva603e73a2021-10-22 14:46:45 +040014clean:
Giorgi Lekveishvili58cb1482023-12-04 12:33:49 +040015 rm -f server server_*
16
gioe71b12b2026-07-29 10:02:37 +040017format:
18 $(GOFMT) -w $(GO_FILES)
19
20format-check:
21 @files="$$( $(GOFMT) -l $(GO_FILES) )" || { status=$$?; printf 'gofmt check failed\n' >&2; exit $$status; }; \
22 if [ -n "$$files" ]; then printf 'Go files need formatting:\n%s\n' "$$files" >&2; exit 1; fi
23
giob7df27f2026-07-28 10:36:17 +040024test:
gioe71b12b2026-07-29 10:02:37 +040025 $(GO) test ./...
26
27test-race:
28 $(GO) test -race -count=1 ./...
29
30vet:
31 $(GO) vet ./...
32
33check: format-check test test-race vet
34 $(GO) build ./...
giob7df27f2026-07-28 10:36:17 +040035
36test-e2e:
gioe71b12b2026-07-29 10:02:37 +040037 $(GO) test -tags=e2e -count=1 -timeout=10m -v ./e2e
giob7df27f2026-07-28 10:36:17 +040038
39test-e2e-offline:
gioe71b12b2026-07-29 10:02:37 +040040 AUTH_UI_E2E_OFFLINE=1 $(GO) test -tags=e2e -count=1 -timeout=10m -v ./e2e
giob7df27f2026-07-28 10:36:17 +040041
42clean-e2e-artifacts:
43 rm -rf -- e2e/artifacts
44
Giorgi Lekveishvili58cb1482023-12-04 12:33:49 +040045build: clean
gioe71b12b2026-07-29 10:02:37 +040046 $(GO) build -o server *.go
giolekva603e73a2021-10-22 14:46:45 +040047
giolekva6f3e2332021-12-04 19:42:13 +040048build_arm64: export CGO_ENABLED=0
49build_arm64: export GO111MODULE=on
50build_arm64: export GOOS=linux
51build_arm64: export GOARCH=arm64
52build_arm64:
gioe71b12b2026-07-29 10:02:37 +040053 $(GO) build -o server_arm64 *.go
giolekva603e73a2021-10-22 14:46:45 +040054
giolekva6f3e2332021-12-04 19:42:13 +040055build_amd64: export CGO_ENABLED=0
56build_amd64: export GO111MODULE=on
57build_amd64: export GOOS=linux
58build_amd64: export GOARCH=amd64
59build_amd64:
gioe71b12b2026-07-29 10:02:37 +040060 $(GO) build -o server_amd64 *.go
giolekva603e73a2021-10-22 14:46:45 +040061
Giorgi Lekveishvilia1e77902023-11-06 14:48:27 +040062push_arm64: clean build_arm64
gio2446de02025-04-11 11:20:39 +040063 $(podman) build --platform linux/arm64 --tag=$(repo_name)/auth-ui:arm64 $(docker_flags) .
DTabidze52593392024-03-08 12:53:20 +040064 $(podman) push $(repo_name)/auth-ui:arm64
Giorgi Lekveishvilia1e77902023-11-06 14:48:27 +040065
66push_amd64: clean build_amd64
gio2446de02025-04-11 11:20:39 +040067 $(podman) build --platform linux/amd64 --tag=$(repo_name)/auth-ui:amd64 $(docker_flags) .
DTabidze52593392024-03-08 12:53:20 +040068 $(podman) push $(repo_name)/auth-ui:amd64
Giorgi Lekveishvilia1e77902023-11-06 14:48:27 +040069
70
71push: push_arm64 push_amd64
DTabidze52593392024-03-08 12:53:20 +040072 $(podman) manifest create $(repo_name)/auth-ui:latest $(repo_name)/auth-ui:arm64 $(repo_name)/auth-ui:amd64
gio2446de02025-04-11 11:20:39 +040073 $(podman) manifest push --purge $(repo_name)/auth-ui:latest $(manifest_dest)