forked from SciLifeLab/TACA
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request SciLifeLab#413 from kedhammar/pytest-ci
Implement CI testing and increase testing coverage
- Loading branch information
Showing
17 changed files
with
416 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Test code | ||
on: [push, pull_request] | ||
|
||
jobs: | ||
pytest: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
pip install -r requirements-dev.txt | ||
- name: Install TACA | ||
run: pip install -e . | ||
- name: pytest | ||
# Options are configured in pyproject.toml | ||
run: pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ __pycache__ | |
.vscode | ||
.ruff_cache | ||
.mypy_cache | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,42 @@ | ||
title = "taca" | ||
|
||
# === LINTING ================================================================ | ||
|
||
[tool.ruff.lint] | ||
select =[ | ||
select = [ | ||
# Ruff default rules | ||
# ------------------------------ | ||
"E4", # pycodestyle Imports | ||
"E7", # pycodestyle Statements | ||
"E9", # pycodestyle Runtime | ||
"F", # Pyflakes | ||
"E4", # pycodestyle Imports | ||
"E7", # pycodestyle Statements | ||
"E9", # pycodestyle Runtime | ||
"F", # Pyflakes | ||
|
||
# Additional Comment | ||
# ------------------------------------------------------ | ||
"I", # isort Best-practice sorting of imports | ||
"UP", # pyupgrade Make sure syntax is up-to-date | ||
"I", # isort Best-practice sorting of imports | ||
"UP", # pyupgrade Make sure syntax is up-to-date | ||
] | ||
ignore = [ | ||
"E402", # Module level import not at top of file | ||
"E722", # Do not use bare 'except' | ||
"E741", # Ambiguous variable name | ||
] | ||
|
||
|
||
[tool.mypy] | ||
ignore_missing_imports = true | ||
follow_imports = 'skip' | ||
|
||
# === Testing ================================================================ | ||
|
||
[tool.pytest.ini_options] | ||
# Omit deprecation warnings from 3rd party packages | ||
filterwarnings = [ | ||
'ignore::DeprecationWarning:couchdb.*', | ||
'ignore::DeprecationWarning:pkg_resources.*', | ||
] | ||
addopts = "--cov=./taca --cov-report term-missing -vv --cache-clear tests/pytest/" | ||
|
||
[tool.coverage.run] | ||
# The comment "# pragma: no cover" can be used to exclude a line from coverage | ||
source = ["taca"] | ||
omit = ["**/__init__.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ mock | |
sphinx | ||
sphinx-rtd-theme | ||
pytest | ||
pytest-cov | ||
ipython | ||
ipdb | ||
ruff | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import os | ||
import tempfile | ||
|
||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def create_dirs(): | ||
"""Create the bottom-level file-tree to be used for all tests: | ||
tmp | ||
├── log | ||
│ ├── transfer_minion.tsv | ||
│ └── transfer_promethion.tsv | ||
├── miarka | ||
│ ├── minion | ||
│ │ └── qc | ||
│ └── promethion | ||
├── minknow_reports | ||
├── ngi-nas-ns | ||
│ ├── minion_data | ||
│ ├── promethion_data | ||
│ └── samplesheets | ||
│ └── anglerfish | ||
└── sequencing | ||
├── minion | ||
│ ├── nosync | ||
│ └── qc | ||
│ └── nosync | ||
└── promethion | ||
└── nosync | ||
--> Return the the temporary directory object | ||
""" | ||
tmp = tempfile.TemporaryDirectory() | ||
|
||
# CREATE DIR STRUCTURE | ||
|
||
# Sequencing data | ||
os.makedirs(f"{tmp.name}/sequencing/promethion/nosync") | ||
os.makedirs(f"{tmp.name}/sequencing/minion/nosync") | ||
os.makedirs(f"{tmp.name}/sequencing/minion/qc/nosync") | ||
|
||
# Non-sensitive metadata | ||
os.makedirs(f"{tmp.name}/ngi-nas-ns/promethion_data") | ||
os.makedirs(f"{tmp.name}/ngi-nas-ns/minion_data") | ||
os.makedirs(f"{tmp.name}/ngi-nas-ns/samplesheets/anglerfish") | ||
|
||
# Reports for GenStat | ||
os.makedirs(f"{tmp.name}/minknow_reports") | ||
|
||
# Logs | ||
os.makedirs(f"{tmp.name}/log") | ||
open(f"{tmp.name}/log/transfer_promethion.tsv", "w").close() | ||
open(f"{tmp.name}/log/transfer_minion.tsv", "w").close | ||
|
||
# Analysis server destination dirs | ||
os.makedirs(f"{tmp.name}/miarka/promethion") | ||
os.makedirs(f"{tmp.name}/miarka/minion/qc") | ||
|
||
yield tmp | ||
|
||
tmp.cleanup() |
Oops, something went wrong.