forked from digitalocean/pydo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
133 lines (110 loc) · 4.39 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
121
122
123
124
125
126
127
128
129
130
131
132
133
LOCAL_SPEC_FILE=./DigitalOcean-public.v2.yaml
MODELERFOUR_VERSION="4.23.6"
AUTOREST_PYTHON_VERSION="6.13.16"
POETRY_VERSION:=$(shell poetry version)
PACKAGE_VERSION:=$(lastword $(POETRY_VERSION))
ROOT_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
ORIGIN ?= origin
BUMP ?= patch
ifeq (, $(findstring -m,$(PYTEST_ARGS)))
PYTEST_EXCLUDE_MARKS=-m "not real_billing"
endif
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'; \
printf "\nNOTE: Run 'SPEC_FILE=path/to/local/spec make generate' to skip the download and use a local spec file.\n"
.PHONY: dev-dependencies
dev-dependencies: ## Install development tooling
npm install --only=dev
.PHONY: clean
clean: ## Removes all generated code (except _patch.py files)
@printf "=== Cleaning src directory\n"
@find src/pydo -type f ! -name "_patch.py" ! -name "custom_*.py" ! -name "exceptions.py" -exec rm -rf {} +
.PHONY: download-spec
download-spec: ## Download Latest DO Spec
@echo Downloading published spec; \
touch DigitalOcean-public.v2.yaml && \
curl https://api-engineering.nyc3.digitaloceanspaces.com/spec-ci/DigitalOcean-public.v2.yaml -o $(LOCAL_SPEC_FILE)
.PHONY: generate
ifndef SPEC_FILE
generate: SPEC_FILE = $(LOCAL_SPEC_FILE)
generate: dev-dependencies download-spec ## Generates the python client using the latest published spec first.
endif
generate: install clean dev-dependencies
@printf "=== Generating client with spec: $(SPEC_FILE)\n\n"; \
npm run autorest -- client_gen_config.md \
--use:@autorest/modelerfour@$(MODELERFOUR_VERSION) \
--use:@autorest/python@$(AUTOREST_PYTHON_VERSION) \
--package-version=$(PACKAGE_VERSION) \
--input-file=$(SPEC_FILE)
@poetry run black src
.PHONY: install
install: ## Install test dependencies
ifneq (, $(shell which poetry))
poetry install --no-interaction -E aio
else
@(echo "poetry is not installed. See https://python-poetry.org/docs/#installation for more info."; exit 1)
endif
.PHONY: dev
dev: dev-dependencies ## Turns the current terminal into a poetry env
poetry shell
.PHONY: lint-tests
lint-tests: install ## Lints the code
poetry run black --check --diff tests/. && \
poetry run pylint $(PYLINT_ARGS) tests/.
.PHONY: test-mocked
test-mocked: install ## Runs the mock test suite
poetry run pytest -rA --tb=short tests/mocked/. $(PYTEST_ARGS)
.PHONY: test-mocked
test-integration: install ## Runs the integration test suite
poetry run pytest -rA --tb=short tests/integration/. $(PYTEST_EXCLUDE_MARKS) $(PYTEST_ARGS)
.PHONY: test-mocked
test-integration-single: install ## This command runs a single integration test, e.g. > make test-integration-single test=test_actions
poetry run pytest -rA --tb=short tests/integration/. -k $(test)
.PHONY: docker-build
docker-build:
docker build -t pydo:dev .
.PHONY: docker-python
docker-python: docker-build ## Runs a python shell within a docker container
docker run -it --rm --name pydo pydo:dev python
.PHONY: lint-docs
lint-docs:
docker run -v $(ROOT_DIR):/workdir ghcr.io/igorshubovych/markdownlint-cli:latest "*.md"
.PHONY: generate-docs
generate-docs: install ## readthedocs requires a requirements.txt file, this step converts poetry file to requirements.txt file before re-gen the docs
@echo Generating documentation...;
@echo Converting poetry file to requirements.txt...;
poetry export -f requirements.txt -o requirements.txt --without-hashes --with dev
cd docs && \
poetry run sphinx-apidoc -o source/ ../src/pydo && \
poetry run make html
.PHONY: clean-docs
clean-docs: ## Delete everything in docs/build/html
cd docs && \
poetry run make clean
.PHONY: _install_github_release_notes
_install_github_release_notes:
@GO111MODULE=off go get -u github.com/digitalocean/github-changelog-generator
.PHONY: changes
changes: _install_github_release_notes
@echo "==> Merged PRs since last release"
@echo ""
@github-changelog-generator -org digitalocean -repo pydo
.PHONY: version
version:
@poetry version
.PHONY: _install_sembump
_install_sembump:
@echo "=> installing/updating sembump tool"
@echo ""
@GO111MODULE=off go get -u github.com/jessfraz/junk/sembump
.PHONY: bump_version
bump_version: _install_sembump ## Bumps the version
@echo "==> BUMP=${BUMP} bump_version"
@echo ""
@ORIGIN=${ORIGIN} scripts/bumpversion.sh
.PHONY: tag
tag: ## Tags a release
@echo "==> ORIGIN=${ORIGIN} COMMIT=${COMMIT} tag"
@echo ""
@ORIGIN=${ORIGIN} scripts/tag.sh