Skip to content

Commit 9ff0a98

Browse files
authored
ci: use pytest-xdist to speed up the tests (#1509)
1 parent 6749242 commit 9ff0a98

3 files changed

Lines changed: 50 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,17 @@ jobs:
167167
# generate secret key
168168
SECRET_KEY=$(python -c "import secrets; print(secrets.token_urlsafe())")
169169
sed -i "s/^SECRET_KEY=.*/SECRET_KEY=$SECRET_KEY/" .env
170-
MYSQL_PWD=$DB_ROOT_PASSWORD mariadb -u root -h db --skip-ssl -e "GRANT ALL PRIVILEGES ON \`test_OpalDB\`.* TO \`$DB_USER\`@\`%\`;"
171-
MYSQL_PWD=$DB_ROOT_PASSWORD mariadb -u root -h db --skip-ssl -e "GRANT ALL PRIVILEGES ON \`test_QuestionnaireDB\`.* TO \`$DB_USER\`@\`%\`;"
170+
MYSQL_PWD=$DB_ROOT_PASSWORD mariadb -u root -h db --skip-ssl -e "GRANT ALL PRIVILEGES ON \`test_opal%\`.* TO \`$DB_USER\`@\`%\`;"
171+
MYSQL_PWD=$DB_ROOT_PASSWORD mariadb -u root -h db --skip-ssl -e "GRANT ALL PRIVILEGES ON \`test_OpalDB%\`.* TO \`$DB_USER\`@\`%\`;"
172+
MYSQL_PWD=$DB_ROOT_PASSWORD mariadb -u root -h db --skip-ssl -e "GRANT ALL PRIVILEGES ON \`test_QuestionnaireDB%\`.* TO \`$DB_USER\`@\`%\`;"
172173
- name: Run pytest
174+
env:
175+
# https://github.com/zupo/awesome-pytest-speedup#pythondontwritebytecode
176+
PYTHONDONTWRITEBYTECODE: 1
173177
run: |
174178
uv run pytest --version
175179
# -m "" runs all tests, even the ones marked as slow
176-
uv run coverage run -m pytest -m "" -v --junitxml=test-report.xml
180+
uv run pytest --cov=opal -n auto -m "" --junitxml=test-report.xml
177181
# see: https://github.com/dorny/test-reporter/issues/244
178182
# - name: Publish Test Results
179183
# uses: dorny/test-reporter@v1.9.1

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,14 @@ dev = [
7070
"pandas-stubs==3.0.0.260204",
7171
"prek==0.3.4",
7272
"pytest==9.0.2",
73+
# for proper coverage support with pytest-xdist
74+
"pytest-cov==7.0.0",
7375
"pytest-django==4.11.1",
7476
"pytest-mock==3.15.1",
7577
"pytest-randomly==4.0.1",
7678
"pytest-socket==0.7.0",
7779
"pytest-sugar==1.1.1",
80+
"pytest-xdist==3.8.0",
7881
"ruff==0.15.4",
7982
"types-beautifulsoup4==4.12.0.20250516",
8083
"types-fpdf2==2.8.4.20260221",

uv.lock

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)