forked from doublecloud/transfer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
76 lines (64 loc) · 2.11 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
# removes static build artifacts
.PHONY: clean
clean:
@echo "--------------> Running 'make clean'"
@rm -rf binaries tmp
rm -f *.tgz
# Define the `build` target
API ?= trcli
.PHONY: build
build:
go build -o binaries/$(API) ./cmd/trcli/*.go
docker: build
cp binaries/$(API) . && docker build -t transfer
.PHONY: test
test:
USE_TESTCONTAINERS=1 gotestsum --rerun-fails --format github-actions --packages="./cmd/..." -- -timeout=30m
# Define variables for the suite group, path, and name with defaults
SUITE_GROUP ?= 'tests/e2e'
SUITE_PATH ?= 'pg2pg'
SUITE_NAME ?= 'e2e-pg2pg'
SHELL := /bin/bash
# Define the `run-tests` target
.PHONY: run-tests
run-tests:
@echo "Running $(SUITE_GROUP) suite $(SUITE_NAME)"
@export RECIPE_CLICKHOUSE_BIN=clickhouse; \
export USE_TESTCONTAINERS=1; \
export YA_TEST_RUNNER=1; \
export YT_PROXY=localhost:8180; \
export TEST_DEPS_BINARY_PATH=binaries; \
for dir in $$(find ./$(SUITE_GROUP)/$(SUITE_PATH) -type d); do \
if ls "$$dir"/*_test.go >/dev/null 2>&1; then \
echo "::group::$$dir"; \
echo "Running tests for directory: $$dir"; \
sanitized_dir=$$(echo "$$dir" | sed 's|/|_|g'); \
gotestsum \
--junitfile="reports/$(SUITE_NAME)_$$sanitized_dir.xml" \
--junitfile-project-name="$(SUITE_GROUP)" \
--junitfile-testsuite-name="short" \
--rerun-fails \
--format github-actions \
--packages="$$dir" \
-- -timeout=15m; \
echo "::endgroup::"; \
else \
echo "No Go test files found in $$dir, skipping tests."; \
fi \
done
# Define variables
HELM_CHART_PATH := ./helm/transfer
IMAGE_NAME := ghcr.io/doublecloud/transfer-helm
VERSION := $(shell grep '^version:' $(HELM_CHART_PATH)/Chart.yaml | awk '{print $$2}')
# Login to GitHub Container Registry
.PHONY: login-ghcr
login-ghcr:
echo "${GHCR_TOKEN}" | docker login ghcr.io -u ${GITHUB_USERNAME} --password-stdin
# Package the Helm chart
.PHONY: helm-package
helm-package:
helm package $(HELM_CHART_PATH) --destination .
# Push the Helm chart as OCI artifact
.PHONY: helm-push
helm-push: helm-package login-ghcr
helm push ./transfer-$(VERSION).tgz oci://$(IMAGE_NAME)