Skip to content

Commit

Permalink
Merge pull request #560 from UW-GAC/maint/ci-parallel-tests
Browse files Browse the repository at this point in the history
Run tests in parallel
  • Loading branch information
amstilp authored May 8, 2024
2 parents 36aa29e + d974cf4 commit ff02479
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
19 changes: 13 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
- python-version: 3.8 # Possible future version.
backend: "mariadb"
mariadb-version: "10.11"

name: "py${{ matrix.python-version }}-${{ matrix.backend }}-${{ matrix.mariadb-version }}"

services:
Expand Down Expand Up @@ -77,13 +78,18 @@ jobs:
run: python manage.py collectstatic --noinput --settings=config.settings.test

- name: Run tests
run: coverage run -p -m pytest
run: |
pytest --cov=gregor_django -n auto
mv .coverage .coverage-${{ strategy.job-index }}
- name: List files for debugging purposes
run: ls -lhta

- name: Upload coverage data
uses: actions/upload-artifact@v4
with:
name: coverage-data-${{ strategy.job-index }}
path: .coverage.*
path: .coverage-${{ strategy.job-index }}

coverage:
needs:
Expand All @@ -110,13 +116,14 @@ jobs:

- name: Merge coverage files
run: |
mv ./artifacts/coverage-data*/.coverage* .
python -m coverage combine ./artifacts/coverage-data*/.coverage-*
python -m coverage xml
ls -la .coverage*
- name: Combine coverage data
- name: Report coverage
run: |
python -m coverage combine
python -m coverage xml
python -m coverage report
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[pytest]
addopts = --ds=config.settings.test --reuse-db
addopts = --ds=config.settings.test --reuse-db -n auto
python_files = tests.py test_*.py
filterwarnings =
# Convert all warnings to errors.
Expand Down
4 changes: 4 additions & 0 deletions requirements/test-requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
types-requests
# Pytest
pytest # https://github.com/pytest-dev/pytest
# Parallelized tests
pytest-xdist # https://github.com/pytest-dev/pytest-xdist
# Coverage integrated with pytest
pytest-cov
# Pytest improvements - progress bar, etc.
pytest-sugar # https://github.com/Frozenball/pytest-sugar
# Mock HTTP responses
Expand Down
6 changes: 6 additions & 0 deletions requirements/test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ django-test-migrations==1.3.0
# via -r requirements/test-requirements.in
exceptiongroup==1.2.0
# via pytest
execnet==2.1.1
# via pytest-xdist
factory-boy==3.3.0
# via -r requirements/test-requirements.in
faker==23.2.1
Expand All @@ -44,10 +46,14 @@ pytest==8.2.0
# -r requirements/test-requirements.in
# pytest-django
# pytest-sugar
pytest-cov==5.0.0
# via -r requirements/test-requirements.in
pytest-django==4.8.0
# via -r requirements/test-requirements.in
pytest-sugar==1.0.0
# via -r requirements/test-requirements.in
pytest-xdist==3.6.1
# via -r requirements/test-requirements.in
python-dateutil==2.8.2
# via faker
pyyaml==6.0.1
Expand Down

0 comments on commit ff02479

Please sign in to comment.