-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
154 lines (122 loc) · 4.48 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# Makefile for packaging and testing pytest_pgsql
#
# This Makefile has the following targets:
#
# pyenv - Sets up pyenv and a virtualenv that is automatically used
# deactivate_pyenv - Deactivates the pyenv setup
# dependencies - Installs all dependencies for a project (including mac dependencies)
# setup - Sets up the entire development environment (pyenv and dependencies)
# clean_docs - Clean the documentation folder
# clean - Clean any generated files (including documentation)
# open_docs - Open any docs generated with "make docs"
# docs - Generated sphinx docs
# validate - Run code validation
# test - Run tests
# run - Run any services for local development (databases, CSS compiliation, airflow, etc)
# version - Show the version of the package
OS = $(shell uname -s)
PACKAGE_NAME=pytest_pgsql
MODULE_NAME=pytest_pgsql
ifdef CIRCLECI
TOX_POSARGS=-- --junitxml={env:CIRCLE_TEST_REPORTS}/pytest_pgsql/junit.xml
# Use CircleCIs version
PYTHON_VERSION=
# Dont log pip install output since it can print the private repo url
PIP_INSTALL_CMD=pip install -q
# Do local installs without editable mode because of issues with CircleCI's venv
PIP_LOCAL_INSTALL_CMD=pip install -q .
else
TOX_POSARGS=
PIP_INSTALL_CMD=pip install
PIP_LOCAL_INSTALL_CMD=pip install -e .
endif
# Print usage of main targets when user types "make" or "make help"
help:
@echo "Please choose one of the following targets: \n"\
" setup: Setup your development environment and install dependencies\n"\
" test: Run tests\n"\
" validate: Validate code and documentation\n"\
" docs: Build Sphinx documentation\n"\
" open_docs: Open built documentation\n"\
"\n"\
"View the Makefile for more documentation about all of the available commands"
@exit 2
# Sets up pyenv and the virtualenv that is managed by pyenv
.PHONY: pyenv
pyenv:
ifeq (${OS}, Darwin)
brew install pyenv pyenv-virtualenv 2> /dev/null || true
# Ensure we remain up to date with pyenv so that new python versions are available for installation
brew upgrade pyenv pyenv-virtualenv 2> /dev/null || true
endif
# Install all supported Python versions. There are more recent patch releases
# for most of these but CircleCI doesn't have them preinstalled. Installing a
# version of Python that isn't preinstalled slows down the build significantly.
#
# If you don't have these installed yet it's going to take a long time, but
# you'll only need to do it once.
pyenv install -s 3.6.2
pyenv install -s 3.5.2
pyenv install -s 3.4.4
# Set up the environments for Tox
pyenv local 3.6.2 3.5.2 3.4.4
# Deactivates pyenv and removes it from auto-using the virtualenv
.PHONY: deactivate_pyenv
deactivate_pyenv:
rm .python-version
# Builds all dependencies for a project
.PHONY: dependencies
dependencies:
${PIP_INSTALL_CMD} -U -r dev_requirements.txt # Use -U to ensure requirements are upgraded every time
${PIP_INSTALL_CMD} -r test_requirements.txt
${PIP_LOCAL_INSTALL_CMD}
pip check
# Performs the full development environment setup
.PHONY: setup
setup: pyenv dependencies
# Clean the documentation folder
.PHONY: clean_docs
clean_docs:
cd docs && make clean
# Clean any auto-generated files
.PHONY: clean
clean: clean_docs
python setup.py clean
rm -rf build/
rm -rf dist/
rm -rf *.egg*/
rm -rf __pycache__/
rm -f MANIFEST
find ${PACKAGE_NAME} -type f -name '*.pyc' -delete
rm -rf coverage .coverage .coverage*
# Open the build docs (only works on Mac)
.PHONY: open_docs
open_docs:
open docs/_build/html/index.html
# Build Sphinx autodocs
.PHONY: docs
docs: clean_docs # Ensure docs are clean, otherwise weird render errors can result
sphinx-apidoc -f -e -M -o docs/ pytest_pgsql 'pytest_pgsql/tests' 'pytest_pgsql/version.py' && cd docs && make html
# Run code validation
.PHONY: validate
validate:
flake8 -v ${MODULE_NAME}/
pylint ${MODULE_NAME}
make docs # Ensure docs can be built during validation
# Run tests
.PHONY: test
test:
tox ${TOX_POSARGS}
coverage report
.PHONY: test_single_version
test_single_version:
coverage run -a -m pytest --pg-conf-opt="track_commit_timestamp=True" --pg-extensions=btree_gin,,btree_gist pytest_pgsql/tests
# Run any services for local development. For example, docker databases, CSS compilation watching, etc
.PHONY: run
run:
@echo "No services need to be running for local development"
# Distribution helpers for determining the version of the package
VERSION=$(shell python setup.py --version | sed 's/\([0-9]*\.[0-9]*\.[0-9]*\).*$$/\1/')
.PHONY: version
version:
@echo ${VERSION}