Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test using xdist for faster tests [skip changelog] #2685

Draft
wants to merge 2 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,18 @@ jobs:
fi
gh pr checkout $PR_NUMBER

- uses: actions/setup-python@v5
# Check if python is installed
- name: Check python version
id: python-version
run: python --version

# Set up nf-core/tools
- name: Set up Python 3.11
uses: actions/setup-python@v5
if: steps.python-version.outcome == 'failure'
with:
python-version: "3.11"
cache: "pip"

- name: Install packages
run: |
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/create-lint-wf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,15 @@ jobs:
- uses: actions/checkout@v4
name: Check out source-code repository

# Check if python is installed
- name: Check python version
id: python-version
run: python --version

# Set up nf-core/tools
- name: Set up Python 3.11
uses: actions/setup-python@v5
if: steps.python-version.outcome == 'failure'
with:
python-version: 3.11
cache: pip
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/create-test-lint-wf-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,14 @@ jobs:
- uses: actions/checkout@v4
name: Check out source-code repository

# Check if python is installed
- name: Check python version
id: python-version
run: python --version

- name: Set up Python 3.11
uses: actions/setup-python@v5
if: steps.python-version.outcome == 'failure'
with:
python-version: 3.11

Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/create-test-wf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,15 @@ jobs:
- uses: actions/checkout@v4
name: Check out source-code repository

# Check if python is installed
- name: Check python version
id: python-version
run: python --version

# Set up nf-core/tools
- name: Set up Python 3.11
uses: actions/setup-python@v5
if: steps.python-version.outcome == 'failure'
with:
python-version: 3.11

Expand Down
21 changes: 19 additions & 2 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,13 @@ jobs:
- uses: actions/checkout@v4
name: Check out source-code repository

# Check if python is installed, by outputing major and minor version, but not patch version
- name: Check python version
id: python-version
run: echo "python-version=$(python --version)" | sed 's/Python \([0-9]\+\.[0-9]\+\)\.[0-9]\+/\1/' >> $GITHUB_OUTPUT

- name: Set up Python ${{ needs.setup.outputs.python-version }}
if: steps.python-version.outputs.python-version == ${{ needs.setup.outputs.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ needs.setup.outputs.python-version }}
Expand Down Expand Up @@ -136,7 +142,11 @@ jobs:

- name: Test with pytest
run: |
python3 -m pytest tests/${{matrix.test}} --color=yes --cov --durations=0 && exit_code=0|| exit_code=$?
# run in parallel with xdist if not test_modules.py or test_subworkflows.py
if [ "${{ matrix.test }}" != "test_modules.py" ] && [ "${{ matrix.test }}" != "test_subworkflows.py" ]; then
python3 -m pytest tests/${{matrix.test}} --color=yes --cov --durations=0 -n 2 && exit_code=0|| exit_code=$?
else
python3 -m pytest tests/${{matrix.test}} --color=yes --cov --durations=0 && exit_code=0|| exit_code=$?
# don't fail if no tests were collected, e.g. for test_licence.py
if [ "${exit_code}" -eq 5 ]; then
echo "No tests were collected"
Expand All @@ -161,9 +171,16 @@ jobs:
mkdir -p pytest
cd pytest

- uses: actions/checkout@v4
- uses: actions/checkout@v4 #

- name: Check python version
id: python-version
run: python --version

# Set up nf-core/tools
- name: Set up Python 3.11
uses: actions/setup-python@v5
if: steps.python-version.outcome == 'failure'
env:
AGENT_TOOLSDIRECTORY: /opt/actions-runner/_work/tools/tools/
with:
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ mypy
myst_parser
pytest-cov
pytest-datafiles
pytest-xdist
responses
ruff
Sphinx
Expand Down
Loading