Skip to content

Commit

Permalink
chore(ci): add testing workflow and coverage configuration
Browse files Browse the repository at this point in the history
- Introduce GitHub Actions workflow for running tests
- Add codecov configuration
- Include .coveragerc for coverage settings
- Create Makefile with common development tasks
- Update pyproject.toml with new dependencies and test configurations
  • Loading branch information
bendikrb committed Sep 15, 2024
1 parent a13785a commit 227871c
Show file tree
Hide file tree
Showing 6 changed files with 559 additions and 248 deletions.
13 changes: 13 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[run]
branch = True
omit =
podplay_api/cli.py

[report]
exclude_lines =
pragma: no cover
def __repr__
def __str__
def __rich_console__
if __name__ == .__main__.:
if TYPE_CHECKING
76 changes: 76 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
name: Testing

# yamllint disable-line rule:truthy
on:
push:
pull_request:
workflow_dispatch:

env:
DEFAULT_PYTHON: "3.12"

jobs:
pytest:
name: Python ${{ matrix.python }}
runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.12"]
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/[email protected]
- name: 🏗 Set up Poetry
run: pipx install poetry
- name: 🏗 Set up Python ${{ matrix.python }}
id: python
uses: actions/[email protected]
with:
python-version: ${{ matrix.python }}
cache: "poetry"
- name: 🏗 Install workflow dependencies
run: |
poetry config virtualenvs.create true
poetry config virtualenvs.in-project true
- name: 🏗 Install dependencies
run: poetry install --no-interaction
- name: 🚀 Run pytest
run: poetry run pytest --cov podplay_api tests
- name: ⬆️ Upload coverage artifact
uses: actions/[email protected]
with:
name: coverage-${{ matrix.python }}
path: .coverage

coverage:
runs-on: ubuntu-latest
needs: pytest
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/[email protected]
with:
fetch-depth: 0
- name: ⬇️ Download coverage data
uses: actions/[email protected]
- name: 🏗 Set up Poetry
run: pipx install poetry
- name: 🏗 Set up Python ${{ env.DEFAULT_PYTHON }}
id: python
uses: actions/[email protected]
with:
python-version: ${{ env.DEFAULT_PYTHON }}
cache: "poetry"
- name: 🏗 Install workflow dependencies
run: |
poetry config virtualenvs.create true
poetry config virtualenvs.in-project true
- name: 🏗 Install dependencies
run: poetry install --no-interaction
- name: 🚀 Process coverage results
run: |
poetry run coverage combine coverage*/.coverage*
poetry run coverage xml -i
- name: 🚀 Upload coverage report
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
33 changes: 33 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
run := poetry run

.PHONY: test
test:
$(run) pytest tests/ $(ARGS)

.PHONY: test-coverage
test-coverage:
$(run) pytest tests/ --cov-report term-missing --cov podplay_api $(ARGS)

.PHONY: coverage
coverage:
$(run) coverage html

.PHONY: format
format:
$(run) ruff format podplay_api

.PHONY: format-check
format-check:
$(run) ruff --check podplay_api

.PHONY: setup
setup:
poetry install

.PHONY: update
update:
poetry update

.PHONY: repl
repl:
$(run) python
7 changes: 7 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
codecov:
branch: master
cli:
plugins:
pycoverage:
report_type: "json"

Loading

0 comments on commit 227871c

Please sign in to comment.