Skip to content

Commit 429a3ab

Browse files
authored
Merge pull request #3 from CroudTech/feature/tests_and_compliance
Add precommit
2 parents c37024a + 6c89eb9 commit 429a3ab

28 files changed

+1606
-935
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
*.egg-info
22
dist
33
test-output.xml
4-
__pycache__
4+
__pycache__

.pre-commit-config.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
repos:
2+
- repo: https://github.com/psf/black
3+
rev: 22.3.0
4+
hooks:
5+
- id: black
6+
language_version: python3.9
7+
- repo: https://github.com/pre-commit/pre-commit-hooks
8+
rev: v4.2.0
9+
hooks:
10+
- id: check-merge-conflict
11+
- id: end-of-file-fixer
12+
- id: requirements-txt-fixer
13+
- id: mixed-line-ending
14+
args: [--fix=no]
15+
- repo: https://github.com/pycqa/flake8
16+
rev: 5.0.4
17+
hooks:
18+
- id: flake8
19+
args: [--config, setup.cfg]
20+
- repo: https://github.com/pycqa/bandit
21+
rev: 1.7.4
22+
hooks:
23+
- id: bandit
24+
args: [--skip, "B101", --recursive]
25+
- repo: https://github.com/pre-commit/mirrors-prettier
26+
rev: v2.6.2
27+
hooks:
28+
- id: prettier
29+
- repo: https://github.com/pycqa/isort
30+
rev: 5.8.0
31+
hooks:
32+
- id: isort
33+
name: isort (python)

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
include requirements.txt
1+
include requirements.txt

Makefile

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# ENV defaults to local (so that requirements/local.txt are installed), but can be overridden
2+
# (e.g. ENV=production make setup).
3+
ENV ?= local
4+
# PYTHON specifies the python binary to use when creating virtualenv
5+
PYTHON ?= python3.9
6+
7+
# Editor can be defined globally but defaults to nano
8+
EDITOR ?= nano
9+
10+
# By default we open the editor after copying settings, but can be overridden
11+
# (e.g. EDIT_SETTINGS=no make settings).
12+
EDIT_SETTINGS ?= yes
13+
14+
# Get root dir and project dir
15+
PROJECT_ROOT ?= $(PWD)
16+
SITE_ROOT ?= $(PROJECT_ROOT)
17+
18+
BLACK ?= \033[0;30m
19+
RED ?= \033[0;31m
20+
GREEN ?= \033[0;32m
21+
YELLOW ?= \033[0;33m
22+
BLUE ?= \033[0;34m
23+
PURPLE ?= \033[0;35m
24+
CYAN ?= \033[0;36m
25+
GRAY ?= \033[0;37m
26+
COFF ?= \033[0m
27+
28+
.PHONY: all help setup pycharm coverage test clean
29+
.PHONY: isort isort-fix quality flake8
30+
31+
32+
all: help
33+
34+
35+
help:
36+
@echo "+------<<<< Configuration >>>>------+"
37+
@echo ""
38+
@echo "ENV: $(ENV)"
39+
@echo "PYTHON: $(PYTHON)"
40+
@echo "PROJECT_ROOT: $(PROJECT_ROOT)"
41+
@echo "SITE_ROOT: $(SITE_ROOT)"
42+
@echo ""
43+
@echo "+------<<<< Tasks >>>>------+"
44+
@echo ""
45+
@echo "$(CYAN)make pycharm$(COFF) - Copies default PyCharm settings (unless they already exist)"
46+
@echo ""
47+
@echo "$(CYAN)make test$(COFF) - Runs automatic tests on your python code"
48+
@echo ""
49+
@echo "$(CYAN)make coverage$(COFF) - Runs code test coverage calculation"
50+
@echo ""
51+
@echo "$(CYAN)make quality$(COFF) - Runs automatic code quality tests on your code"
52+
@echo ""
53+
54+
55+
56+
pycharm: $(PROJECT_ROOT)/.idea
57+
58+
59+
$(PROJECT_ROOT)/.idea:
60+
@echo "$(CYAN)Creating pycharm settings from template$(COFF)"
61+
@mkdir -p $(PROJECT_ROOT)/.idea && cp -R $(PROJECT_ROOT)/.idea_template/* $(PROJECT_ROOT)/.idea/
62+
63+
64+
settings: $(PROJECT_ROOT)/.env
65+
66+
67+
coverage:
68+
@echo "$(CYAN)Running automatic code coverage check$(COFF)"
69+
@coverage run -m py.test
70+
@coverage html
71+
@coverage report
72+
73+
pre-commit:
74+
@echo "$(CYAN)Running pre-commit routine$(COFF)"
75+
pipenv run pre-commit run --all-files
76+
make flake8
77+
78+
test: clean
79+
@echo "$(CYAN)Running automatic tests$(COFF)"
80+
@py.test --disable-warnings
81+
82+
83+
clean:
84+
@echo "$(CYAN)Cleaning pyc files$(COFF)"
85+
@cd $(SITE_ROOT) && find . -name "*.pyc" -exec rm -rf {} \;
86+
87+
88+
isort:
89+
@echo "$(CYAN)Checking imports with isort$(COFF)"
90+
isort --recursive --check-only -p . --diff
91+
92+
93+
isort-fix:
94+
@echo "$(CYAN)Fixing imports with isort$(COFF)"
95+
isort --recursive -p .
96+
97+
98+
quality: flake8 isort
99+
100+
101+
flake8:
102+
@echo "$(CYAN)Running flake8$(COFF)"
103+
@flake8
104+
105+
106+
docker-django:
107+
$(cmd)

Pipfile

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,25 @@ name = "pypi"
66
[packages]
77
click = "*"
88
redis = "*"
9-
boto3 = "*"
9+
boto3 = "~=1.2"
1010
pyyaml = "*"
11-
boto3-stubs = {extras = ["secretsmanager"], version = "*"}
1211
table2ascii = "*"
12+
types-pyyaml = "*"
1313

1414
[dev-packages]
1515
autopep8 = "*"
16+
black = "*"
17+
boto3-stubs = {extras = ["secretsmanager", "s3"], version = "*"}
1618
build = "*"
19+
deepdiff = "*"
20+
flake8 = "*"
21+
flake8-bugbear = "*"
22+
isort = "*"
23+
pre-commit = "*"
24+
pytest = "*"
25+
pytest-cov = "*"
26+
pytest-mock = "*"
27+
pytest-xdist = "*"
1728
twine = "*"
1829

1930
[requires]

0 commit comments

Comments
 (0)