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

Add template #1

Merged
merged 38 commits into from
Mar 12, 2025
Merged
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
e148639
Move to pixi
irm-codebase Mar 4, 2025
467e7a9
Separete pyproject into individual configuration files
irm-codebase Mar 4, 2025
ca4796b
Add pixi tests
irm-codebase Mar 4, 2025
34cb537
Move integration tests within the template
irm-codebase Mar 4, 2025
2d46514
Merge branch 'main' into add-template
irm-codebase Mar 4, 2025
b11be15
update README
irm-codebase Mar 4, 2025
18166bd
Add scheduled workflow for copier template updates.
irm-codebase Mar 5, 2025
353376e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 5, 2025
5aec108
Add PR CI and avoid snakefmt template false positive
irm-codebase Mar 5, 2025
2828bee
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 5, 2025
1fb55eb
Fix CI
irm-codebase Mar 5, 2025
cf6592d
use miniconda incubator in CI
irm-codebase Mar 5, 2025
cb225a9
Add local mamba dependency
irm-codebase Mar 5, 2025
d83d963
switch mamba-> conda
irm-codebase Mar 5, 2025
7146a52
Try pixi local and mini-forge in global
irm-codebase Mar 5, 2025
7524b37
Use pixi with conda dependency
irm-codebase Mar 5, 2025
827c665
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 5, 2025
eecaa11
Avoid windows bug: shell commands must use \"
irm-codebase Mar 5, 2025
e1898c1
Specify locations to skip for the template
irm-codebase Mar 5, 2025
a1a5d99
Add pull request CI test to the template.
irm-codebase Mar 5, 2025
af272a1
update readme and changelog
irm-codebase Mar 5, 2025
573246b
PR fixes: add examples to docs, avoid name confusion
irm-codebase Mar 6, 2025
30e1198
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 6, 2025
d1d896d
Improve the explanation in the README
irm-codebase Mar 6, 2025
86fc03d
Use conda-forge to install clio-tools
irm-codebase Mar 6, 2025
65d0e4b
PR fixes: no pixi shell use, remove unused mkdocs plugin, fix github …
irm-codebase Mar 7, 2025
81f1b95
Fix integration test configuration path
irm-codebase Mar 7, 2025
cf5fb7f
Fix relative path bug
irm-codebase Mar 7, 2025
ff5c1b6
Minor docs updates
brynpickering Mar 7, 2025
bb24ded
Update highlight to tip
brynpickering Mar 7, 2025
977c0ba
Remove attempt at highlighting
brynpickering Mar 7, 2025
13cbe9d
Update tests/utils/simple_answers.yaml
sjpfenninger Mar 11, 2025
1098a91
Update tests/utils/simple_answers.yaml
sjpfenninger Mar 11, 2025
d11f453
Update copier.yaml
irm-codebase Mar 11, 2025
71ff30c
Update README.md
irm-codebase Mar 11, 2025
61d9590
PR fixes: improve instructions, improve integration test.
irm-codebase Mar 11, 2025
bd0428d
Remove mermaid
irm-codebase Mar 11, 2025
e8b7571
Simplify: read the docs is optional, improve README
irm-codebase Mar 12, 2025
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
Prev Previous commit
Next Next commit
Move integration tests within the template
irm-codebase committed Mar 4, 2025
commit 34cb5377b6ca04534c701aebf89c1ce4e065292e
3 changes: 2 additions & 1 deletion template/{{ module_short_name }}/pixi.toml.jinja
Original file line number Diff line number Diff line change
@@ -20,7 +20,8 @@ snakefmt = ">=0.10.2"
snakemake-minimal = ">=8.29.0"
networkx = ">=3.4.2" # TODO: remove after clio-tools is released
cffconvert = ">=2.0.0" # TODO: remove after clio-tools is released
pydantic = ">=2.10.6"
pydantic = ">=2.10.6" # TODO: remove after clio-tools is released
pyyaml = ">=6.0.2" # TODO: remove after clio-tools is released

[pypi-dependencies]
mkdocs-mermaid2-plugin = ">=1.2.1"
36 changes: 36 additions & 0 deletions template/{{ module_short_name }}/tests/clio_test.py.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""Set of standard clio tests."""

import subprocess
from pathlib import Path

import pytest
from clio_tools.data_module import ModuleInterface


@pytest.fixture(scope="module")
def module_path():
"""Parent directory of the project."""
return Path(__file__).parent.parent


def test_interface_file(module_path):
"""The interfacing file should be correct."""
assert ModuleInterface.from_yaml(module_path / "INTERFACE.yaml")


def test_snakemake_all_failure(module_path):
"""The snakemake 'all' rule should return an error by default."""
process = subprocess.run(
"snakemake", shell=True, cwd=module_path, capture_output=True
)
assert "This workflow must be called as a snakemake module" in str(process.stderr)


def test_snakemake_integration_testing(module_path):
"""Run a light-weight test simulating someone using this module."""
assert subprocess.run(
"snakemake --use-conda",
shell=True,
check=True,
cwd=module_path / "tests/integration",
)
58 changes: 12 additions & 46 deletions tests/template_test.py
Original file line number Diff line number Diff line change
@@ -7,8 +7,8 @@
from copier import run_copy


@pytest.fixture(scope="module", params=["MIT"])
def simple_template(request, tmp_path_factory, template_path, simple_answers):
@pytest.fixture(scope="module", params=["Apache-2.0"])
def template_project(request, tmp_path_factory, template_path, simple_answers):
"""Run the template in a temporary location, for further testing."""
path = tmp_path_factory.mktemp(request.param)
modified_answers = deepcopy(simple_answers)
@@ -18,59 +18,25 @@ def simple_template(request, tmp_path_factory, template_path, simple_answers):


@pytest.fixture(scope="module")
def pixi_built(simple_template):
def pixi_built(template_project):
"""Create a pixi environment for the temporary template project."""
pixi_config = simple_template / "pixi.toml"
pixi_config = template_project / "pixi.toml"
subprocess.run(
f"pixi install --manifest-path {pixi_config}",
shell=True,
cwd=simple_template,
cwd=template_project,
check=True,
)
return simple_template

@pytest.fixture(scope="module")
def snakemake_built(pixi_built):
"""Create snakemake environments in the temporary template project."""
subprocess.run(
"pixi run snakemake --conda-create-envs-only",
shell=True,
cwd=pixi_built,
check=True
)
return pixi_built
return template_project


def test_template_license(simple_template):
"""Generated license files should match the copier request."""
assert (simple_template / "LICENSE").exists()


def test_citation_file(pixi_built):
"""The generated citation file should be valid."""
citation_file = pixi_built / "CITATION.cff"
def test_mkdocs_build(pixi_built):
"""The template's mkdocs should build without issues."""
assert subprocess.run(
f"pixi run cffconvert -i {citation_file.name} --validate",
shell=True,
check=True,
cwd=pixi_built,
"pixi run mkdocs build", shell=True, check=True, cwd=pixi_built
)


def test_mkdocs_build(pixi_built):
"""Mkdocs should build without issues."""
assert subprocess.run("pixi run mkdocs build", shell=True, check=True, cwd=pixi_built)


def test_snakemake_all_failure(snakemake_built):
"""The 'all' rule should return an error by default."""
process = subprocess.run("pixi run snakemake", shell=True, cwd=snakemake_built, capture_output=True)
assert "This workflow must be called as a snakemake module" in str(process.stderr)


def test_snakemake_integration_testing(snakemake_built):
"""The automatic integration test should run by default."""
assert subprocess.run("pixi run snakemake --use-conda",
check=True,
cwd=snakemake_built / "tests/integration",
)
def test_pytest(pixi_built):
"""The template's tests should pass by default."""
assert subprocess.run("pixi run pytest", shell=True, check=True, cwd=pixi_built)