-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
executable file
·76 lines (57 loc) · 2.82 KB
/
Makefile
File metadata and controls
executable file
·76 lines (57 loc) · 2.82 KB
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
.DEFAULT_GOAL := help
# Use force targets instead of listing all the targets we have via .PHONY
# https://www.gnu.org/software/make/manual/html_node/Force-Targets.html#Force-Targets
.FORCE:
# default image tag set to current user name
IMAGE = quay.io/testing-farm/cli
IMAGE_TAG ?= ${USER}
PROJECT_ROOT := $(shell git rev-parse --show-toplevel)
# get tool version, used only inside the CLI alpine container
# NOTE(mvadkert): do not use `testing-farm version` here as the rich print breaks goss due to formatting, and no workaround found
CLI_VERSION=$(shell sh -c "python -c \"import importlib.metadata; print(importlib.metadata.version('tft-cli'))\" 2>/dev/null")
build: ## Build the container image
rm -rf $(PROJECT_ROOT)/dist
poetry build
buildah bud --layers -t $(IMAGE):$(IMAGE_TAG) -f container/Dockerfile .
build/fedora: ## Build the Fedora-based container image
rm -rf $(PROJECT_ROOT)/dist
poetry build
buildah bud --layers -t $(IMAGE):fedora-$(IMAGE_TAG) -f container/Dockerfile.fedora .
push: ## Push the container image to quay.io
buildah push $(IMAGE):$(IMAGE_TAG)
push/fedora: ## Push the Fedora-based container image to quay.io
buildah push $(IMAGE):fedora-$(IMAGE_TAG)
enter: ## Run bash in the container with the code
podman run --rm -itv $$(pwd):/code:Z $(IMAGE):$(IMAGE_TAG) bash
pre-commit: ## Run pre-commit on all files
pre-commit run --all-files
tmt: ## Run available tmt tests
-tmt clean runs -i tft-cli
-tmt run -e IMAGE_TAG=$(IMAGE_TAG) -i tft-cli
tmt run -i tft-cli report -vvv
tox: ## Run tox based tests
poetry run tox
testing-farm: build build/fedora push push/fedora ## Run the tmt tests in Testing Farm
testing-farm request -e IMAGE_TAG=$(IMAGE_TAG)
test: build build/fedora pre-commit tmt tox ## Run all the tests
test-container: ## Test the container via goss
if command -v goss; then \
MOUNT_GOSS="-v $$(command -v goss):/usr/bin/goss:Z)"; \
fi
podman run -it --rm -v $$PWD:/code:Z $$MOUNT_GOSS --entrypoint make $(IMAGE):$(IMAGE_TAG) goss
goss: ## Run goss inside the container
if [ ! -e "/.testing-farm-cli" ]; then \
echo "Error: expected to run inside the CLI container only."; \
exit 1; \
fi
if ! command -v goss; then \
wget -O /usr/bin/goss https://github.com/goss-org/goss/releases/latest/download/goss-linux-amd64; \
chmod +rx /usr/bin/goss; \
fi
cd container && CLI_VERSION=$(CLI_VERSION) goss validate
clean: ## Cleanup
buildah rmi $(IMAGE):$(IMAGE_TAG)
# See https://www.thapaliya.com/en/writings/well-documented-makefiles/ for details.
reverse = $(if $(1),$(call reverse,$(wordlist 2,$(words $(1)),$(1)))) $(firstword $(1))
help: .FORCE ## Show this help
@awk 'BEGIN {FS = ":.*##"; printf "$(info $(PRELUDE))"} /^[a-zA-Z_/-]+:.*?##/ { printf " \033[36m%-35s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(call reverse, $(MAKEFILE_LIST))