diff --git a/.github/scripts/check_version_snapshot.py b/.github/scripts/check_version_snapshot.py new file mode 100755 index 00000000000..85abb816418 --- /dev/null +++ b/.github/scripts/check_version_snapshot.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 +# /// script +# requires-python = ">=3.10" +# dependencies = [] +# /// + +"""Check that versions are captured not hashed.""" + +import argparse +import re +from pathlib import Path +from typing import Optional, Sequence + + +def check_snapshotting(lines: list[str], path: Path) -> None: + """Check each line for proper snapshotting.""" + good_pattern = re.compile( + r'snapshot\(path\(process\.out\.versions\.get\(0\)\)\.yaml\)\.match\("versions"\)|path\(process\.out\.versions\.get\(0\)\)\.yaml' + ) + bad_pattern = re.compile(r"process\.out\.versions|snapshot\(process\.out\)\.match\(\)") + + for line_number, line in enumerate(lines, start=1): + if bad_pattern.search(line) and not good_pattern.search(line): + print(f"Improper snapshotting in {path} at line {line_number}: {line.strip()}") + + +def main(argv: Optional[Sequence[str]] = None) -> None: + """Check that versions are captured not hashed.""" + parser = argparse.ArgumentParser() + parser.add_argument("paths", nargs="*", type=Path) + args = parser.parse_args(argv) + for path in args.paths: + with path.open() as f: + lines = f.readlines() + check_snapshotting(lines, path) + + +if __name__ == "__main__": + main() diff --git a/.github/scripts/conda_env_sorter.py b/.github/scripts/conda_env_sorter.py new file mode 100755 index 00000000000..6c42e65f0cd --- /dev/null +++ b/.github/scripts/conda_env_sorter.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python3 +# /// script +# requires-python = ">=3.10" +# dependencies = [ +# "ruamel.yaml", +# ] +# /// + +"""Sort dependencies in conda environment files.""" + +import argparse +from pathlib import Path +from typing import Optional, Sequence + +import ruamel.yaml + +yaml = ruamel.yaml.YAML() +yaml.indent(mapping=2, sequence=2, offset=2) # Set indentation to 2 spaces + + +def main(argv: Optional[Sequence[str]] = None) -> None: + """Sort dependencies in conda environment files.""" + parser = argparse.ArgumentParser() + parser.add_argument("paths", nargs="*", type=Path) + args = parser.parse_args(argv) + for path in args.paths: + with path.open() as f: + lines = f.readlines() + + # Define the schema lines to be added if missing + schema_lines = [ + "---\n", + "# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json\n", + ] + + # Check if the first two lines match the expected schema lines + if lines[:2] == schema_lines: + header = lines[:2] + content = lines[2:] + else: + # Add schema lines if they are missing + header = schema_lines + content = lines + + doc = yaml.load("".join(content)) + dicts = [] + others = [] + + for term in doc["dependencies"]: + if isinstance(term, dict): + dicts.append(term) + else: + others.append(term) + others.sort(key=str) + for dict_term in dicts: + for value in dict_term.values(): + if isinstance(value, list): + value.sort(key=str) + dicts.sort(key=str) + doc["dependencies"].clear() + doc["dependencies"].extend(others) + doc["dependencies"].extend(dicts) + + with path.open("w") as f: + f.writelines(header) + yaml.dump(doc, f) + + +if __name__ == "__main__": + main() diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b6517edd742..c6d913aba53 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,22 @@ repos: + - repo: local + hooks: + - id: conda-env-sorter + name: Sort dependencies in conda environment files. + entry: ./.github/scripts/conda_env_sorter.py + language: python + files: environment + types: [yaml] + additional_dependencies: ["ruamel.yaml"] + - repo: local + hooks: + - id: check-version-snapshot + name: Versions are captured not hashed + entry: ./.github/scripts/check_version_snapshot.py + language: python + files: \.nf\.test$ + types: [file] + additional_dependencies: [] - repo: https://github.com/pre-commit/mirrors-prettier rev: "v3.1.0" hooks: diff --git a/modules/nf-core/basicpy/environment.yml b/modules/nf-core/basicpy/environment.yml deleted file mode 100644 index 3cebeff05bf..00000000000 --- a/modules/nf-core/basicpy/environment.yml +++ /dev/null @@ -1,3 +0,0 @@ -channels: - - conda-forge - - bioconda diff --git a/modules/nf-core/bowtie/align/environment.yml b/modules/nf-core/bowtie/align/environment.yml index 61bd69c2c7a..b5a02be1cc8 100644 --- a/modules/nf-core/bowtie/align/environment.yml +++ b/modules/nf-core/bowtie/align/environment.yml @@ -2,7 +2,7 @@ channels: - conda-forge - bioconda dependencies: - # renovate: datasource=conda depName=bioconda/bowtie - - bioconda::bowtie=1.3.1 # renovate: datasource=conda depName=bioconda/samtools - bioconda::samtools=1.20 + # renovate: datasource=conda depName=bioconda/bowtie + - bioconda::bowtie=1.3.1 diff --git a/modules/nf-core/cellrangeratac/count/environment.yml b/modules/nf-core/cellrangeratac/count/environment.yml deleted file mode 100644 index 3cebeff05bf..00000000000 --- a/modules/nf-core/cellrangeratac/count/environment.yml +++ /dev/null @@ -1,3 +0,0 @@ -channels: - - conda-forge - - bioconda diff --git a/modules/nf-core/cellrangeratac/mkfastq/environment.yml b/modules/nf-core/cellrangeratac/mkfastq/environment.yml deleted file mode 100644 index 3cebeff05bf..00000000000 --- a/modules/nf-core/cellrangeratac/mkfastq/environment.yml +++ /dev/null @@ -1,3 +0,0 @@ -channels: - - conda-forge - - bioconda diff --git a/modules/nf-core/cellrangeratac/mkref/environment.yml b/modules/nf-core/cellrangeratac/mkref/environment.yml deleted file mode 100644 index 3cebeff05bf..00000000000 --- a/modules/nf-core/cellrangeratac/mkref/environment.yml +++ /dev/null @@ -1,3 +0,0 @@ -channels: - - conda-forge - - bioconda diff --git a/modules/nf-core/coreograph/environment.yml b/modules/nf-core/coreograph/environment.yml deleted file mode 100644 index 3cebeff05bf..00000000000 --- a/modules/nf-core/coreograph/environment.yml +++ /dev/null @@ -1,3 +0,0 @@ -channels: - - conda-forge - - bioconda diff --git a/modules/nf-core/ensemblvep/environment.yml b/modules/nf-core/ensemblvep/environment.yml index e94bfeb2cb0..7818cfa6bd4 100644 --- a/modules/nf-core/ensemblvep/environment.yml +++ b/modules/nf-core/ensemblvep/environment.yml @@ -1,5 +1,3 @@ -# You can use this file to create a conda environment for this module: -# conda env create -f environment.yml channels: - conda-forge - bioconda diff --git a/modules/nf-core/fastk/histex/environment.yml b/modules/nf-core/fastk/histex/environment.yml deleted file mode 100644 index 3cebeff05bf..00000000000 --- a/modules/nf-core/fastk/histex/environment.yml +++ /dev/null @@ -1,3 +0,0 @@ -channels: - - conda-forge - - bioconda diff --git a/modules/nf-core/fastk/merge/environment.yml b/modules/nf-core/fastk/merge/environment.yml deleted file mode 100644 index 3cebeff05bf..00000000000 --- a/modules/nf-core/fastk/merge/environment.yml +++ /dev/null @@ -1,3 +0,0 @@ -channels: - - conda-forge - - bioconda diff --git a/modules/nf-core/fcs/fcsgx/environment.yml b/modules/nf-core/fcs/fcsgx/environment.yml deleted file mode 100644 index 3cebeff05bf..00000000000 --- a/modules/nf-core/fcs/fcsgx/environment.yml +++ /dev/null @@ -1,3 +0,0 @@ -channels: - - conda-forge - - bioconda diff --git a/modules/nf-core/gatk4/variantstotable/environment.yml b/modules/nf-core/gatk4/variantstotable/environment.yml index d04a469c944..0fab9f885c5 100644 --- a/modules/nf-core/gatk4/variantstotable/environment.yml +++ b/modules/nf-core/gatk4/variantstotable/environment.yml @@ -1,6 +1,6 @@ # yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json + --- -# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json channels: - conda-forge - bioconda diff --git a/modules/nf-core/genescopefk/environment.yml b/modules/nf-core/genescopefk/environment.yml deleted file mode 100644 index 3cebeff05bf..00000000000 --- a/modules/nf-core/genescopefk/environment.yml +++ /dev/null @@ -1,3 +0,0 @@ -channels: - - conda-forge - - bioconda diff --git a/modules/nf-core/hlala/preparegraph/environment.yml b/modules/nf-core/hlala/preparegraph/environment.yml index 3cebeff05bf..3e7bf59bb49 100644 --- a/modules/nf-core/hlala/preparegraph/environment.yml +++ b/modules/nf-core/hlala/preparegraph/environment.yml @@ -1,3 +1,5 @@ channels: - conda-forge - bioconda +dependencies: + - bioconda::hla-la=1.0.4 diff --git a/modules/nf-core/ilastik/multicut/environment.yml b/modules/nf-core/ilastik/multicut/environment.yml deleted file mode 100644 index 3cebeff05bf..00000000000 --- a/modules/nf-core/ilastik/multicut/environment.yml +++ /dev/null @@ -1,3 +0,0 @@ -channels: - - conda-forge - - bioconda diff --git a/modules/nf-core/ilastik/pixelclassification/environment.yml b/modules/nf-core/ilastik/pixelclassification/environment.yml deleted file mode 100644 index 3cebeff05bf..00000000000 --- a/modules/nf-core/ilastik/pixelclassification/environment.yml +++ /dev/null @@ -1,3 +0,0 @@ -channels: - - conda-forge - - bioconda diff --git a/modules/nf-core/merquryfk/katcomp/environment.yml b/modules/nf-core/merquryfk/katcomp/environment.yml deleted file mode 100644 index 3cebeff05bf..00000000000 --- a/modules/nf-core/merquryfk/katcomp/environment.yml +++ /dev/null @@ -1,3 +0,0 @@ -channels: - - conda-forge - - bioconda diff --git a/modules/nf-core/merquryfk/katgc/environment.yml b/modules/nf-core/merquryfk/katgc/environment.yml deleted file mode 100644 index 3cebeff05bf..00000000000 --- a/modules/nf-core/merquryfk/katgc/environment.yml +++ /dev/null @@ -1,3 +0,0 @@ -channels: - - conda-forge - - bioconda diff --git a/modules/nf-core/regtools/junctionsextract/environment.yml b/modules/nf-core/regtools/junctionsextract/environment.yml index 2b615890f84..d6cbfc1e982 100644 --- a/modules/nf-core/regtools/junctionsextract/environment.yml +++ b/modules/nf-core/regtools/junctionsextract/environment.yml @@ -1,6 +1,5 @@ -# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json channels: - conda-forge - bioconda dependencies: - - "bioconda::regtools=1.0.0" + - bioconda::regtools=1.0.0 diff --git a/modules/nf-core/snpeff/environment.yml b/modules/nf-core/snpeff/environment.yml index 6ac55ab765a..4c7a46b77ff 100644 --- a/modules/nf-core/snpeff/environment.yml +++ b/modules/nf-core/snpeff/environment.yml @@ -1,5 +1,6 @@ -# You can use this file to create a conda environment for this module: -# conda env create -f environment.yml +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json + +--- channels: - conda-forge - bioconda diff --git a/modules/nf-core/trgt/merge/environment.yml b/modules/nf-core/trgt/merge/environment.yml index 614dc872b7b..6f2e029e311 100644 --- a/modules/nf-core/trgt/merge/environment.yml +++ b/modules/nf-core/trgt/merge/environment.yml @@ -1,4 +1,6 @@ # yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json + +--- channels: - conda-forge - bioconda diff --git a/modules/nf-core/trgt/plot/environment.yml b/modules/nf-core/trgt/plot/environment.yml index 614dc872b7b..6f2e029e311 100644 --- a/modules/nf-core/trgt/plot/environment.yml +++ b/modules/nf-core/trgt/plot/environment.yml @@ -1,4 +1,6 @@ # yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json + +--- channels: - conda-forge - bioconda diff --git a/modules/nf-core/universc/environment.yml b/modules/nf-core/universc/environment.yml deleted file mode 100644 index 3cebeff05bf..00000000000 --- a/modules/nf-core/universc/environment.yml +++ /dev/null @@ -1,3 +0,0 @@ -channels: - - conda-forge - - bioconda