-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* configure pre-commit and add some metadata to pyproject * add linting ci workflow * add pytest in dev dependencies * add basic example functions and tests with CI
- Loading branch information
1 parent
dbdaee9
commit 91b5334
Showing
8 changed files
with
264 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Lint | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.x' | ||
- uses: pre-commit/[email protected] |
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,29 @@ | ||
name: Unit Tests | ||
|
||
on: | ||
push: | ||
branches: ["main"] | ||
pull_request: | ||
branches: ["maint"] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
test: | ||
name: Run unit tests on ${{ matrix.os }} with Python ${{ matrix.python-version }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest, macos-latest] | ||
python-version: ['3.9', '3.10', '3.11', '3.12'] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: snok/install-poetry@v1 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
cache: poetry | ||
- name: Run unit tests | ||
run: make test |
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,24 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.5.0 | ||
hooks: | ||
- id: check-yaml | ||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
rev: v0.2.2 | ||
hooks: | ||
- id: ruff | ||
args: [ --fix ] | ||
- id: ruff-format | ||
- repo: https://github.com/codespell-project/codespell | ||
rev: v2.3.0 | ||
hooks: | ||
- id: codespell | ||
additional_dependencies: | ||
- tomli | ||
- repo: https://github.com/python-poetry/poetry | ||
rev: '1.7.1' | ||
hooks: | ||
- id: poetry-check | ||
|
||
default_language_version: | ||
python: python3 |
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,13 @@ | ||
POETRY ?= poetry | ||
|
||
.PHONY: check.lock | ||
check.lock: | ||
@$(POETRY) check --lock | ||
|
||
.PHONY: install | ||
install: check.lock | ||
@$(POETRY) install | ||
|
||
.PHONY: test | ||
test: install | ||
@$(POETRY) run python -m pytest -v tests/unittests |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 |
---|---|---|
@@ -1,15 +1,58 @@ | ||
[tool.poetry] | ||
name = "clinicaio" | ||
version = "0.1.0" | ||
description = "" | ||
description = "A Python library for input/output management of all Clinica projects." | ||
license = "MIT" | ||
authors = ["ARAMIS Lab"] | ||
maintainers = ["Clinica developers <[email protected]>"] | ||
readme = "README.md" | ||
repository = "https://github.com/aramis-lab/clinicaio.git" | ||
packages = [{include = "clinicaio", from = "src"}] | ||
keywords = [ | ||
"bids", | ||
"image processing", | ||
"machine learning", | ||
"neuroimaging", | ||
"neuroscience" | ||
] | ||
classifiers = [ | ||
"Development Status :: 4 - Beta", | ||
"Environment :: Console", | ||
"Intended Audience :: Developers", | ||
"Intended Audience :: End Users/Desktop", | ||
"Operating System :: OS Independent", | ||
"Topic :: Scientific/Engineering :: Medical Science Apps.", | ||
"Topic :: Scientific/Engineering :: Image Processing" | ||
] | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.12" | ||
python = ">=3.9,<3.13" | ||
|
||
[tool.poetry.group.dev.dependencies] | ||
pytest = "^8.3.3" | ||
|
||
[build-system] | ||
requires = ["poetry-core"] | ||
build-backend = "poetry.core.masonry.api" | ||
|
||
[tool.ruff] | ||
target-version = "py39" | ||
line-length = 88 | ||
|
||
[tool.ruff.lint] | ||
select = [ | ||
"E", | ||
"W", | ||
"I001", | ||
"PTH", | ||
] | ||
ignore = ["E203", "E501"] | ||
|
||
[tool.ruff.lint.isort] | ||
known-first-party = ["clinicaio"] | ||
|
||
[tool.ruff.format] | ||
quote-style = "double" | ||
indent-style = "space" | ||
skip-magic-trailing-comma = false | ||
line-ending = "auto" |
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,16 @@ | ||
__all__ = ["greet"] | ||
|
||
|
||
def greet(name: str): | ||
"""Greet the person with provided name. | ||
Parameters | ||
---------- | ||
name : str | ||
The name of the person to greet. | ||
""" | ||
print(_build_greeting_message(name)) | ||
|
||
|
||
def _build_greeting_message(name: str) -> str: | ||
return f"Hello {name} !" |
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,16 @@ | ||
def test_build_greeting_message(): | ||
from clinicaio.hello import _build_greeting_message | ||
|
||
assert ( | ||
_build_greeting_message("ClinicaIO developers") | ||
== "Hello ClinicaIO developers !" | ||
) | ||
|
||
|
||
def test_greet(capsys): | ||
from clinicaio.hello import greet | ||
|
||
greet("John Doe") | ||
|
||
captured = capsys.readouterr() | ||
assert captured.out == "Hello John Doe !\n" |