Fix GH actions

This commit is contained in:
Alvaro Mariano 2023-06-19 20:29:14 -03:00
parent c2ec8ac800
commit ec38ad0ecf
4 changed files with 92 additions and 14 deletions

View file

@ -2,7 +2,7 @@
# https://pypi.org/project/tox-gh-actions/
---
name: Test the application using Tox.
name: Test the application.
on:
- push
@ -10,22 +10,59 @@ on:
jobs:
build:
name: Testing
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8"]
# python-version: ["3.8", "3.9", "3.10", "3.11"]
steps:
- name: apt update
run: sudo apt update
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install poetry
run: pipx install poetry
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox tox-gh-actions
- name: Test with tox
run: tox -v
run: poetry install
- name: Run tests
run: poetry run pytest
env:
COVERAGE_FILE: ".coverage.${{ matrix.python_version }}"
- name: Store coverage file
uses: actions/upload-artifact@v3
with:
name: coverage
path: .coverage.${{ matrix.python_version }}
coverage:
name: Coverage
runs-on: ubuntu-latest
needs: build
permissions:
pull-requests: write
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
id: download
with:
name: 'coverage'
- name: Coverage comment
id: coverage_comment
uses: py-cov-action/python-coverage-comment-action@v3
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MERGE_COVERAGE_FILES: true
- name: Store Pull Request comment to be posted
uses: actions/upload-artifact@v3
if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true'
with:
name: python-coverage-comment-action
path: python-coverage-comment-action.txt

1
.gitignore vendored
View file

@ -15,3 +15,4 @@ test.sqlite3
settings.json
.pytest_cache
.vscode
coverage.xml

36
poetry.lock generated
View file

@ -358,6 +358,20 @@ files = [
[package.extras]
test = ["pytest (>=6)"]
[[package]]
name = "execnet"
version = "1.9.0"
description = "execnet: rapid multi-Python deployment"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
files = [
{file = "execnet-1.9.0-py2.py3-none-any.whl", hash = "sha256:a295f7cc774947aac58dde7fdc85f4aa00c42adf5d8f5468fc630c1acf30a142"},
{file = "execnet-1.9.0.tar.gz", hash = "sha256:8f694f3ba9cc92cab508b152dcfe322153975c29bda272e2fd7f3f00f36e47c5"},
]
[package.extras]
testing = ["pre-commit"]
[[package]]
name = "factory-boy"
version = "3.2.1"
@ -942,6 +956,26 @@ pytest = ">=5.4.0"
docs = ["sphinx", "sphinx-rtd-theme"]
testing = ["Django", "django-configurations (>=2.0)"]
[[package]]
name = "pytest-xdist"
version = "3.3.1"
description = "pytest xdist plugin for distributed testing, most importantly across multiple CPUs"
optional = false
python-versions = ">=3.7"
files = [
{file = "pytest-xdist-3.3.1.tar.gz", hash = "sha256:d5ee0520eb1b7bcca50a60a518ab7a7707992812c578198f8b44fdfac78e8c93"},
{file = "pytest_xdist-3.3.1-py3-none-any.whl", hash = "sha256:ff9daa7793569e6a68544850fd3927cd257cc03a7ef76c95e86915355e82b5f2"},
]
[package.dependencies]
execnet = ">=1.1"
pytest = ">=6.2.0"
[package.extras]
psutil = ["psutil (>=3.0)"]
setproctitle = ["setproctitle"]
testing = ["filelock"]
[[package]]
name = "python-dateutil"
version = "2.8.2"
@ -1292,4 +1326,4 @@ files = [
[metadata]
lock-version = "2.0"
python-versions = "^3.8.1"
content-hash = "fd733a59826a0314c13965a59360679214feae545620f75b4c9bc5e6bc964683"
content-hash = "5124ddae507dc735742cabf924f10727740142438abaa081cd1a239b1c1c2d7a"

View file

@ -89,7 +89,7 @@ swapper = "^1"
[tool.poetry.group.dev.dependencies]
black = "^23"
bandit = "^1"
coverage = "^7"#### TODO
coverage = {extras = ["toml"], version = "^7.2.7"}
django-debug-toolbar = "^4"
isort = "^5"
mypy = "^1" ### TODO
@ -104,6 +104,7 @@ tox = "^4"
psycopg2-binary = "^2.9.6"
django-test-migrations = "^1.3.0"
factory-boy = "^3.2.1"
pytest-xdist = "^3.3.1"
[build-system]
requires = ["poetry-core"]
@ -135,7 +136,7 @@ profile = "black"
[tool.pytest.ini_options]
minversion = "7.0"
addopts = "--reuse-db"
addopts = "--reuse-db -n auto --cov=notifications"
norecursedirs = [
".git",
".github",
@ -157,3 +158,8 @@ testpaths = [
]
DJANGO_SETTINGS_MODULE = "notifications.tests.settings"
django_debug_mode = "keep"
[tool.coverage.run]
relative_files = true
parallel = true
branch = true