-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.lib
83 lines (55 loc) · 2.69 KB
/
Makefile.lib
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
.DEFAULT_GOAL := help
.common-phony: help build-ci push-ci install install-no-dev publish clean _env-info
.PHONY: help build-ci push-ci install install-no-dev coverage gen-db-revision publish clean _env-info
# Poetry does not handle "default" flavor of Python, and uses the most recent one. That's nice,
# but we like to be in control, knowing what exactl we did install.
DEFAULT_PYTHON ?= python3.9
# Container image for GitLab CI
IMAGE_GILTAB_CI ?= quay.io/testing-farm/gitlab-ci-artemis:latest
##@ -- Common targets ---------------------
_env-info:
@echo "# Poetry: $$(type poetry) $$(poetry --version $$POETRY_ADDOPTS)"
@echo "# Global Poetry configuration:"
@poetry config --list $$POETRY_ADDOPTS
@echo "# Local Poetry configuration:"
@poetry config --list --local $$POETRY_ADDOPTS
@echo "# Tox: $$(type tox) $$(tox --version)"
##@ Images
build-ci: ## Build container image for CI
buildah bud --layers -t $(IMAGE_GILTAB_CI) -f ../container/Dockerfile.gitlab-ci .
push-ci: ## Push container image for CI to registry
buildah push $(IMAGE_GILTAB_CI)
##@ Installation
install: _env-info ## Install component and development tools
poetry env use $(DEFAULT_PYTHON) $$POETRY_ADDOPTS
poetry env info $$POETRY_ADDOPTS
poetry install -v --remove-untracked -E full $$POETRY_ADDOPTS
install-no-dev: _env-info ## Install component alone, no development tools
poetry env use $(DEFAULT_PYTHON) $$POETRY_ADDOPTS
poetry env info $$POETRY_ADDOPTS
poetry install -v --no-dev --remove-untracked -E full $$POETRY_ADDOPTS
##@ Tests
.common-tests: test-units test-pre-commit
tests: .common-tests ## Run all tests
test-units: _env-info ## Run unit tests
tox -e py37
test-pre-commit: install ## Run pre-commit checks
git ls-files -- . | xargs -n200 poetry run pre-commit run --show-diff-on-failure --files
coverage: _env-info ## Run tests with coverage
tox -e py37-coverage
##@ Documentation
.common-docs: docs-autodocs
docs: .common-docs ## Generate all documentation
docs-autodocs: ## Generate source code documentation
tox -e autodocs
##@ Release
publish: ## Publish component as PyPI package
@poetry publish --username $(PYPI_USERNAME) --password $(PYPI_PASSWORD) --build $$POETRY_ADDOPTS
##@ Utility
clean: ## Remove virtual environments
rm -rf .tox
rm -rf .venv
# 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: ## Show this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make [target]\033[36m\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(call reverse, $(MAKEFILE_LIST))