diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 47ccee2..3f5907a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,6 +1,6 @@ name: Linting - Tests -on: [push] +on: [push, pull_request] jobs: lint: @@ -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: @@ -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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0c40b3e..b9ef45c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 @@ -17,7 +17,7 @@ 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 @@ -25,9 +25,27 @@ repos: 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: diff --git a/changes/185.misc b/changes/185.misc new file mode 100644 index 0000000..e65d4ed --- /dev/null +++ b/changes/185.misc @@ -0,0 +1 @@ +Tweak linting diff --git a/pyproject.toml b/pyproject.toml index b713447..1c88cc6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [tool.black] line-length = 119 -target-version = ["py27"] +target-version = ["py36"] include = 'app_helper/*py' [tool.towncrier] @@ -12,3 +12,19 @@ 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 diff --git a/tasks.py b/tasks.py index d0645d3..82261dd 100644 --- a/tasks.py +++ b/tasks.py @@ -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) diff --git a/tox.ini b/tox.ini index a173a72..dfe2115 100644 --- a/tox.ini +++ b/tox.ini @@ -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