8000 Update CI tooling · flask-api/flask-api@05a0713 · GitHub
[go: up one dir, main page]

Skip to content

Commit 05a0713

Browse files
committed
Update CI tooling
1 parent f288095 commit 05a0713

File tree

11 files changed

+430
-133
lines changed

11 files changed

+430
-133
lines changed

.gitignore

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,51 @@
1-
.env/
2-
.venv/
3-
env/
4-
dist/
5-
htmlcov/
6-
site/
7-
.tox/
8-
Flask_API.egg-info/
1+
# Temporary Python files
92
*.pyc
3+
*.egg-info
104
__pycache__
11-
.coverage
5+
.ipynb_checkpoints
6+
7+
# Temporary OS files
8+
Icon*
9+
10+
# Temporary virtual environment files
11+
/.cache/
12+
/.venv/
13+
14+
# Temporary server files
15+
.env
16+
*.pid
17+
18+
# Generated documentation
19+
/docs/gen/
20+
/docs/apidocs/
21+
/site/
22+
/*.html
23+
/*.rst
24+
/docs/*.png
25+
26+
# Google Drive
27+
*.gdoc
28+
*.gsheet
29+
*.gslides
30+
*.gdraw
31+
32+
# Testing and coverage results
33+
/.pytest/
34+
/.coverage
35+
/.coverage.*
36+
/htmlcov/
37+
/xmlreport/
38+
/pyunit.xml
39+
/tmp/
40+
*.tmp
41+
42+
# Build and release directories
43+
/build/
44+
/dist/
45+
*.spec
46+
47+
# Sublime Text
48+
*.sublime-workspace
49+
50+
# Eclipse
51+
.settings

.travis.yml

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,37 @@
11
language: python
2-
sudo: false
32

43
python:
5-
- 2.7
6-
- 3.3
7-
- 3.4
8-
- 3.5
4+
- 2.7
5+
- 3.3
6+
- 3.4
7+
- 3.5
8+
- 3.6
99

1010
env:
11+
global:
12+
- RANDOM_SEED=0
13+
- PIPENV_NOSPIN=true
1114
matrix:
1215
- FLASK_VERSION=0.10.1
13-
# TODO: enable when future release is available:
14-
# http://flask.pocoo.org/docs/0.11/changelog/#version-0-10-2
15-
# - FLASK_VERSION=0.10.2
16+
- FLASK_VERSION=0.10.2
1617
- FLASK_VERSION=0.11.0
1718

1819
before_install:
19-
- pip install pipenv
20+
- pip install pipenv~=5.0
2021

2122
install:
22-
- pipenv install --dev --system
23-
- pip install flask==${FLASK_VERSION} # override version for the build matrix
24-
- pip install coverage==3.6
25-
- pip install python-coveralls==2.4.0
26-
- export PYTHONPATH=.
23+
- make install
2724

28-
before_script: coverage erase
25+
script:
26+
- make check
27+
- make test
2928

30-
script: ./runtests
29+
after_success:
30+
- pip install coveralls scrutinizer-ocular
31+
- coveralls
32+
- ocular
3133

32-
after_success: coverage report; coveralls
34+
notifications:
35+
email:
36+
on_success: never
37+
on_failure: never

Makefile

Lines changed: 200 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,223 @@
1+
# Project settings
2+
PROJECT := Flask-API
3+
PACKAGE := flask_api
4+
REPOSITORY := flask-api/flask-api
5+
6+
# Project paths
7+
PACKAGES := $(PACKAGE) tests
8+
CONFIG := $(wildcard *.py)
9+
MODULES := $(wildcard $(PACKAGE)/*.py)
10+
11+
# Python settings
12+
PYTHON_MAJOR ?= 2
13+
PYTHON_MINOR ?= 7
14+
15+
# System paths
16+
PLATFORM := $(shell python -c 'import sys; print(sys.platform)')
17+
ifneq ($(findstring win32, $(PLATFORM)), )
18+
WINDOWS := true
19+
SYS_PYTHON_DIR := C:\\Python$(PYTHON_MAJOR)$(PYTHON_MINOR)
20+
SYS_PYTHON := $(SYS_PYTHON_DIR)\\python.exe
21+
# https://bugs.launchpad.net/virtualenv/+bug/449537
22+
export TCL_LIBRARY=$(SYS_PYTHON_DIR)\\tcl\\tcl8.5
23+
else
24+
ifneq ($(findstring darwin, $(PLATFORM)), )
25+
MAC := true
26+
else
27+
LINUX := true
28+
endif
29+
SYS_PYTHON := python$(PYTHON_MAJOR)
30+
ifdef PYTHON_MINOR
31+
SYS_PYTHON := $(SYS_PYTHON).$(PYTHON_MINOR)
32+
endif
33+
endif
34+
35+
# Virtual environment paths
36+
ENV := .venv
37+
ifneq ($(findstring win32, $(PLATFORM)), )
38+
BIN := $(ENV)/Scripts
39+
ACTIVATE := $(BIN)/activate.bat
40+
OPEN := cmd /c start
41+
PYTHON := $(BIN)/python.exe
42+
PIP := $(BIN)/pip.exe
43+
else
44+
BIN := $(ENV)/bin
45+
ACTIVATE := . $(BIN)/activate
46+
ifneq ($(findstring cygwin, $(PLATFORM)), )
47+
OPEN := cygstart
48+
else
49+
OPEN := open
50+
endif
51+
PYTHON := $(BIN)/python
52+
PIP := $(BIN)/pip
53+
endif
54+
55+
# MAIN TASKS ###################################################################
56+
57+
SNIFFER := pipenv run sniffer
58+
159
.PHONY: all
260
all: install
361

62+
.PHONY: ci
63+
ci: check test ## Run all tasks that determine CI status
64+
65+
.PHONY: watch
66+
watch: install .clean-test ## Continuously run all CI tasks when files chanage
67+
$(SNIFFER)
68+
69+
.PHONY: run ## Start the program
70+
run: install
71+
$(PYTHON) $(PACKAGE)/__main__.py
72+
473
# PROJECT DEPENDENCIES #########################################################
574

675
export PIPENV_SHELL_COMPAT=true
776
export PIPENV_VENV_IN_PROJECT=true
77+
export PIPENV_IGNORE_VIRTUALENVS=true
878

9-
ENV := .venv
1079
DEPENDENCIES := $(ENV)/.installed
11-
PIP := $(ENV)/bin/pip
80+
METADATA := *.egg-info
1281

1382
.PHONY: install
14-
install: $(DEPENDENCIES)
83+
install: $(DEPENDENCIES) $(METADATA)
1584

1685
$(DEPENDENCIES): $(PIP) Pipfile*
17-
pipenv install --dev --ignore-hashes
86+
pipenv install --dev
87+
ifdef WINDOWS
88+
@ echo "Manually install pywin32: https://sourceforge.net/projects/pywin32/files/pywin32"
89+
else ifdef MAC
90+
$(PIP) install pync MacFSEvents
91+
else ifdef LINUX
92+
$(PIP) install pyinotify
93+
endif
94+
@ touch $@
95+
96+
$(METADATA): $(PYTHON) setup.py
97+
$(PYTHON) setup.py develop
1898
@ touch $@
1999

20-
$(PIP):
21-
pipenv --python=python3.6
100+
$(PYTHON) $(PIP):
101+
pipenv --python=$(SYS_PYTHON)
102+
pipenv run pip --version
103+
104+
# CHECKS #######################################################################
105+
106+
FLAKE8 := pipenv run flake8
107+
108+
.PHONY: check
109+
check: flake8 ## Run linters and static analysis
22110

23-
# VALIDATION TARGETS ###########################################################
111+
.PHONY: flake8
112+
flake8: install
113+
$(FLAKE8) flask_api --ignore=E128,E501 --exclude=__init__.py
114+
115+
# TESTS ########################################################################
116+
117+
NOSE := pipenv run nosetests
118+
COVERAGE := pipenv run coverage
119+
COVERAGE_SPACE := pipenv run coverage.space
120+
121+
RANDOM_SEED ?= $(shell date +%s)
122+
123+
NOSE_OPTIONS := --with-doctest
124+
ifndef DISABLE_COVERAGE
125+
NOSE_OPTIONS += --with-coverage --cover-package=$(PACKAGE) --cover-erase --cover-html --cover-html-dir=htmlcov --cover-branches
126+
endif
24127

25128
.PHONY: test
26-
test: install ## Run tests and linters
27-
pipenv run nosetests flask_api
28-
pipenv run flake8 flask_api --ignore=E128,E501 --exclude=__init__.py
129+
test: install ## Run unit and integration tests
130+
$(NOSE) $(PACKAGE) $(NOSE_OPTIONS)
131+
$(COVERAGE_SPACE) $(REPOSITORY) overall
132+
133+
.PHONY: read-coverage
134+
read-coverage:
135+
$(OPEN) coverage/index.html
136+
137+
# DOCUMENTATION ################################################################
138+
139+
MKDOCS := pipenv run mkdocs
140+
141+
MKDOCS_INDEX := site/index.html
142+
143+
.PHONY: doc
144+
doc: mkdocs ## Generate documentation
145+
146+
.PHONY: mkdocs
147+
mkdocs: install $(MKDOCS_INDEX)
148+
$(MKDOCS_INDEX): mkdocs.yml docs/*.md
149+
$(MKDOCS) build --clean --strict
150+
151+
.PHONY: mkdocs-live
152+
mkdocs-live: mkdocs
153+
eval "sleep 3; open http://127.0.0.1:8000" &
154+
$(MKDOCS) serve
155+
156+
# RELEASE ######################################################################
157+
158+
TWINE := pipenv run twine
159+
160+
.PHONY: register
161+
register: dist ## Register the project on PyPI
162+
@ echo NOTE: your project must be registered manually
163+
@ echo https://github.com/pypa/python-packaging-user-guide/issues/263
164+
# TODO: switch to twine when the above issue is resolved
165+
# $(TWINE) register dist/*.whl
166+
167+
.PHONY: upload
168+
upload: .git-no-changes register ## Upload the current version to PyPI
169+
$(TWINE) upload dist/*.*
170+
$(OPEN) https://pypi.python.org/pypi/$(PROJECT)
171+
172+
.PHONY: .git-no-changes
173+
.git-no-changes:
174+
@ if git diff --name-only --exit-code; \
175+
then \
176+
echo Git working copy is clean...; \
177+
else \
178+
echo ERROR: Git working copy is dirty!; \
179+
echo Commit your changes and try again.; \
180+
exit -1; \
181+
fi;
29182

30183
# CLEANUP ######################################################################
31184

32185
.PHONY: clean
33-
clean:
186+
clean: .clean-dist .clean-test .clean-doc .clean-build ## Delete all generated and temporary files
187+
188+
.PHONY: clean-all
189+
clean-all: clean .clean-env .clean-workspace
190+
191+
.PHONY: .clean-build
192+
.clean-build:
193+
find $(PACKAGES) -name '*.pyc' -delete
194+
find $(PACKAGES) -name '__pycache__' -delete
195+
rm -rf *.egg-info
196+
197+
.PHONY: .clean-doc
198+
.clean-doc:
199+
rm -rf README.rst docs/apidocs *.html docs/*.png site
200+
201+
.PHONY: .clean-test
202+
.clean-test:
203+
rm -rf .cache .pytest .coverage htmlcov xmlreport
204+
205+
.PHONY: .clean-dist
206+
.clean-dist:
207+
rm -rf *.spec dist build
208+
209+
.PHONY: .clean-env
210+
.clean-env: clean
34211
rm -rf $(ENV)
212+
213+
.PHONY: .clean-workspace
214+
.clean-workspace:
215+
rm -rf *.sublime-workspace
216+
217+
# HELP #########################################################################
218+
219+
.PHONY: help
220+
help: all
221+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
222+
223+
.DEFAULT_GOAL := help

Pipfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Flask = "~=0.10.1"
88
[dev-packages]
99
nose = "*"
1010
coverage = "~=3.7.1"
11+
"coverage.space" = "*"
1112
flake8 = "~=2.1"
12-
mkdocs = "~=0.12"
13-
tox = "~=2.0"
13+
mkdocs = "==0.12"
14+
sniffer = "*"

0 commit comments

Comments
 (0)
0