Skip to content

Commit

Permalink
test checks
Browse files Browse the repository at this point in the history
  • Loading branch information
devProdigy committed Dec 2, 2020
1 parent 1f9882a commit 8a68e00
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 171 deletions.
70 changes: 24 additions & 46 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
# component: [formatting, builder, cli, client, machine, reporters, serializer, server, util, workflow, allelse]
component: [builder]
component: [formatting, builder, cli, client, machine, reporters, serializer, server, util, workflow, allelse]
python-version: [3.7]
steps:
- uses: actions/checkout@v2
Expand All @@ -36,43 +35,22 @@ jobs:

- name: Install
run: |
#pip install --upgrade pip
#pip install --upgrade pip-tools
#pip uninstall -y aws-sam-cli pyyaml # Workaround for fixing an issue with incompatible package versions
#pip install -r requirements/full_requirements.txt
pip install --upgrade pip
pip install --upgrade pip-tools
pip uninstall -y aws-sam-cli pyyaml # Workaround for fixing an issue with incompatible package versions
pip install -r requirements/full_requirements.txt
pip install .[tests]
# - name: Debug
# run: |
# echo extract_branch - ${{ steps.extract_branch.outputs.branch }}
#
# echo github.event_name - ${{ github.event_name }}
# echo GITHUB_REF - $GITHUB_REF
# echo GITHUB_BASE_REF - $GITHUB_BASE_REF
#
# #git fetch origin ${{ steps.extract_branch.outputs.branch }}
# git fetch origin master
# git branch -a
# git log -25 remotes/origin/master..${{ steps.extract_branch.outputs.branch }}
#
# echo $( git diff origin/master..${{ steps.extract_branch.outputs.branch }} --name-only --diff-filter=AMRC | grep '.py')
# #echo $( git diff origin/master..${{ steps.extract_branch.outputs.branch }} --name-only --diff-filter=AMRC | grep '.py' | xargs black --check)

- name: Get git diff files for Black
shell: bash
run: |
git fetch origin master
git branch -a
git log -25 remotes/origin/master..${{ steps.extract_branch.outputs.branch }}
git diff origin/master..${{ steps.extract_branch.outputs.branch }}
git fetch origin master # needed to make diff on master
echo "##[set-output name=diff_files;]$( git diff origin/master..${{ steps.extract_branch.outputs.branch }} --name-only --diff-filter=AMRC | grep '.py' )"
id: python_git_diff_files

- name: Run code quality checks
# TODO Alex add Legacy code errors first -> https://wemake-python-stylegui.de/en/latest/pages/usage/integrations/flakehell.html#flakehell-legacy
run: |
git diff origin/master..${{ steps.extract_branch.outputs.branch }} | flakehell lint --diff
git diff origin/master..${{ steps.extract_branch.outputs.branch }} | flakehell lint --diff ||
black --check ${{ steps.python_git_diff_files.outputs.diff_files }}
- name: Test ${{ matrix.component }}
Expand Down Expand Up @@ -108,20 +86,20 @@ jobs:
token: fc2844a2-5a6c-43ef-a758-05bc50562b14
fail_ci_if_error: false

# build-docs:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v1
#
# - uses: actions/setup-python@v1
# with:
# python-version: '3.7' # Version range or exact version of a Python version to use, using semvers version range syntax.
# architecture: 'x64'
#
# - name: Install deps
# run: |
# pip install --upgrade pip
# pip install .[docs]
#
# - name: Build Docs
# run: make docs
build-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1

- uses: actions/setup-python@v1
with:
python-version: '3.7' # Version range or exact version of a Python version to use, using semvers version range syntax.
architecture: 'x64'

- name: Install deps
run: |
pip install --upgrade pip
pip install .[docs]
- name: Build Docs
run: make docs
7 changes: 1 addition & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,9 @@ code-quality: flakehell black ## Run code quality tools

flakehell: ## Run flakehell with plugins - only on changed code
git diff | flakehell lint --diff
#git diff --name-only | grep -E '.py$' | xargs flakehell lint

black: ## Run black auto code formatter - only on changed code
git diff ..master '--diff-filter=AMRC' --name-only | grep '.py' | xargs black --check


#git diff --name-only | grep -E ".py$$" | xargs black --check
# $CI_MERGE_REQUEST_TARGET_BRANCH_SHA
git diff --diff-filter=AMRC --name-only | grep '.py' | xargs black --check

test:
python setup.py test
Expand Down
119 changes: 0 additions & 119 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,116 +1,12 @@
[tool.flakehell]
#baseline = "baseline.txt" # TODO remove this after all code will be cleaned # flakehell baseline > baseline.txt
format = "grouped"
#format = "stat"
max_line_length = 120
show_source = true
no-isort-config = true
max-line-complexity = 15

## disable some checks for tests
#[tool.flakehell.exceptions."tests/conftest.py"]
#pycodestyle = ["-E501"] # disable a check
#pycodestyle = ["-*"] # disable a plugin

exclude = [".cache", ".git", "__pycache__", "old", "build", "dist", "junk"]

# TODO Alex this is not supported
ignore = [
"E501",
# "Coding" magic comment
"C101",
# Missing trailing comma in Python 3.6+
"C816",
# Backslash that is used for line breaking
"N400",
# Double quotes forbidding
"Q000",
# Trailing comma, supported by Black
"C812",
"C813",
"C815",
# RST docstrings -- not used
"RST",
# Docstring in `__init__`
"D107",
# Requires all classes to have a base class
"WPS306",
# Requires boolean arguments to be passed as keywords
"WPS425",
# f-strings forbidding
"WPS305",
# relative imports
"WPS300",
# Found context manager with too many assignments - usually good for readability
"WPS316",
# Found incorrect multi-line parameters - handled by black.
"WPS317",
# "Found incorrect order of methods in a class" – requires private methods to be after all
# public ones.
"WPS338",
# "Found shadowed class attribute" - false positive for dataclasses.
"WPS601",
# Found wrong metadata variable: __all__ (???)
"WPS410",
# Found a line that starts with a dot - handled by black
"WPS348",
# Found bad magic module function: __getattr__ (false-positive for class level attributes)
"WPS413",
# "Found too short name" - it's ok for list comprehensions, lambdas etc.
"WPS111",
# Found `finally` in `try` block without `except`
"WPS501",
# "Found subclassing a builtin" - it's required for typed enums.
"WPS600",
# "Found using `@staticmethod`" – static methods are good for self-documenting the code,
# they also provide a little bit of performance optimization.
"WPS602",
# W503 line break before binary operator
"W503",
# Missing parameter(s) in Docstring: - ctx
"DAR101",
# Missing docstring in magic method
"D105",
# Missing "Returns" in Docstring:
"DAR201",
# Missing "Yields" in Docstring
"DAR301",
# Missing exception(s) in Raises section
"DAR401",
# Found `%` string formatting
"WPS323",
# Found an unnecessary blank line before a bracket - handled by Black
"WPS355",
]


#per-file-ignores=
# # S101 - using asserts.
# # D103 - test docstrings.
# # DAR101 Missing parameter(s) in Docstring
# # N400 - found backslash that is used for line breaking.
# # WPS202 - found overused expression.
# # WPS204 - found too many module members.
# # WPS226 - found string constant over-use.
# # WPS430 - "found nested function" for functional decorators.
# # WPS432 - Found magic number.
# # WPS441 - "found control variable used after block" - normal for mock patches.
# # WPS442 - "found outer scope names shadowing" for fixtures.
# # WPS520 - "found compare with falsy constant"
# # WPS609 - "direct magic attribute usage" for MagicMock
# # C412 - Unnecessary set comprehension - 'in' can take a generator.
# ./tests/test_*.py:S101,D103,WPS202,WPS204,WPS226,WPS430,WPS432,WPS441,WPS442,WPS520,WPS600,WPS609,DAR101,C412
# ./tests/**/test_*.py:S101,D103,WPS202,WPS204,WPS226,WPS430,WPS432,WPS441,WPS442,WPS520,WPS600,WPS609,DAR101,C412
#
# # WPS442 - Found outer scope names shadowing.
# # S101 - using asserts.
# # S608 - Possible SQL injection.
# ./tests/conftest.py:WPS442,S101,S608
#
# # Bulk imports, module docstring
# ./*/__init__.py:WPS412,WPS440,F,D104


[tool.flakehell.plugins]
flake8-broken-line = ["+*"]
flake8-bugbear = ["+*"]
Expand All @@ -129,21 +25,6 @@ pep8-naming = ["+*"]
pycodestyle = ["+*"]
pyflakes = ["+*"]

#
# image: python:3.7
# script:
# - pip3 install flakehell
# - flakehell lint --format=gitlab --output-file flakehell.json
# artifacts:
# reports:
# codequality: flakehell.json

# github actions: https://wemake-python-stylegui.de/en/latest/pages/usage/integrations/github-actions.html

#git diff | flakehell lint --diff my_project/
#https://flakehell.readthedocs.io/commands/baseline.html


[tool.black]
line-length = 120
target-version = ['py37']
Expand Down

0 comments on commit 8a68e00

Please sign in to comment.