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

Parallelize pytest (#1) #2550

Merged
merged 136 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
136 commits
Select commit Hold shift + click to select a range
23295ac
Parallelize pytest (#1)
mashehu Nov 30, 2023
34285cf
use PR to test aws runners
mashehu Nov 30, 2023
7cfb0ae
fix coverage step
mashehu Nov 30, 2023
1a8d7f6
try self-hosted again
mashehu Nov 30, 2023
8e4554d
smaller naming changes
mashehu Dec 1, 2023
3b69094
try to use github runner when available
mashehu Dec 1, 2023
f77eff6
Merge branch 'dev' of github.com:mashehu/tools into dev
mashehu Dec 1, 2023
6ea28b7
Revert "try to use github runner when available"
mashehu Dec 1, 2023
5c866c6
run all tests even if one fails
mashehu Dec 1, 2023
5bb519f
print nextflow config
mashehu Dec 1, 2023
4f2b42d
use full path for nextflow.config
mashehu Dec 1, 2023
5f79510
fix workflow
mashehu Dec 1, 2023
498fca2
use different logic
mashehu Dec 1, 2023
b0ef65a
revert
mashehu Dec 1, 2023
7a1e095
try more self-hosted
mashehu Dec 1, 2023
4b0b238
remove config options
mashehu Dec 1, 2023
28a2a58
switch to new profile
mashehu Dec 4, 2023
7382ac7
Merge branch 'dev' of github.com:mashehu/tools into dev
mashehu Dec 4, 2023
6022a1d
print config files, try fix for coverage creation
mashehu Dec 4, 2023
08f4d28
print configs with profiles
mashehu Dec 4, 2023
35cb092
fix config command
mashehu Dec 4, 2023
ac2acfc
simply list_tests
mashehu Dec 4, 2023
cd7fac2
print more configs
mashehu Dec 4, 2023
1e5c2d7
don't print configs in this step
mashehu Dec 4, 2023
0084d15
exclude some template settings to be able to use nf-core configs
mashehu Dec 4, 2023
dddf944
try to fix coverage upload
mashehu Dec 5, 2023
1423218
debugging coverage step
mashehu Dec 5, 2023
c997ab2
ignore coverage errors for now
mashehu Dec 5, 2023
d84a86f
seems to work now?
mashehu Dec 5, 2023
e23e611
add codecov token
mashehu Dec 5, 2023
9547c66
try to fix name collisions
mashehu Dec 5, 2023
96b3152
add github token to editorconfig step
mashehu Dec 5, 2023
02fa592
debug changed directory
mashehu Dec 5, 2023
a9981c5
don't change path
mashehu Dec 5, 2023
6b97c77
more codecov debuggin
mashehu Dec 6, 2023
d0715e9
specify codecov file
mashehu Dec 6, 2023
fb2e164
Merge branch 'dev' into dev
mashehu Dec 7, 2023
3edb3db
test on github runners, to see speed differences
mashehu Dec 7, 2023
f52cb42
Merge branch 'dev' of github.com:mashehu/tools into dev
mashehu Dec 7, 2023
e107ada
run also list_test in github
mashehu Dec 7, 2023
e3fa536
don't reverse for now
mashehu Dec 7, 2023
d3ae3fa
more reversion
mashehu Dec 7, 2023
db88a83
remove debugging
mashehu Dec 7, 2023
b34f99f
cleanup work directory
mashehu Dec 7, 2023
addbf77
Merge branch 'dev' of github.com:mashehu/tools into dev
mashehu Dec 7, 2023
50814d1
switch to self-hosted again
mashehu Dec 7, 2023
c4fa345
don't need to install everything for coverage
mashehu Dec 7, 2023
fb8e644
always cleanup work directory
mashehu Dec 7, 2023
82791ac
debug coverage
mashehu Dec 7, 2023
494ecaf
Merge branch 'dev' into dev
mashehu Dec 8, 2023
72b6553
cleanup everything
mashehu Dec 8, 2023
0bba0e4
Merge branch 'dev' of github.com:mashehu/tools into dev
mashehu Dec 8, 2023
a1901f7
debugging coverage
mashehu Dec 8, 2023
9528d28
fail gracefully during cleanup
mashehu Dec 8, 2023
5c34797
debug no cleaned up paths
mashehu Dec 8, 2023
c9510e2
install tools also in coverage job
mashehu Dec 8, 2023
05bbc2f
add coverage report back in
mashehu Dec 8, 2023
fc96713
coverage debugging...
mashehu Dec 8, 2023
21b6c78
change nextflow working dir
mashehu Dec 8, 2023
7a2188d
kick off tests
mashehu Dec 8, 2023
15593b1
Merge branch 'dev' into dev
mashehu Dec 9, 2023
e83ec76
Merge branch 'dev' into dev
mashehu Dec 11, 2023
d14c02f
add debugger ssh
mashehu Dec 11, 2023
86d4ae2
more debugging
mashehu Dec 11, 2023
49827b8
try non-cached python
mashehu Dec 11, 2023
187a5b1
figure out differences in paths
mashehu Dec 11, 2023
4674b3f
trying to set the python directory manually
mashehu Dec 12, 2023
f262b79
hopefully harmonizing python paths
mashehu Dec 13, 2023
cd4ae58
fix coverage step
mashehu Dec 13, 2023
4e1029c
trying to fix the source error
mashehu Dec 13, 2023
86a771d
specify full path for coverage
mashehu Dec 13, 2023
e7bea34
copy more settings from pytest-split
mashehu Dec 14, 2023
5dfd403
handle exit code better
mashehu Dec 14, 2023
08d7a62
didn't work
mashehu Dec 14, 2023
4fafbef
switch to new gitlab branch
mashehu Dec 14, 2023
957b990
Merge branch 'dev' into dev
mashehu Dec 14, 2023
b2a9458
remove coverage output specification
mashehu Dec 14, 2023
3c11198
Merge branch 'dev' of github.com:mashehu/tools into dev
mashehu Dec 14, 2023
51bc286
omit all template files in coverage
mashehu Dec 14, 2023
d376ade
try different coverage_config path
mashehu Dec 14, 2023
704e348
fix coverage artifact upload
mashehu Dec 14, 2023
e2b846e
upgrade artifact download
mashehu Dec 14, 2023
4fa2825
run coverage step explicetly
mashehu Dec 14, 2023
2ab3974
change location of coverage config
mashehu Dec 14, 2023
2031d06
add ssh debugger
mashehu Dec 15, 2023
3d2009d
use old version of artifact upload
mashehu Dec 15, 2023
2bbb40a
debug artifact upload
mashehu Dec 15, 2023
fbb50f3
use files codecov-action argument
mirpedrol Dec 18, 2023
2807fca
Merge branch 'dev' of github.com:nf-core/tools into dev
mashehu Dec 19, 2023
5340d0d
Merge branch 'dev' of github.com:mashehu/tools into dev
mashehu Dec 19, 2023
b831fb6
debug coverage
mashehu Dec 20, 2023
a8697fc
Merge branch 'dev' of github.com:nf-core/tools into dev
mashehu Dec 20, 2023
76517c1
update action versions
mashehu Jan 2, 2024
8e52118
fix cleanup step
mashehu Jan 2, 2024
e389c8c
run small jobs still on github
mashehu Jan 2, 2024
7eb8d0b
switch to pre-commit for code linting
mashehu Jan 2, 2024
5b283d9
don't run pyupgrade for now
mashehu Jan 2, 2024
b699651
fix job name
mashehu Jan 2, 2024
e5b0f4d
debugging
mashehu Jan 2, 2024
ce1bd2f
keep coverage files
mashehu Jan 2, 2024
3b21894
test better cleanup
mashehu Jan 2, 2024
0ba7f49
fix parameter position
mashehu Jan 2, 2024
10da34d
add cleanup step to nextflow steps
mashehu Jan 2, 2024
3b2e86a
use nextflow clean
mashehu Jan 2, 2024
0f446f6
remove ssh step
mashehu Jan 2, 2024
e2137b6
test cirun.io
mashehu Jan 2, 2024
b729141
don't set AGENT_TOOLSDIRECTORY
mashehu Jan 2, 2024
a37f0e4
add java setup step
mashehu Jan 2, 2024
af55c34
use general gitlab branch
mashehu Jan 2, 2024
2c9e443
change image id back
mashehu Jan 2, 2024
18090ff
debug cleanup step
mashehu Jan 4, 2024
fc05f53
Merge branch 'dev' of github.com:nf-core/tools into parallelize-pytes…
mashehu Jan 4, 2024
32dcbf3
use sudo rm
mashehu Jan 4, 2024
e81b658
run everything on our own runners again
mashehu Jan 4, 2024
1cffa1e
use correct gitlab branch
mashehu Jan 4, 2024
f7fe4f0
use java from runners
mashehu Jan 4, 2024
fbe7da6
Merge branch 'dev' of github.com:nf-core/tools into parallelize-pytes…
mashehu Jan 4, 2024
2953465
test coverage for one file
mashehu Jan 4, 2024
af98e0c
Merge branch 'dev' of github.com:nf-core/tools into parallelize-pytes…
mashehu Jan 4, 2024
418e978
run individual test also parallel
mashehu Jan 4, 2024
e822600
add github token to setup-python
mashehu Jan 4, 2024
3f5310d
use same directory structure for coverage
mashehu Jan 4, 2024
71c4901
don't ran everything parallel
mashehu Jan 4, 2024
ecb21e4
move coveragerc
mashehu Jan 5, 2024
02ddfd2
Merge branch 'dev' of github.com:nf-core/tools into parallelize-pytes…
mashehu Jan 5, 2024
1614129
remove debugging code
mashehu Jan 5, 2024
bcaef36
run some template variations on github
mashehu Jan 5, 2024
2f0698c
remove more left over code
mashehu Jan 5, 2024
b4d3367
set correct runner
mashehu Jan 5, 2024
b00ec69
set profile depending on runner
mashehu Jan 5, 2024
2735ee8
set profile docker for github runners
mashehu Jan 5, 2024
8227bc3
use pre-commit for all linting jobs
mashehu Jan 5, 2024
cd75ff9
fix editorconfig
mashehu Jan 5, 2024
c9377c4
fix .editorconfig and makefile
mashehu Jan 5, 2024
438e85e
Merge branch 'dev' of github.com:nf-core/tools into parallelize-pytes…
mashehu Jan 5, 2024
43d56d5
update changelog
mashehu Jan 5, 2024
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
5 changes: 4 additions & 1 deletion .github/.coveragerc
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
[run]
omit = nf_core/pipeline-template/*
omit = nf_core/*-template/*
source = nf_core
relative_files = True

10 changes: 10 additions & 0 deletions .github/workflows/create-lint-wf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ jobs:
- "23.04.0"
- "latest-everything"
steps:
- name: go to subdirectory and change nextflow workdir
run: |
mkdir -p create-lint-wf
cd create-lint-wf
export NXF_WORK=$(pwd)

# Get the repo code
- uses: actions/checkout@v4
name: Check out source-code repository
Expand Down Expand Up @@ -136,3 +142,7 @@ jobs:
with:
name: nf-core-log-file
path: create-lint-wf/log.txt

- name: Cleanup work directory
run: sudo rm -rf create-lint-wf
if: always()
25 changes: 21 additions & 4 deletions .github/workflows/create-test-lint-wf-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,32 @@ env:

jobs:
RunTestWorkflow:
runs-on: ubuntu-latest
runs-on: ${{ matrix.runner }}
env:
NXF_ANSI_LOG: false
strategy:
matrix:
TEMPLATE:
- "template_skip_all.yml"
- "template_skip_github_badges.yml"
- "template_skip_igenomes.yml"
- "template_skip_ci.yml"
- "template_skip_nf_core_configs.yml"
runner: ["self-hosted"]
profile: ["self_hosted_runner"]
include:
- TEMPLATE: "template_skip_all.yml"
runner: ubuntu-latest
profile: "docker"
- TEMPLATE: "template_skip_nf_core_configs.yml"
runner: ubuntu-latest
profile: "docker"

steps:
- name: go to working directory
run: |
mkdir -p create-lint-wf-template
cd create-lint-wf-template
export NXF_WORK=$(pwd)

- uses: actions/checkout@v4
name: Check out source-code repository

Expand Down Expand Up @@ -83,7 +96,7 @@ jobs:
- name: run the pipeline
run: |
cd create-test-lint-wf
nextflow run my-prefix-testpipeline -profile test,docker --outdir ./results
nextflow run my-prefix-testpipeline -profile test,${{matrix.profile}} --outdir ./results

# Remove results folder before linting
- name: remove results folder
Expand Down Expand Up @@ -134,3 +147,7 @@ jobs:
with:
name: nf-core-log-file
path: create-test-lint-wf/artifact_files.tar

- name: Cleanup work directory
run: sudo rm -rf create-test-lint-wf
if: always()
15 changes: 13 additions & 2 deletions .github/workflows/create-test-wf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ env:

jobs:
RunTestWorkflow:
runs-on: ubuntu-latest
runs-on: self-hosted
env:
NXF_ANSI_LOG: false
strategy:
Expand All @@ -26,6 +26,12 @@ jobs:
- "23.04.0"
- "latest-everything"
steps:
- name: go to working directory
run: |
mkdir -p create-test-wf
cd create-test-wf
export NXF_WORK=$(pwd)

- uses: actions/checkout@v4
name: Check out source-code repository

Expand All @@ -49,11 +55,16 @@ jobs:
mkdir create-test-wf && cd create-test-wf
export NXF_WORK=$(pwd)
nf-core --log-file log.txt create -n testpipeline -d "This pipeline is for testing" -a "Testing McTestface" --plain
nextflow run nf-core-testpipeline -profile test,docker --outdir ./results
nextflow run nf-core-testpipeline -profile test,self_hosted_runner --outdir ./results

- name: Upload log file artifact
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: nf-core-log-file
path: create-test-wf/log.txt

- name: Cleanup work directory
# cleanup work directory
run: sudo rm -rf create-test-wf
if: always()
2 changes: 1 addition & 1 deletion .github/workflows/fix-linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
contains(github.event.comment.html_url, '/pull/') &&
contains(github.event.comment.body, '@nf-core-bot fix linting') &&
github.repository == 'nf-core/tools'
runs-on: ubuntu-latest
runs-on: self-hosted
steps:
# Use the @nf-core-bot token to check out so we can push later
- uses: actions/checkout@v4
Expand Down
15 changes: 8 additions & 7 deletions .github/workflows/lint-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,20 @@ concurrency:

jobs:
Pre-commit:
name: Pre-commit
runs-on: ["ubuntu-latest"]
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5

- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.11
cache: "pip"

- name: Install dependencies
run: |
python -m pip install --upgrade pip -r requirements-dev.txt
pip install -e .
- name: Install pre-commit
run: pip install pre-commit

- name: Run pre-commit
run: pre-commit run --all-files
2 changes: 1 addition & 1 deletion .github/workflows/push_dockerhub_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ concurrency:
jobs:
push_dockerhub:
name: Push new Docker image to Docker Hub (dev)
runs-on: self-hosted
runs-on: ubuntu-latest
# Only run for the nf-core repo, for releases and merged PRs
if: ${{ github.repository == 'nf-core/tools' }}
env:
Expand Down
105 changes: 92 additions & 13 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ on:
- "CHANGELOG.md"
release:
types: [published]
workflow_dispatch:

# Cancel if a newer run is started
# Cancel if a newer run with the same workflow name is queued
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
Expand All @@ -25,7 +26,7 @@ env:

jobs:
setup:
runs-on: ["ubuntu-latest"]
runs-on: "ubuntu-latest"
strategy:
matrix:
python-version: ["3.8", "3.11"]
Expand All @@ -44,12 +45,36 @@ jobs:
runner: ${{ matrix.runner }}
run-tests: ${{ steps.conditions.outputs.run-tests }}

# create a test matrix based on all python files in /tests
list_tests:
name: Get test file matrix
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4
name: Check out source-code repository

- name: List tests
id: list_tests
run: |
echo "tests=$(find tests/test_* | tac | sed 's/tests\///g' | jq -R -s -c '{test: (split("\n")[:-1])}')" >> $GITHUB_OUTPUT
outputs:
tests: ${{ steps.list_tests.outputs.tests }}

test:
name: Test with Python ${{ needs.setup.outputs.python-version }} on ${{ needs.setup.outputs.runner }}
needs: setup
if: ${{ needs.setup.outputs.run-tests}}
runs-on: ${{ needs.setup.outputs.runner }}
name: Run ${{matrix.test}} with Python ${{ needs.setup.outputs.python-version }} on ${{ needs.setup.outputs.runner }}
needs: [setup, list_tests]
if: ${{ needs.setup.outputs.run-tests }}
runs-on: self-hosted
strategy:
matrix: ${{ fromJson(needs.list_tests.outputs.tests) }}
fail-fast: false # run all tests even if one fails
steps:
- name: go to subdirectory and change nextflow workdir
run: |
mkdir -p pytest
cd pytest
export NXF_WORK=$(pwd)

- uses: actions/checkout@v4
name: Check out source-code repository

Expand All @@ -58,6 +83,7 @@ jobs:
with:
python-version: ${{ needs.setup.outputs.python-version }}
cache: "pip"
token: ${{ secrets.GITHUB_TOKEN }}

- name: Install dependencies
run: |
Expand All @@ -71,14 +97,13 @@ jobs:
sudo apt remove -y git git-man
sudo add-apt-repository --remove ppa:git-core/ppa
sudo apt install -y git

- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m')" >> $GITHUB_ENV

- name: Install Nextflow
uses: nf-core/setup-nextflow@v1
with:
version: "latest-everything"

- name: Cache nf-test installation
id: cache-software
Expand All @@ -95,11 +120,65 @@ jobs:
wget -qO- https://code.askimed.com/install/nf-test | bash
sudo mv nf-test /usr/local/bin/

- name: move coveragerc file up
run: |
mv .github/.coveragerc .

- name: Test with pytest
run: python3 -m pytest tests/ --color=yes --cov-report=xml --cov-config=.github/.coveragerc --cov=nf_core
run: |
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"
exit 0
elif [ "${exit_code}" -ne 0 ]; then
echo "Tests failed with exit code ${exit_code}"
exit 1
fi

- name: Upload coverage
uses: actions/upload-artifact@v4
with:
name: coverage_${{ matrix.test }}
path: .coverage

coverage:
needs: test
runs-on: self-hosted
steps:
- name: go to subdirectory
run: |
mkdir -p pytest
cd pytest

- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
env:
AGENT_TOOLSDIRECTORY: /opt/actions-runner/_work/tools/tools/
with:
python-version: 3.11
cache: "pip"

- name: Install dependencies
run: |
python -m pip install --upgrade pip -r requirements-dev.txt
pip install -e .

- name: move coveragerc file up
run: |
mv .github/.coveragerc .

- name: Download all artifacts
uses: actions/download-artifact@v4
- name: Run coverage
run: |
coverage combine --keep coverage*/.coverage*
coverage report
coverage xml

- uses: codecov/codecov-action@v1
name: Upload code coverage report
- uses: codecov/codecov-action@v3
with:
if: success()
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ concurrency:

jobs:
get-pipelines:
runs-on: ubuntu-latest
runs-on: self-hosted
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tools-api-docs-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ concurrency:
jobs:
api-docs:
name: Build & push Sphinx API docs
runs-on: self-hosted
runs-on: ubuntu-latest

steps:
- name: Check out source-code repository
Expand Down
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

### Template

- Use `pre-commit` to lint files in GitHub CI ([#2635](https://github.com/nf-core/tools/pull/2635))

### Download

### Linting
Expand All @@ -14,6 +16,8 @@

### General

- Run CI-pytests for nf-core tools on self-hosted runners ([#2550](https://github.com/nf-core/tools/pull/2550))

- Add Ruff linter and formatter replacing Black, isort and pyupgrade ([#2620](https://github.com/nf-core/tools/pull/2620))
- Update pre-commit hook pre-commit/mirrors-mypy to v1.8.0 ([#2630](https://github.com/nf-core/tools/pull/2630))
- Update mshick/add-pr-comment action to v2 ([#2632](https://github.com/nf-core/tools/pull/2632))
Expand All @@ -24,7 +28,6 @@

- Rename `release-announcments.yml` to `release-announcements.yml` ([#2610](https://github.com/nf-core/tools/pull/2610))
- Fix `nextflow.config` `docker.runOptions` ([#2607](https://github.com/nf-core/tools/pull/2607))
- Use `pre-commit` to lint files in GitHub CI ([#2635](https://github.com/nf-core/tools/pull/2635))

### General

Expand Down
3 changes: 3 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ coverage:
default:
threshold: 5%
patch: off
comment:
layout: "condensed_header, condensed_files, condensed_footer" # add "condensed_" to "header", "files" and "footer"
hide_project_coverage: TRUE # set to true
2 changes: 1 addition & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
GITLAB_BRANCH_ORG_PATH_BRANCH = "org-path"
GITLAB_BRANCH_TEST_OLD_SHA = "e772abc22c1ff26afdf377845c323172fb3c19ca"
GITLAB_BRANCH_TEST_NEW_SHA = "7d73e21f30041297ea44367f2b4fd4e045c0b991"
GITLAB_NFTEST_BRANCH = "nf-test-tests"
GITLAB_NFTEST_BRANCH = "nf-test-tests-self-hosted-runners"


def with_temporary_folder(func: Callable[..., Any]) -> Callable[..., Any]:
Expand Down
Loading