Skip to content

Commit

Permalink
Add GH Actions and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike committed Feb 27, 2022
1 parent 490357a commit c4ccd67
Show file tree
Hide file tree
Showing 8 changed files with 180 additions and 6 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: publish

on:
release:
types: [published]

jobs:
publish:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade tox-gh-actions
- name: Publish with tox and twine
env:
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
run: |
tox -e publish
39 changes: 39 additions & 0 deletions .github/workflows/run-python-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This workflow will install Python dependencies, lint and run tests
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: build

on:
push:
branches-ignore:
- gh-pages
pull_request:
branches-ignore:
- gh-pages

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade tox-gh-actions
- name: Test with tox/pytest
run: |
tox
- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v1
if: always()
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
files: .tox/*.xml
- name: Upload Coverage Results
uses: codecov/codecov-action@v2
if: success()
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
[![Build Status](https://github.com/mcarans/pytest-loguru/workflows/build/badge.svg)](https://github.com/mcarans/pytest-loguru/actions?query=workflow%3Abuild)
[![Coverage Status](https://codecov.io/gh/mcarans/pytest-loguru/branch/main/graph/badge.svg?token=JpWZc5js4y)](https://codecov.io/gh/mcarans/pytest-loguru)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)

### pytest-loguru

A pytest plugin to add support for loguru to pytest's caplog fixture.
98 changes: 97 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,99 @@
[build-system]
requires = [ "setuptools>=45" ]
requires = [ "setuptools>=45", "setuptools_scm[toml]>=6.2", "wheel"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
write_to = "src/pytest_loguru/_version.py"
local_scheme = "no-local-version"
version_scheme = "python-simplified-semver"

[tool.black]
line-length = 79

[tool.isort]
profile = "black"
line_length = 79
multi_line_output = 3

[tool.flakeheaven]
# make output nice
format = "grouped"
max_line_length = 79
# show line of source code in output
show_source = true
exclude = ["_version.py"]

# list of plugins and rules for them
[tool.flakeheaven.plugins]
mccabe = ["+*"]
pycodestyle = ["+*", "-E203", "-E501", "-W503"]
pyflakes = ["+*"]
pylint = ["+*"]
flake8-isort = ["+*"]
flake8-black = ["+*"]

[tool.pytest.ini_options]
pythonpath = "src"
addopts = "--color=yes"
log_cli = 1

[tool.coverage.paths]
source = ["src/pytest_loguru", "*/site-packages/pytest_loguru"]

[tool.coverage.report]
omit = [
"*/setup.py",
"*/python?.?/*",
"*/venv/*",
"*/site-packages/*",
"*/tests/*",
"*__init__*"
]

exclude_lines = [
"pragma: no cover", # Have to re-enable the standard pragma
"def __repr__", # Don't complain about missing
"if self.debug", # debug-only code
"raise AssertionError", # Don't complain if tests don't hit
"raise NotImplementedError", # defensive assertion code
"if 0:", # Don't complain if non-runnable code
"if __name__ == .__main__.:" # isn't run
]

[tool.tox]
legacy_tox_ini = """
[tox]
isolated_build = true
envlist = py310, lint
[gh-actions]
python =
3: py310, lint
[testenv]
recreate = true
wheel = true
deps =
-r test-requirements.txt
commands =
pytest --cov=pytest_loguru --no-cov-on-fail --junitxml=.tox/test-results.xml --cov-report=xml --cov-report=term-missing
[testenv:lint]
wheel_build_env = py310
deps =
flakeheaven
flake8
flake8-isort
flake8-black
commands =
flakeheaven lint src tests
[testenv:publish]
wheel_build_env = py310
passenv = SSH_AUTH_SOCK TWINE_USERNAME TWINE_PASSWORD
deps =
twine
commands =
twine upload {distdir}/*
"""
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pytest
loguru
pytest==7.0.1
loguru==0.6.0
2 changes: 1 addition & 1 deletion src/pytest_loguru/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.0.0"
from ._version import version as __version__ # noqa: F401
4 changes: 4 additions & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pytest-cov==3.0.0
tox==3.24.5
tox-wheel==0.7.0
-r requirements.txt
4 changes: 2 additions & 2 deletions tests/pytest_loguru/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

from loguru import logger

from pytest_loguru.plugin import caplog
from pytest_loguru.plugin import caplog # noqa: F401


class TestLogging:
def test_setup_logging(self, caplog):
def test_setup_logging(self, caplog): # noqa: F811
with caplog.at_level(logging.ERROR):
text = "Division by zero!"

Expand Down

0 comments on commit c4ccd67

Please sign in to comment.