forked from rackspace/runway
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
124 lines (99 loc) · 6 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
.PHONY: help list sync sync_two sync_all pipenv_lock clean fix-isort lint lint-flake8 lint-isort lint-pylint lint_two test test-integration test-unit test_shim create_tfenv_ver_file build build_pyinstaller_file build_pyinstaller_folder build_whl release npm_prep
help: ## show this message
@IFS=$$'\n' ; \
help_lines=(`fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##/:/'`); \
printf "%-30s %s\n" "target" "help" ; \
printf "%-30s %s\n" "------" "----" ; \
for help_line in $${help_lines[@]}; do \
IFS=$$':' ; \
help_split=($$help_line) ; \
help_command=`echo $${help_split[0]} | sed -e 's/^ *//' -e 's/ *$$//'` ; \
help_info=`echo $${help_split[2]} | sed -e 's/^ *//' -e 's/ *$$//'` ; \
printf '\033[36m'; \
printf "%-30s %s" $$help_command ; \
printf '\033[0m'; \
printf "%s\n" $$help_info; \
done
list: ## list all targets in this Makefile
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$'
sync: ## create a python virtual environment in the project for development
PIPENV_VENV_IN_PROJECT=1 pipenv sync --dev
pipenv run pre-commit install
# changes that need to be made inorder to sync python two (may also require deletion of the existing lock file)
sync_two: ## create a python virtual environment in the project for python 2 development
PIPENV_VENV_IN_PROJECT=1 pipenv install "astroid<2.0" "pylint<2.0" "pydocstyle<4.0.0" --dev --skip-lock
sync_all: sync ## sync all virtual environments used by this project with their Pipfile.lock
pushd docs && PIPENV_VENV_IN_PROJECT=1 pipenv sync --dev --three && popd
pushd integration_tests && PIPENV_VENV_IN_PROJECT=1 pipenv sync --dev --three && popd
pushd integration_test_infrastructure && PIPENV_VENV_IN_PROJECT=1 pipenv sync --dev --three && popd
pipenv_lock: ## update all Pipfile.lock's used by this project
pipenv lock --dev
pushd docs && pipenv lock --dev && popd
pushd integration_tests && pipenv lock --dev && popd
pushd integration_test_infrastructure && pipenv lock --dev && popd
clean: ## remove generated file from the project directory
rm -rf build/
rm -rf dist/
rm -rf runway.egg-info/
rm -rf tmp/
rm -rf src/
rm -rf package.json postinstall.js preuninstall.js .coverage .npmignore
fix-isort: ## automatically fix all isort errors
@pipenv run isort . --recursive --atomic
lint: lint-isort lint-flake8 lint-pylint ## run all linters
lint-flake8: ## run flake8
@echo "Running flake8..."
@pipenv run flake8 --exclude=runway/embedded,runway/templates runway --docstring-convention=all
@echo ""
lint-isort: ## run isort
@echo "Running isort... If this fails, run 'make fix-isort' to resolve."
@pipenv run isort . --recursive --check-only
@echo ""
lint-pylint: ## run pylint
@echo "Running pylint (excluding blueprints & template)..."
@find runway -name '*.py' -not -path 'runway/embedded*' -not -path 'runway/templates/stacker/*' -not -path 'runway/templates/cdk-py/*' -not -path 'runway/blueprints/*' | xargs pipenv run pylint --rcfile=.pylintrc
@echo "Running pylint (--disable=duplicate-code)..."
@find runway/blueprints -name '*.py' | xargs pipenv run pylint --disable=duplicate-code
@echo ""
# linting for python 2, requires additional disables
lint_two: ## run all linters (python 2 only)
pipenv run flake8 --exclude=runway/embedded,runway/templates --ignore=D101,D403,E124,W504 runway
find runway -name '*.py' -not -path 'runway/embedded*' -not -path 'runway/templates/stacker/*' -not -path 'runway/templates/cdk-py/*' -not -path 'runway/blueprints/*' | xargs pipenv run pylint --rcfile=.pylintrc --disable=bad-option-value,duplicate-code,method-hidden,relative-import
test: ## run integration and unit tests
@echo "Running integration & unit tests..."
@pipenv run pytest --cov=runway --cov-report term:skip-covered --integration
test-functional: ## run function tests only
@echo "Running functional tests..."
@pipenv run pytest --functional --no-cov
test-integration: ## run integration tests only
@echo "Running integration tests..."
@pipenv run pytest --cov=runway --cov-report term:skip-covered --integration-only
test-unit: ## run unit tests only
@echo "Running unit tests..."
@pipenv run pytest --cov=runway --cov-config=tests/unit/.coveragerc --cov-report term-missing
test_shim: ## run a test for the stacker shim
bash ./.github/scripts/cicd/test_shim.sh
create_tfenv_ver_file: ## create a tfenv version file using the latest version
curl --silent https://releases.hashicorp.com/index.json | jq -r '.terraform.versions | to_entries | map(select(.key | contains ("-") | not)) | sort_by(.key | split(".") | map(tonumber))[-1].key' | egrep -o '^[0-9]*\.[0-9]*\.[0-9]*' > runway/templates/terraform/.terraform-version
build: clean create_tfenv_ver_file ## build the PyPi release
python setup.py sdist
build_pyinstaller_file: clean create_tfenv_ver_file ## build Pyinstaller single file release (github)
bash ./.github/scripts/cicd/build_pyinstaller.sh file
build_pyinstaller_folder: clean create_tfenv_ver_file ## build Pyinstaller folder release(github)
bash ./.github/scripts/cicd/build_pyinstaller.sh folder
build_whl: clean create_tfenv_ver_file ## build wheel
python setup.py bdist_wheel --universal
release: clean create_tfenv_ver_file build # publish to PyPi
twine upload dist/*
curl -D - -X PURGE https://pypi.org/simple/runway
# requires setuptools-scm and setuptools global python installs
# copies artifacts to src & npm package files to the root of the repo
# updates package.json with the name of the package & semver version from scm (formated for npm)
npm_prep: ## process that needs to be run before creating an npm package
mkdir -p tmp
mkdir -p src
cp -r artifacts/$$(python ./setup.py --version)/* src/
cp npm/* . && cp npm/.[^.]* .
jq ".version = \"$${NPM_PACKAGE_VERSION:-$$(python ./setup.py --version | sed -E "s/\.dev/-dev/")}\"" package.json > tmp/package.json
jq ".name = \"$${NPM_PACKAGE_NAME-undefined}\"" tmp/package.json > package.json
rm -rf tmp/package.json