Skip to content

Commit

Permalink
Fix GH actions
Browse files Browse the repository at this point in the history
  • Loading branch information
AlvaroLQueiroz committed Jun 22, 2023
1 parent c2ec8ac commit ec38ad0
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 14 deletions.
59 changes: 48 additions & 11 deletions .github/workflows/test.yml
Expand Up @@ -2,30 +2,67 @@
# https://pypi.org/project/tox-gh-actions/

---
name: Test the application using Tox.
name: Test the application.

on:
- push
- pull_request

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 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -15,3 +15,4 @@ test.sqlite3
settings.json
.pytest_cache
.vscode
coverage.xml
36 changes: 35 additions & 1 deletion poetry.lock

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

10 changes: 8 additions & 2 deletions pyproject.toml
Expand Up @@ -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
Expand All @@ -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"]
Expand Down Expand Up @@ -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",
Expand All @@ -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

0 comments on commit ec38ad0

Please sign in to comment.