From 3853929d9f2062317bd4c7a3fc2923fdf804b155 Mon Sep 17 00:00:00 2001 From: mashehu Date: Thu, 25 Jan 2024 15:38:28 +0100 Subject: [PATCH 1/2] test using xdist for faster tests --- .github/workflows/pytest.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 8cec6a63d7..b4438055c0 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -136,7 +136,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" From 541d4fb39e41fbb309aac049a801060b2176337a Mon Sep 17 00:00:00 2001 From: mashehu Date: Thu, 25 Jan 2024 15:53:46 +0100 Subject: [PATCH 2/2] avoid setup-python api limit --- .github/workflows/changelog.yml | 11 ++++++++++- .github/workflows/create-lint-wf.yml | 6 ++++++ .../workflows/create-test-lint-wf-template.yml | 6 ++++++ .github/workflows/create-test-wf.yml | 7 +++++++ .github/workflows/pytest.yml | 15 ++++++++++++++- requirements-dev.txt | 1 + 6 files changed, 44 insertions(+), 2 deletions(-) diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index 63dcf2e428..c45052fae5 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -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: | diff --git a/.github/workflows/create-lint-wf.yml b/.github/workflows/create-lint-wf.yml index 0119efcd41..523681b206 100644 --- a/.github/workflows/create-lint-wf.yml +++ b/.github/workflows/create-lint-wf.yml @@ -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 diff --git a/.github/workflows/create-test-lint-wf-template.yml b/.github/workflows/create-test-lint-wf-template.yml index 3805c1a240..e84e48487b 100644 --- a/.github/workflows/create-test-lint-wf-template.yml +++ b/.github/workflows/create-test-lint-wf-template.yml @@ -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 diff --git a/.github/workflows/create-test-wf.yml b/.github/workflows/create-test-wf.yml index e128e16a36..75fba50810 100644 --- a/.github/workflows/create-test-wf.yml +++ b/.github/workflows/create-test-wf.yml @@ -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 diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index b4438055c0..51263f4d9c 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -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 }} @@ -165,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: diff --git a/requirements-dev.txt b/requirements-dev.txt index 9fbb49c10c..0e91a437b9 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -2,6 +2,7 @@ mypy myst_parser pytest-cov pytest-datafiles +pytest-xdist responses ruff Sphinx