Skip to content

Commit

Permalink
build: use pytest-cov and deptry (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
natelandau authored Nov 10, 2024
1 parent 5ccf463 commit d1533c5
Showing 4 changed files with 105 additions and 58 deletions.
47 changes: 2 additions & 45 deletions .github/workflows/automated-tests.yml
Original file line number Diff line number Diff line change
@@ -50,19 +50,11 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

# ----------------------------------------------
# Install and run MongoDB
# ----------------------------------------------

- name: Start MongoDB
uses: supercharge/mongodb-github-action@1.11.0
with:
mongodb-version: "8.0"

# ----------------------------------------------
# Setup Python, uv, and install project dependencies
# ----------------------------------------------

- name: Setup Python, uv, and the package
uses: ./.github/actions/uv-python-package

@@ -80,45 +72,10 @@ jobs:

- name: Run tests
shell: bash
run: uv run pytest tests/

upload-coverage:
runs-on: ubuntu-latest
needs:
- test-python-code
steps:
- name: Checkout repository
uses: actions/checkout@v4

# ----------------------------------------------
# Install and run MongoDB
# ----------------------------------------------

- name: Start MongoDB
uses: supercharge/mongodb-github-action@1.11.0
with:
mongodb-version: "8.0"

# ----------------------------------------------
# Setup Python, uv, and install project dependencies
# ----------------------------------------------

- name: Setup Python, uv, and the package
uses: ./.github/actions/uv-python-package

# ----------------------------------------------
# Run tests
# ----------------------------------------------
run: uv run poe test

- name: Run tests with pytest
run: |
uv run coverage run
uv run coverage report
uv run coverage xml
# ----------------------------------------------
# upload coverage stats
# ----------------------------------------------
- name: Upload coverage
if: ${{ matrix.python-version == '3.13' }}
uses: codecov/codecov-action@v4
with:
files: reports/coverage.xml
7 changes: 6 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -66,7 +66,7 @@ repos:
- id: ruff-format

- repo: "https://github.com/crate-ci/typos"
rev: typos-dict-v0.11.34
rev: typos-dict-v0.11.35
hooks:
- id: typos

@@ -76,6 +76,11 @@ repos:
- id: djlint
args: ["--configuration", "pyproject.toml"]

- repo: "https://github.com/fpgmaas/deptry.git"
rev: "0.21.0"
hooks:
- id: deptry

# - repo: "https://github.com/pre-commit/mirrors-mypy"
# rev: v1.11.2
# hooks:
30 changes: 19 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -6,22 +6,29 @@
authors = [{ name = "Nate Landau", email = "valentina@natenate.org" }]
dependencies = [
"aiofiles>=24.1.0",
"aiohttp>=3.10.10",
"arrow>=1.3.0",
"audioop-lts>=0.2.1",
"beanie>=1.26.0,<2.0.0",
"boto3>=1.35.24,<2.0.0",
"botocore>=1.35.56",
"certifi>=2024.8.30",
"confz>=2.0.1,<3.0.0",
"faker>=30.0.0",
"flask-discord>=0.1.69",
"flask>=3.0.3",
"hypercorn>=0.17.3",
"inflect>=7.4.0",
"jinjax[whitenoise]>=0.46",
"loguru>=0.7.2",
"markdown2>=2.5.0",
"markupsafe>=2.1.5",
"motor>=3.6.0",
"numpy>=2.1.1,<2.2.0",
"py-cord>=2.6.1,<2.7.0",
"pydantic>=2.9.2,<3.0.0",
"pygithub>=2.4.0",
"pymongo>=4.9.2",
"quart-flask-patch>=0.3.0",
"quart-session>=3.0.0",
"quart-wtforms>=1.0.2",
@@ -30,6 +37,8 @@
"rich>=13.8.1",
"semver>=3.0.2",
"typer>=0.13.0,<0.14.0",
"werkzeug>=3.1.2",
"wtforms>=3.2.1",
]
description = "Valentina is a Discord bot that helps you run TTRPGs."
license = "AGPL-3.0-or-later"
@@ -48,6 +57,7 @@
dev-dependencies = [
"commitizen>=3.29.1",
"coverage>=7.6.1",
"deptry>=0.21.0",
"dirty-equals>=0.8.0",
"djlint>=1.35.2",
"mypy>=1.11.2",
@@ -56,6 +66,7 @@
"pre-commit>=3.8.0",
"pytest-asyncio>=0.24.0",
"pytest-clarity>=1.0.1",
"pytest-cov>=6.0.0",
"pytest-env>=1.1.5",
"pytest-mock>=3.14.0",
"pytest-sugar>=1.0.0",
@@ -120,6 +131,11 @@
[tool.coverage.xml]
output = "reports/coverage.xml"

[tool.deptry]
known_first_party = ["valentina"]
[tool.deptry.per_rule_ignores]
DEP002 = ["audioop-lts", "redis"]

[tool.djlint]
extend_exclude = ".vscode, .github, .git, .ruff_cache, .pytest_cache, __pycache__, .mypy_cache, .venv, tests, src/valentina/discord, src/valentina/models, src/valentina/utils, src/valentina/views, tests"
ignore = "H030,H031,H021,H006,H013"
@@ -157,7 +173,7 @@

[tool.pytest.ini_options]

addopts = "--color=yes --doctest-modules --exitfirst --failed-first --strict-config --strict-markers --junitxml=reports/pytest.xml --ignore=src/valentina/discord/cogs/test_cog.py"
addopts = "--color=yes --doctest-modules --exitfirst --failed-first --strict-config --strict-markers --ignore=src/valentina/discord/cogs/test_cog.py"
asyncio_default_fixture_loop_scope = "function"
asyncio_mode = "auto"
env = [
@@ -340,13 +356,5 @@
"""

[tool.poe.tasks.test]
help = "Test this package"

[[tool.poe.tasks.test.sequence]]
cmd = "coverage run"

[[tool.poe.tasks.test.sequence]]
cmd = "coverage report"

[[tool.poe.tasks.test.sequence]]
cmd = "coverage xml"
cmd = "pytest --cov=valentina --cov-config=pyproject.toml --cov-report=xml --cov-report=term tests/"
help = "Test this package and generate coverage reports"
79 changes: 78 additions & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d1533c5

Please sign in to comment.