Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Linting - Tests

on: [push]
on: [push, pull_request]

jobs:
lint:
Expand All @@ -12,6 +12,9 @@ jobs:
toxenv: [pep8, isort, black, pypi-description, docs, towncrier]
steps:
- uses: actions/checkout@v2
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
Expand Down Expand Up @@ -73,7 +76,8 @@ jobs:
env:
TOX_ENV: ${{ format('py{0}-django{1}-cms{2}', matrix.python-version, matrix.django, matrix.cms) }}
COMMAND: coverage run
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_SERVICE_NAME: github
run: |
tox -e$TOX_ENV
.tox/$TOX_ENV/bin/coverage xml
Expand Down
24 changes: 21 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
exclude: '(.idea|node_modules|.tox)'
exclude: "(.idea|node_modules|.tox)"
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.5.0
Expand All @@ -17,17 +17,35 @@ repos:
args:
- --remove
- repo: https://github.com/timothycrosley/isort
rev: '4.3.21'
rev: "4.3.21"
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 19.10b0
hooks:
- id: black
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.0a2
rev: 3.8.0
hooks:
- id: flake8
additional_dependencies:
- flake8-broken-line
- flake8-bugbear
- flake8-builtins
- flake8-coding
- flake8-commas
- flake8-comprehensions
- flake8-eradicate
- flake8-quotes
- flake8-tidy-imports
- pep8-naming
- repo: https://github.com/econchick/interrogate
rev: 1.2.0
hooks:
- id: interrogate
args:
- "-cpyproject.toml"
- "--quiet"
- repo: https://github.com/asottile/pyupgrade
rev: v2.2.1
hooks:
Expand Down
1 change: 1 addition & 0 deletions changes/185.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Tweak linting
18 changes: 17 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,27 @@ build-backend = "setuptools.build_meta"

[tool.black]
line-length = 119
target-version = ["py27"]
target-version = ["py36"]
include = 'app_helper/*py'

[tool.towncrier]
package = "app_helper"
directory = "changes"
filename = "HISTORY.rst"
title_format = "{version} ({project_date})"

[tool.interrogate]
ignore-init-method = true
ignore-init-module = true
ignore-magic = false
ignore-semiprivate = false
ignore-private = false
ignore-module = true
ignore-nested-functions = true
fail-under = 0
exclude = ["docs", ".tox"]
ignore-regex = ["^get$", "^mock_.*", ".*BaseClass.*"]
verbose = 0
quiet = false
whitelist-regex = []
color = true
22 changes: 19 additions & 3 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,26 @@ def format(c): # NOQA
def towncrier_check(c): # NOQA
""" Check towncrier files. """
output = io.StringIO()
c.run("git branch -a --contains HEAD", out_stream=output)
branches = [branch.replace("remotes/origin/", "") for branch in output.getvalue().strip("*").split()]
towncrier_file = None
c.run("git branch --contains HEAD", out_stream=output)
skipped_branch_prefix = ["pull/", "develop", "master", "HEAD"]
# cleanup branch names by removing PR-only names in local, remote and disconnected branches to ensure the current
# (i.e. user defined) branch name is used
branches = list(
filter(
lambda x: x and all(not x.startswith(part) for part in skipped_branch_prefix),
(
branch.replace("origin/", "").replace("remotes/", "").strip("* (")
for branch in output.getvalue().split("\n")
),
)
)
print("Candidate branches", ", ".join(output.getvalue().split("\n")))
if not branches:
# if no branch name matches, we are in one of the excluded branches above, so we just exit
print("Skip check, branch excluded by configuration")
return
branch = branches[0]
towncrier_file = None
for branch in branches:
if any(branch.startswith(prefix) for prefix in SPECIAL_BRANCHES):
sys.exit(0)
Expand Down
4 changes: 3 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ basepython = python3.7
[testenv:pep8]
commands =
{envpython} -m flake8
{envpython} -minterrogate -c pyproject.toml app_helper
deps =
interrogate
flake8
flake8-broken-line
flake8-bugbear
flake8-builtins
flake8-coding # Enable when dropping python2
flake8-coding
flake8-commas
flake8-comprehensions
flake8-eradicate
Expand Down