-
Notifications
You must be signed in to change notification settings - Fork 78
/
Makefile
114 lines (90 loc) · 3.93 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
SHELL=/bin/bash -o pipefail
TARGET ?= default
POSTGRES_BASE_VERSION ?= 14
ECR_REGISTRY ?= 011789831835.dkr.ecr.us-east-1.amazonaws.com
GOLANGCI_LINT_VERSION ?= $$(cat .golangci_lint_version)
TEST_ARTIFACT_DIR ?= $(CURDIR)/tmp/test_artifacts
$(TEST_ARTIFACT_DIR):
mkdir -p $(TEST_ARTIFACT_DIR)
.PHONY: docker_build
# Runs a full multi-platform docker build
docker_build:
POSTGRES_BASE_VERSION=$(POSTGRES_BASE_VERSION) docker buildx bake --pull $(TARGET)
uname_m := $(shell uname -m)
ifeq ($(uname_m),x86_64)
PLATFORM ?= linux/amd64
else
PLATFORM ?= linux/$(uname_m)
endif
.PHONY: docker_build_local
# Runs a docker build for the target platform and loads it into the local docker
# environment
docker_build_local:
POSTGRES_BASE_VERSION=$(POSTGRES_BASE_VERSION) docker buildx bake --set *.platform=$(PLATFORM) --pull --load $(TARGET)
.PHONY: docker_build_local_postgres
docker_build_local_postgres: TARGET = postgres
# Runs a local docker build for the target platform for postgres and loads it
# into the local docker
docker_build_local_postgres: docker_build_local
.PHONY: docker_build_local_spilo
docker_build_local_spilo: TARGET = spilo
# Runs a local docker build for the target platform for spilo and loads it
# into the local docker
docker_build_local_spilo: docker_build_local
.PHONY: docker_check_columnar
docker_check_columnar:
docker buildx bake --set *.platform=$(PLATFORM) --set columnar.target=checker columnar_13 columnar_14
GO_TEST_FLAGS ?=
.PHONY: acceptance_test
# Runs the acceptance tests
acceptance_test: postgres_acceptance_test spilo_acceptance_test
.PHONY: acceptance_build_test
# Builds local images then runs the acceptance tests
acceptance_build_test: postgres_acceptance_build_test spilo_acceptance_build_test
POSTGRES_IMAGE ?= ghcr.io/hydradatabase/hydra:latest
POSTGRES_UPGRADE_FROM_IMAGE ?= ghcr.io/hydradatabase/hydra:$(POSTGRES_BASE_VERSION)
.PHONY: postgres_acceptance_test
# Runs the postgres acceptance tests
postgres_acceptance_test: $(TEST_ARTIFACT_DIR)
export ARTIFACT_DIR=$(TEST_ARTIFACT_DIR) && \
export POSTGRES_IMAGE=$(POSTGRES_IMAGE) && \
export POSTGRES_UPGRADE_FROM_IMAGE=$(POSTGRES_UPGRADE_FROM_IMAGE) && \
export EXPECTED_POSTGRES_VERSION=$(POSTGRES_BASE_VERSION) && \
cd acceptance && \
go test ./postgres/... $(GO_TEST_FLAGS) -count=1 -v
.PHONY: postgres_pull_upgrade_image
postgres_pull_upgrade_image:
docker pull $(POSTGRES_UPGRADE_FROM_IMAGE)
.PHONY: postgres_acceptance_build_test
# Builds the postgres image then runs the acceptance tests
postgres_acceptance_build_test: docker_build_local_postgres postgres_pull_upgrade_image postgres_acceptance_test
.PHONY: ecr_login
ecr_login:
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $(ECR_REGISTRY)
SPILO_REPO ?= $(ECR_REGISTRY)/spilo
SPILO_IMAGE ?= $(SPILO_REPO):latest
SPILO_UPGRADE_FROM_IMAGE ?= $(SPILO_REPO):$$(cat HYDRA_PROD_VER)
# Runs the spilo acceptance tests
.PHONY: spilo_acceptance_test
spilo_acceptance_test: $(TEST_ARTIFACT_DIR)
export ARTIFACT_DIR=$(TEST_ARTIFACT_DIR) && \
export SPILO_IMAGE=$(SPILO_IMAGE) && \
export SPILO_UPGRADE_FROM_IMAGE=$(SPILO_UPGRADE_FROM_IMAGE) && \
cd acceptance && \
go test ./spilo/... $(GO_TEST_FLAGS) -count=1 -v
.PHONY: spilo_pull_upgrade_image
spilo_pull_upgrade_image: ecr_login
docker pull $(SPILO_UPGRADE_FROM_IMAGE)
.PHONY: spilo_acceptance_build_test
# Builds the spilo image then runs acceptance tests
spilo_acceptance_build_test: docker_build_local_spilo spilo_pull_upgrade_image spilo_acceptance_test
.PHONY: lint_acceptance
# Runs the go linter
lint_acceptance:
docker run --rm -v $(CURDIR)/acceptance:/app -w /app golangci/golangci-lint:$(GOLANGCI_LINT_VERSION) \
golangci-lint run --timeout 5m --out-format colored-line-number
.PHONY: lint_fix_acceptance
# Runs the go linter with the auto-fixer
lint_fix_acceptance:
docker run --rm -v $(CURDIR)/acceptance:/app -w /app golangci/golangci-lint:$(GOLANGCI_LINT_VERSION) \
golangci-lint run --fix