Skip to content

Commit 612bfb5

Browse files
author
Dmitry Berezovsky
committed
Started incorporating more advanced build process
1 parent 7858dd5 commit 612bfb5

25 files changed

+591
-309
lines changed

Makefile

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
VIRTUAL_ENV_PATH=venv
2+
SKIP_VENV="${NO_VENV}"
3+
PYPI_API_KEY :=
4+
PYPI_REPOSITORY_URL :=
5+
ALPHA_VERSION :=
6+
7+
.DEFAULT_GOAL := pre_commit
8+
9+
pre_commit: copyright format lint
10+
11+
copyright:
12+
@( \
13+
if [ -z $(SKIP_VENV) ]; then source $(VIRTUAL_ENV_PATH)/bin/activate; fi; \
14+
echo "Applying copyright..."; \
15+
./development/copyright-update; \
16+
echo "DONE: copyright"; \
17+
)
18+
19+
flake8:
20+
@( \
21+
set -e; \
22+
if [ -z $(SKIP_VENV) ]; then source $(VIRTUAL_ENV_PATH)/bin/activate; fi; \
23+
echo "Runing Flake8 checks..."; \
24+
flake8 ./src/healthcheckbot --count --statistics; \
25+
echo "DONE: Flake8"; \
26+
)
27+
28+
mypy:
29+
@( \
30+
set -e; \
31+
if [ -z $(SKIP_VENV) ]; then source $(VIRTUAL_ENV_PATH)/bin/activate; fi; \
32+
echo "Runing MyPy checks..."; \
33+
#mypy --show-error-codes ./src/healthcheckbot; \
34+
echo "DONE: MyPy"; \
35+
)
36+
37+
lint: flake8 mypy
38+
39+
build: copyright format lint clean
40+
@( \
41+
set -e; \
42+
if [ -z $(SKIP_VENV) ]; then source $(VIRTUAL_ENV_PATH)/bin/activate; fi; \
43+
echo "Building wheel package..."; \
44+
bash -c "cd src && VERSION_OVERRIDE="$(ALPHA_VERSION)" python ./setup.py bdist_wheel --dist-dir=../dist --bdist-dir=../../build"; \
45+
echo "DONE: wheel package"; \
46+
)
47+
@( \
48+
set -e; \
49+
if [ -z $(SKIP_VENV) ]; then source $(VIRTUAL_ENV_PATH)/bin/activate; fi; \
50+
echo "Building source distribution..."; \
51+
bash -c "cd src && VERSION_OVERRIDE="$(ALPHA_VERSION)" python ./setup.py sdist --dist-dir=../dist"; \
52+
echo "DONE: source distribution"; \
53+
)
54+
55+
clean:
56+
@(rm -rf src/build dist/* *.egg-info src/*.egg-info .pytest_cache)
57+
58+
format:
59+
@( \
60+
if [ -z $(SKIP_VENV) ]; then source $(VIRTUAL_ENV_PATH)/bin/activate; fi; \
61+
echo "Runing Black code formater..."; \
62+
black ./src/healthcheckbot; \
63+
echo "DONE: Black"; \
64+
)
65+
66+
publish:
67+
@( \
68+
set -e; \
69+
if [ -z $(SKIP_VENV) ]; then source $(VIRTUAL_ENV_PATH)/bin/activate; fi; \
70+
if [ ! -z $(PYPI_API_KEY) ]; then export TWINE_USERNAME="__token__"; export TWINE_PASSWORD="$(PYPI_API_KEY)"; fi; \
71+
if [ ! -z $(PYPI_REPOSITORY_URL) ]; then export TWINE_REPOSITORY_URL="$(PYPI_REPOSITORY_URL)"; fi; \
72+
echo "Uploading to PyPi"; \
73+
twine upload -r pypi dist/*; \
74+
echo "DONE: Publish"; \
75+
)
76+
77+
set-version:
78+
@( \
79+
if [ -z $(VERSION) ]; then echo "Missing VERSION argument"; exit 1; fi; \
80+
echo '__version__ = "$(VERSION)"' > ./src/healthcheckbot/__version__.py; \
81+
echo "Version updated: $(VERSION)"; \
82+
)

pyproject.toml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[tool.black]
2+
line-length = 120
3+
target-version = ['py37']
4+
exclude = '''
5+
(
6+
/(
7+
\.eggs # exclude a few common directories in the
8+
| \.git # root of the project
9+
| \.mypy_cache
10+
| \.tox
11+
| \.venv
12+
| _build
13+
| buck-out
14+
| build
15+
| dist
16+
)/
17+
)
18+
'''

requirements.txt

+7-5
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ beautifulsoup4==4.4.0
55
graypy==0.3.2
66
daemons==1.3.0
77

8-
# Contrib
9-
redis==3.2.1
10-
psycopg2==2.8.4
11-
128
# Development dependencies
139
copyright==1.0.1.0
1410
twine==1.13.0
1511
m2r==0.2.1
16-
nose2==0.8.0
12+
nose2==0.8.0
13+
black==20.8b1
14+
flake8==3.8.4
15+
mypy>=0.7
16+
17+
# Contrib
18+
-r contrib-dependencies.txt

setup.cfg

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
[flake8]
2+
max-complexity = 12
3+
max-line-length=122
4+
5+
exclude =
6+
# No need to traverse our git directory
7+
.git,
8+
# There's no value in checking cache directories
9+
__pycache__,
10+
# This contains our built documentation
11+
build,
12+
# This contains builds of flake8 that we don't want to check
13+
dist,
14+
*.egg-info,
15+
# Test / internal files
16+
_client_test.py
17+
18+
ignore =
19+
# W291 trailing whitespace
20+
W291,
21+
# W391 blank line at end of file
22+
W391,
23+
# E501: line too long
24+
E501,
25+
# W503: Line break occurred before a binary operator
26+
W503,
27+
# E203: Whitespace before ':'
28+
E203,
29+
# D202 No blank lines allowed after function docstring
30+
D202,
31+
# W504 line break after binary operator
32+
W504
33+
34+
per-file-ignores =
35+
# imported but unused
36+
__init__.py: F401
37+
38+
[mypy]
39+
python_version = 3.7
40+
show_error_codes = true
41+
ignore_errors = false
42+
warn_return_any = true
43+
ignore_missing_imports = True
44+
disallow_any_generics = false
45+
pretty = true
46+
47+
[mypy-examples]
48+
ignore_errors = true
49+
follow_imports = silent
50+
ignore_missing_imports = true

src/healthcheckbot/__init__.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
# Healthcheck Bot
22
# Copyright (C) 2018 Dmitry Berezovsky
3-
#
3+
#
44
# HealthcheckBot is free software: you can redistribute it and/or modify
55
# it under the terms of the GNU General Public License as published by
66
# the Free Software Foundation, either version 3 of the License, or
77
# (at your option) any later version.
8-
#
8+
#
99
# HealthcheckBot is distributed in the hope that it will be useful,
1010
# but WITHOUT ANY WARRANTY; without even the implied warranty of
1111
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212
# GNU General Public License for more details.
13-
#
13+
#
1414
# You should have received a copy of the GNU General Public License
1515
# along with this program. If not, see <http://www.gnu.org/licenses/>.
16-

src/healthcheckbot/version.py src/healthcheckbot/__version__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# Healthcheck Bot
22
# Copyright (C) 2018 Dmitry Berezovsky
3-
#
3+
#
44
# HealthcheckBot is free software: you can redistribute it and/or modify
55
# it under the terms of the GNU General Public License as published by
66
# the Free Software Foundation, either version 3 of the License, or
77
# (at your option) any later version.
8-
#
8+
#
99
# HealthcheckBot is distributed in the hope that it will be useful,
1010
# but WITHOUT ANY WARRANTY; without even the implied warranty of
1111
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212
# GNU General Public License for more details.
13-
#
13+
#
1414
# You should have received a copy of the GNU General Public License
1515
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

src/healthcheckbot/app.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
# Healthcheck Bot
44
# Copyright (C) 2018 Dmitry Berezovsky
5-
#
5+
#
66
# HealthcheckBot is free software: you can redistribute it and/or modify
77
# it under the terms of the GNU General Public License as published by
88
# the Free Software Foundation, either version 3 of the License, or
99
# (at your option) any later version.
10-
#
10+
#
1111
# HealthcheckBot is distributed in the hope that it will be useful,
1212
# but WITHOUT ANY WARRANTY; without even the implied warranty of
1313
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414
# GNU General Public License for more details.
15-
#
15+
#
1616
# You should have received a copy of the GNU General Public License
1717
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818

@@ -26,7 +26,7 @@
2626
from healthcheckbot.common.bootstrap import bootstrap
2727
from healthcheckbot.common.utils import CLI
2828

29-
logger = logging.getLogger('App')
29+
logger = logging.getLogger("App")
3030

3131

3232
def run_application(config: dict, application: ApplicationManager = None):
@@ -42,7 +42,7 @@ def run_application(config: dict, application: ApplicationManager = None):
4242
exit()
4343

4444

45-
if __name__ == '__main__':
45+
if __name__ == "__main__":
4646
logging.basicConfig(level=logging.DEBUG)
4747
try:
4848
config = cli.read_config_from_arguments()

src/healthcheckbot/assertions.py

+15-11
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# Healthcheck Bot
22
# Copyright (C) 2018 Dmitry Berezovsky
3-
#
3+
#
44
# HealthcheckBot is free software: you can redistribute it and/or modify
55
# it under the terms of the GNU General Public License as published by
66
# the Free Software Foundation, either version 3 of the License, or
77
# (at your option) any later version.
8-
#
8+
#
99
# HealthcheckBot is distributed in the hope that it will be useful,
1010
# but WITHOUT ANY WARRANTY; without even the implied warranty of
1111
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212
# GNU General Public License for more details.
13-
#
13+
#
1414
# You should have received a copy of the GNU General Public License
1515
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

@@ -22,18 +22,22 @@
2222

2323

2424
class TitleAssert(WatcherAssert):
25-
2625
def __init__(self, application):
2726
super().__init__(application)
2827
self.expected_title = None
2928

30-
def do_assert(self, state: requests.Response, reporter: ValidationReporter, assertion_name: str):
31-
soup = BeautifulSoup(state.content, 'html.parser')
29+
def do_assert(
30+
self,
31+
state: requests.Response,
32+
reporter: ValidationReporter,
33+
assertion_name: str,
34+
):
35+
soup = BeautifulSoup(state.content, "html.parser")
3236
actual_title = soup.title.string if soup.title else None
3337
if actual_title != self.expected_title:
34-
reporter.error(assertion_name,
35-
'Expected title is "{}" but actual is "{}"'.format(self.expected_title, actual_title))
38+
reporter.error(
39+
assertion_name,
40+
'Expected title is "{}" but actual is "{}"'.format(self.expected_title, actual_title),
41+
)
3642

37-
PARAMS = (
38-
ParameterDef('expected_title', is_required=True, validators=(validators.string,)),
39-
)
43+
PARAMS = (ParameterDef("expected_title", is_required=True, validators=(validators.string,)),)

0 commit comments

Comments
 (0)