Skip to content

Commit

Permalink
test: Cover all functionality with tests
Browse files Browse the repository at this point in the history
Ensure that `pre-commit-run-hook-entry` as well as
`pre-commit-run-black-entry` works as expected.

Which means to ensure that library supports all pre-commit hooks enabled
for the repo, especially:

- `black` for Python files formatting
- `flake8` & `mypy` for Python files linting
  • Loading branch information
playpauseandstop committed Jun 11, 2020
1 parent 09c7134 commit da90716
Show file tree
Hide file tree
Showing 10 changed files with 433 additions and 57 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[flake8]
application-import-names = pre_commit_which
application-import-names = pre_commit_run_hook_entry
import-order-style = smarkets
inline-quotes = double
max-complexity = 15
25 changes: 23 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
branches: ["master"]

env:
COVERALLS_VERSION: "2.0.0"
DEV_PYTHON_VERSION: "3.8"
POETRY_VERSION: "1.0.9"
TWINE_VERSION: "3.1.1"
Expand Down Expand Up @@ -46,7 +47,7 @@ jobs:

strategy:
matrix:
python-version: ["3.6", "3.7", "3.8"]
python-version: ["3.7", "3.8"]

runs-on: "ubuntu-latest"

Expand All @@ -67,7 +68,7 @@ jobs:
run: |
poetry config --local virtualenvs.create true
poetry config --local virtualenvs.in-project true
poetry install --no-dev
poetry install
- name: "Cache pre-commit"
if: "matrix.python-version == env.DEV_PYTHON_VERSION"
Expand All @@ -80,6 +81,26 @@ jobs:
if: "matrix.python-version == env.DEV_PYTHON_VERSION"
uses: "pre-commit/action@v1.0.1"

- name: "Run tests"
run: |
set -e
# Coverage don't work well on Python 3.7
args=
if [ ${{ matrix.python-version }} == ${{ env.DEV_PYTHON_VERSION }} ]; then
args="--cov --no-cov-on-fail"
fi
poetry run python -m pytest ${args}
- name: "Send report to coveralls"
if: "matrix.python-version == env.DEV_PYTHON_VERSION"
env:
COVERALLS_REPO_TOKEN: "${{ secrets.COVERALLS_REPO_TOKEN }}"
run: |
python -m pip install coveralls==${{ env.COVERALLS_VERSION }}
python -m coveralls
package:
needs: "test"
name: "Build & deploy package"
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

POETRY ?= poetry
PRE_COMMIT ?= pre-commit
PYTHON ?= $(POETRY) run python

install: .install
.install: pyproject.toml poetry.lock
Expand All @@ -15,4 +16,4 @@ lint-only:

test: lint test-only
test-only:
echo "All OK!"
$(PYTHON) -m pytest --cov --no-cov-on-fail
6 changes: 5 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ pre-commit-run-hook-entry
:target: https://github.com/playpauseandstop/pre-commit-run-hook-entry/blob/master/LICENSE
:alt: BSD License

.. image:: https://coveralls.io/repos/playpauseandstop/pre-commit-run-hook-entry/badge.svg?branch=master&service=github
:target: https://coveralls.io/github/playpauseandstop/pre-commit-run-hook-entry
:alt: Coverage

Run `pre-commit`_ hook entry. Allow to run pre-commit hooks for text editor
formatting / linting needs.

Expand All @@ -34,7 +38,7 @@ formatting / linting needs.
Requirements
============

- `Python <https://www.python.org/>`_ 3.6.1 or later
- `Python <https://www.python.org/>`_ 3.7 or later
- `pre-commit`_ 2.4.0 or later

License
Expand Down

0 comments on commit da90716

Please sign in to comment.