/
Makefile
120 lines (102 loc) · 3.94 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
115
116
117
118
119
120
ARGO_WORKFLOWS_VERSION="3.4.4"
OPENAPI_SPEC_URL="https://raw.githubusercontent.com/argoproj/argo-workflows/v$(ARGO_WORKFLOWS_VERSION)/api/openapi-spec/swagger.json"
SPEC_PATH="$(shell pwd)/argo-workflows-$(ARGO_WORKFLOWS_VERSION).json"
.PHONY: help
help: ## Showcase the help instructions for all the available `make` commands
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: install
install: ## Run poetry install with default behaviour
@poetry env use system
@poetry install
.PHONY: install-3.8
install-3.8: ## Install python3.8 for generating test data
@poetry env use 3.8
@poetry install
.PHONY: ci
ci: ## Run all the CI checks
ci: CI=1
ci: lint test check-codegen
.PHONY: codegen
codegen: ## Generate all the code (models, services, examples, and init files)
codegen: models services examples init-files
.PHONY: check-codegen
check-codegen: ## Check if the code is up to date
check-codegen:
@$(MAKE) codegen
git diff --exit-code || "Code is not up-to-date. Please run 'make codegen'"
.PHONY: format
format: ## Format and sort imports for source, tests, examples, etc.
@poetry run black .
@poetry run ruff . --fix
.PHONY: lint
lint: ## Run a `lint` process on Hera and report problems
@poetry run black . --check
@poetry run ruff .
@poetry run mypy -p hera
.PHONY: test
test: ## Run tests for Hera
@poetry run python -m pytest --cov-report=term-missing
.PHONY: workflows-models
workflows-models: ## Generate the Workflows models portion of Argo Workflows
@touch $(SPEC_PATH)
@poetry run python scripts/spec.py $(OPENAPI_SPEC_URL) $(SPEC_PATH)
@poetry run datamodel-codegen \
--input $(SPEC_PATH) \
--snake-case-field \
--target-python-version 3.8 \
--output src/hera/workflows/models \
--base-class hera.shared._base_model.BaseModel \
--wrap-string-literal \
--disable-appending-item-suffix \
--disable-timestamp \
--use-default-kwarg
@poetry run python scripts/models.py $(OPENAPI_SPEC_URL) workflows
@poetry run stubgen -o src -p hera.workflows.models && find src/hera/workflows/models -name '__init__.pyi' -delete
@rm $(SPEC_PATH)
@$(MAKE) format
.PHONY: events-models
events-models: ## Generate the Events models portion of Argo Workflows
@touch $(SPEC_PATH)
@poetry run python scripts/spec.py $(OPENAPI_SPEC_URL) $(SPEC_PATH)
@poetry run datamodel-codegen \
--input $(SPEC_PATH) \
--snake-case-field \
--target-python-version 3.8 \
--output src/hera/events/models \
--base-class hera.shared._base_model.BaseModel \
--wrap-string-literal \
--disable-appending-item-suffix \
--disable-timestamp \
--use-default-kwarg
@poetry run python scripts/models.py $(OPENAPI_SPEC_URL) events
@poetry run stubgen -o src -p hera.events.models && find src/hera/events/models -name '__init__.pyi' -delete
@rm $(SPEC_PATH)
@$(MAKE) format
.PHONY: models
models: ## Generate all the Argo Workflows models
models: workflows-models events-models
.PHONY: workflows-service
workflows-service: ## Generate the Workflows service option of Hera
@poetry run python scripts/service.py $(OPENAPI_SPEC_URL) workflows
$(MAKE) format
.PHONY: events-service
events-service: ## Generate the events service option of Hera
@poetry run python scripts/service.py $(OPENAPI_SPEC_URL) events
$(MAKE) format
.PHONY: services
services: ## Generate the services of Hera
services: workflows-service events-service
.PHONY: init-files
init-files: ## Generate the init-files of Hera
init-files:
@poetry run python scripts/init_files.py
$(MAKE) format
.PHONY: examples
examples: ## Generate all the examples
@(cd docs && poetry run python generate.py)
.PHONY: regenerate-test-data
regenerate-test-data: ## Regenerates the test data from upstream examples and runs tests, report missing examples
regenerate-test-data: install-3.8
find examples -name "*.yaml" -type f -delete
HERA_REGENERATE=1 make test examples
@poetry run python -m pytest -k test_for_missing_examples --runxfail