Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ GOLANGCI_VERSION = 2.7.2
GOFUMPT_VERSION=0.9.2
JQ_VERSION=1.8.1
KIND_VERSION=0.31.0
GOTESTSUM_VERSION=1.13.0

export TESTS_OPENSSH_IMAGE = lscr.io/linuxserver/openssh-server:10.0_p1-r9-ls209
export TESTS_PYTHON_IMAGE = registry.deckhouse.ru/base_images@sha256:b15f9150f3b51f2e11cd73db39c89eef8a075953659caf802363d4f544335fb5
Expand Down Expand Up @@ -58,7 +59,7 @@ else ifeq ($(PLATFORM_NAME), arm64)
KIND_ARCH = arm64
endif

.PHONY: bin/jq bin/gofumpt bin/golangci-lint clean validation/license/download curl-installed docker-installed go-installed clean/test clean/ssh clean/docker
.PHONY: bin/jq bin/gofumpt bin/golangci-lint bin/gotestsum clean validation/license/download curl-installed docker-installed go-installed clean/test clean/ssh clean/docker

bin:
@mkdir -p bin
Expand Down Expand Up @@ -101,7 +102,13 @@ bin/kind: curl-installed bin
chmod +x "./bin/kind"; \
fi

deps: bin bin/jq bin/golangci-lint bin/gofumpt bin/kind
bin/gotestsum: go-installed bin
@if ! ./hack/check_binary.sh "gotestsum" "--version" "$(GOTESTSUM_VERSION)"; then \
echo "Install gotestsum"; \
GOBIN=$(abspath bin/) go install gotest.tools/gotestsum@v$(GOTESTSUM_VERSION); \
fi

deps: bin bin/jq bin/golangci-lint bin/gofumpt bin/kind bin/gotestsum

go-deps/update: go-installed
@if [ -z "$(DEP)" ] ; then \
Expand Down Expand Up @@ -136,7 +143,7 @@ test/pull-ssh-image: docker-installed
test/pull-python-image: docker-installed
@docker pull $(TESTS_PYTHON_IMAGE)

test: go-installed docker-installed bin/kind test/pull-ssh-image test/pull-python-image
test: go-installed docker-installed bin/kind bin/gotestsum test/pull-ssh-image test/pull-python-image
./hack/run_tests.sh
$(MAKE) clean/test

Expand Down
5 changes: 4 additions & 1 deletion hack/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ check_all_deps
check_go
pull_image

# Absolute path: run_tests_in_dir cd's into module dirs (repo root and ./tests).
gotestsum_bin="$(gotestsum_bin_path)"

run_tests=""

if [ -n "$RUN_TEST" ]; then
Expand Down Expand Up @@ -80,7 +83,7 @@ function run_tests_in_dir() {
echo "Found packages: ${packages[@]} in ${run_dir} with module ${prefix}"

echo "Run tests in ${run_dir} (-p ${package_parallelism} -parallel ${test_parallelism})"
if ! go test -timeout 35m -v -p "$package_parallelism" -parallel "$test_parallelism" $run_tests $packages; then
if ! "$gotestsum_bin" -- -timeout 35m -v -p "$package_parallelism" -parallel "$test_parallelism" $run_tests $packages; then
all_failed_tests="$(echo -e "${all_failed_tests}\nTests in ${prefix} failed")"
fi
}
Expand Down
14 changes: 13 additions & 1 deletion hack/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,20 @@ function check_kind() {
fi
}

function gotestsum_bin_path() {
echo -n "$(pwd)/bin/gotestsum"
}

function check_gotestsum() {
local bin_path="$(gotestsum_bin_path)"
if ! [ -x "$bin_path" ]; then
echo "gotestsum not installed! You should run 'make bin/gotestsum' before"
exit 1
fi
}

function check_all_deps() {
check_docker && check_kind
check_docker && check_kind && check_gotestsum
}

function pull_image() {
Expand Down
Loading