-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
131 lines (106 loc) · 3.72 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
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
DEPSGOBIN:=$(shell pwd)/.bin
export PATH:=$(DEPSGOBIN):$(PATH)
export GOBIN:=$(DEPSGOBIN)
.PHONY: clean
clean: clean-helm
rm -rf vendor*
rm -rf $(DEPSGOBIN)
.PHONY: generate
generate: go-generate
.PHONY: vendor
vendor:
go mod tidy
go mod download
go mod vendor
# use the version from go.mod
GINKGO_VERSION ?= $(shell cat go.mod | grep ginkgo | cut -d" " -f2 | sed 's/^v0\.\([[:digit:]]\{1,\}\)\.[[:digit:]]\{1,\}$$/1.\1.x/')
.PHONY: install-tools
install-tools: install-go-tools
# Go dependencies download
# Retry is mainly for pipelines, on big installs we can sometimes get a connect error
.PHONY: mod-download
mod-download:
go mod download
# Go tools installation
.PHONY: install-go-tools
install-go-tools: mod-download
mkdir -p $(DEPSGOBIN)
go install go.uber.org/mock/[email protected]
go install github.com/onsi/ginkgo/v2/ginkgo@$(GINKGO_VERSION)
# Run go-generate on all sub-packages. This generates mocks and primitives used in the portal API implementation.
.PHONY: go-generate
go-generate:
go generate -v ./api/... ./internal/cognito/...
RELEASE := "true"
ifeq ($(TAGGED_VERSION),)
TAGGED_VERSION := $(shell git describe --tags --dirty)
RELEASE := "false"
endif
export VERSION ?= $(shell echo $(TAGGED_VERSION) | sed -e "s/^refs\/tags\///" | cut -c 2-)
CHART_DIR := helm
HELM_SYNC_DIR ?= _helm_sync_dir
PACKAGED_CHART_DIR ?= $(HELM_SYNC_DIR)/charts
# package helm release
.PHONY: package-helm
package-helm: helm-install set-version
mkdir -p $(PACKAGED_CHART_DIR)
helm package --destination $(PACKAGED_CHART_DIR) $(CHART_DIR)
# install helm
.PHONY: helm-install
helm-install:
which helm || curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
.PHONY: publish-chart
publish-chart: package-helm
ifeq ($(RELEASE),"true")
gsutil -m rsync -r gs://gloo-mesh-enterprise/gloo-portal-idp-connect $(HELM_SYNC_DIR)/
helm repo index $(HELM_SYNC_DIR) --merge $(HELM_SYNC_DIR)/index.yaml
gsutil -m rsync -r -d $(HELM_SYNC_DIR) gs://gloo-mesh-enterprise/gloo-portal-idp-connect
else
@echo "Not a release, skipping publishing Helm chart."
endif
.PHONY: clean-helm
clean-helm:
rm -rf $(HELM_SYNC_DIR)
rm -rf helm/Chart.yaml
rm -rf helm/values.yaml
VERSION_MINOR=$(shell echo "$(VERSION)" | cut -d. -f1-2)
HUB ?= us-docker.pkg.dev
REPO_DIR=gloo-portal-idp-connect
REPOSITORY ?= gloo-mesh/$(REPO_DIR)/gloo-portal-idp-connect
DOCKER_IMAGE := $(HUB)/$(REPOSITORY):$(VERSION)
.PHONY: docker-build
docker-build:
docker build . -t $(DOCKER_IMAGE)
.PHONY: docker-release
docker-release:
ifeq ($(RELEASE),"true")
VERSION_MINOR=${VERSION_MINOR} REPO_DIR=${REPO_DIR} scripts/release-docker.sh
docker buildx create --use --name multi-builder --platform linux/amd64,linux/arm64 || true
docker buildx use multi-builder
docker buildx build --platform=linux/amd64,linux/arm64 --push . -t $(DOCKER_IMAGE)
else
@echo "Not a release, skipping publishing Docker image."
endif
.PHONY: set-version
set-version:
sed -e 's/%version%/'$(VERSION)'/' $(CHART_DIR)/Chart-template.yaml > $(CHART_DIR)/Chart.yaml
sed -e 's/%version%/'$(VERSION)'/' $(CHART_DIR)/values-template.yaml > $(CHART_DIR)/values.yaml
# .bak for Linux/Mac portability
sed -i.bak 's/%repo-dir%/'$(REPO_DIR)'/' $(CHART_DIR)/values.yaml
rm -rf $(CHART_DIR)/values.yaml.bak
.PHONY: run-unit-tests
run-unit-tests:
ginkgo run -v ./internal/...
CLUSTER ?= kind
.PHONY: kind-load
kind-load: docker-build
kind load docker-image --name $(CLUSTER) $(DOCKER_IMAGE)
.PHONY: run-e2e-tests
run-e2e-tests: setup-test-clusters
ginkgo run -v ./test/e2e
.PHONY: setup-test-clusters
setup-test-clusters: package-helm
./env/setup/test-clusters.sh setup --idp-connect-version $(TAGGED_VERSION) --use-remote $(RELEASE)
.PHONY: cleanup-test-clusters
cleanup-test-clusters:
./env/setup/test-clusters.sh cleanup