Skip to content

Commit e8d0ecb

Browse files
tobywfaygold92
authored andcommitted
Pre-commit hook for linting, testing
1 parent db26ec5 commit e8d0ecb

File tree

6 files changed

+112
-1
lines changed

6 files changed

+112
-1
lines changed

.coveragerc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[run]
2+
branch = True
3+
omit = */contract/suite/*
4+
5+
[report]
6+
fail_under = 99

.pre-commit-config.yaml

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
exclude: ^(buildspec.yml|.pre-commit-config.yaml)$
2+
repos:
3+
- repo: https://github.com/pre-commit/pre-commit-hooks
4+
rev: v2.0.0
5+
hooks:
6+
- id: check-case-conflict
7+
- id: end-of-file-fixer
8+
- id: mixed-line-ending
9+
args:
10+
- --fix=lf
11+
- id: trailing-whitespace
12+
- id: flake8
13+
additional_dependencies:
14+
- flake8-bugbear>=19.3.0
15+
- flake8-builtins>=1.4.1
16+
- flake8-commas>=2.0.0
17+
- flake8-comprehensions>=2.1.0
18+
- flake8-debugger>=3.1.0
19+
- flake8-pep3101>=1.2.1
20+
# language_version: python3.6
21+
- id: pretty-format-json
22+
args:
23+
- --autofix
24+
- --indent=4
25+
- --no-sort-keys
26+
- id: check-merge-conflict
27+
- id: check-yaml
28+
- repo: https://github.com/pre-commit/mirrors-isort
29+
rev: v4.3.17
30+
hooks:
31+
- id: isort
32+
# language_version: python3.6
33+
- repo: https://github.com/ambv/black
34+
rev: stable
35+
hooks:
36+
- id: black
37+
# language_version: python3.6
38+
- repo: https://github.com/pre-commit/pygrep-hooks
39+
rev: v1.3.0
40+
hooks:
41+
- id: python-check-blanket-noqa
42+
- id: python-check-mock-methods
43+
- id: python-no-log-warn
44+
- repo: https://github.com/PyCQA/bandit
45+
rev: f5a6f0ca62 # TODO: update once a release > 1.5.1 hits with this change in
46+
hooks:
47+
- id: bandit
48+
files: "^python/"
49+
- repo: local
50+
hooks:
51+
- id: pylint-local
52+
name: pylint-local
53+
description: Run pylint in the local virtualenv
54+
entry: pylint "setup.py" "python/" "tests/"
55+
language: system
56+
# ignore all files, run on hard-coded modules instead
57+
exclude: "^."
58+
always_run: true
59+
- id: pytest-local
60+
name: pytest-local
61+
description: Run pytest in the local virtualenv
62+
entry: pytest --cov=rpdk.java --doctest-modules tests/
63+
language: system
64+
# ignore all files, run on hard-coded modules instead
65+
exclude: "^."
66+
always_run: true

.pylintrc

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[MASTER]
2+
3+
ignore=CVS
4+
jobs=1
5+
persistent=yes
6+
7+
[MESSAGES CONTROL]
8+
9+
disable=
10+
missing-docstring, # not everything needs a docstring
11+
fixme, # work in progress
12+
bad-continuation, # clashes with black
13+
duplicate-code, # finds dupes between tests and plugins
14+
too-few-public-methods, # triggers when inheriting
15+
ungrouped-imports, # clashes with isort
16+
17+
[BASIC]
18+
19+
good-names=e,ex,f,fp,i,j,k,n,_
20+
21+
[FORMAT]
22+
23+
indent-string=' '
24+
max-line-length=88

buildspec.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ phases:
33
install:
44
commands:
55
# make sure pip/setuptools/wheel is up to date
6-
- pip install --upgrade pip setuptools wheel
6+
- pip install --upgrade pip setuptools wheel -r requirements.txt
77
- mkdir "$CODEBUILD_SRC_DIR/artifacts"
88
build:
99
commands:
10+
- pre-commit run --all-files
1011
# install aws-cloudformation-rpdk
1112
- cd "$CODEBUILD_SRC_DIR_RPDK"
1213
- python3 setup.py sdist bdist_wheel

requirements.txt

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# better interactive session, debugger
2+
ipython>=7.4.0
3+
ipdb>=0.12
4+
5+
# testing tools
6+
pylint>=2.3.1
7+
coverage>=4.5.3
8+
pytest>=4.4.0
9+
pytest-cov>=2.6.1
10+
pytest-random-order>=1.0.4
11+
12+
# commit hooks
13+
pre-commit>=1.15.2

setup.cfg

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ include_trailing_comma = true
2929
combine_as_imports = True
3030
force_grid_wrap = 0
3131
known_first_party = rpdk
32+
known_third_party = boto3,botocore,jinja2,jsonschema,werkzeug,yaml,requests
3233

3334
[tool:pytest]
3435
# can't do anything about 3rd party modules, so don't spam us

0 commit comments

Comments
 (0)