Skip to content

Commit

Permalink
Merge pull request #3481 from edanielson-ginkgo/config_repos_from_env…
Browse files Browse the repository at this point in the history
…_vars

Configure the default module repository, branch, and path from environment variables.
  • Loading branch information
edanielson-ginkgo authored Mar 6, 2025
2 parents 8451416 + b221780 commit f7207a5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
### Modules

- increase meta index for multiple input channels ([#3463](https://github.com/nf-core/tools/pull/3463))
- Configure the default module repository, branch, and path from environment variables. ([#3481](https://github.com/nf-core/tools/pull/3481))

### Subworkflows

Expand Down
7 changes: 4 additions & 3 deletions nf_core/components/components_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import os
import re
from pathlib import Path
from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Union
Expand All @@ -15,9 +16,9 @@
log = logging.getLogger(__name__)

# Constants for the nf-core/modules repo used throughout the module files
NF_CORE_MODULES_NAME = "nf-core"
NF_CORE_MODULES_REMOTE = "https://github.com/nf-core/modules.git"
NF_CORE_MODULES_DEFAULT_BRANCH = "master"
NF_CORE_MODULES_NAME = os.environ.get("NF_CORE_MODULES_NAME", "nf-core")
NF_CORE_MODULES_REMOTE = os.environ.get("NF_CORE_MODULES_REMOTE", "https://github.com/nf-core/modules.git")
NF_CORE_MODULES_DEFAULT_BRANCH = os.environ.get("NF_CORE_MODULES_DEFAULT_BRANCH", "master")


def get_repo_info(directory: Path, use_prompt: Optional[bool] = True) -> Tuple[Path, Optional[str], str]:
Expand Down
24 changes: 24 additions & 0 deletions tests/components/test_components_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import importlib
import os
from unittest import mock

import responses

import nf_core.components.components_utils
Expand Down Expand Up @@ -55,3 +59,23 @@ def test_get_biotools_ch_info_warn(self):
response = nf_core.components.components_utils.get_biotools_response("bpipe")
nf_core.components.components_utils.get_channel_info_from_biotools(response, "test")
assert "Could not find an EDAM ontology term for 'test'" in self.caplog.text

def test_environment_variables_override(self):
"""Test environment variables override default values"""
mock_env = {
"NF_CORE_MODULES_NAME": "custom-name",
"NF_CORE_MODULES_REMOTE": "https://custom-repo.git",
"NF_CORE_MODULES_DEFAULT_BRANCH": "custom-branch",
}

try:
with mock.patch.dict(os.environ, mock_env):
importlib.reload(nf_core.components.components_utils)
assert nf_core.components.components_utils.NF_CORE_MODULES_NAME == mock_env["NF_CORE_MODULES_NAME"]
assert nf_core.components.components_utils.NF_CORE_MODULES_REMOTE == mock_env["NF_CORE_MODULES_REMOTE"]
assert (
nf_core.components.components_utils.NF_CORE_MODULES_DEFAULT_BRANCH
== mock_env["NF_CORE_MODULES_DEFAULT_BRANCH"]
)
finally:
importlib.reload(nf_core.components.components_utils)

0 comments on commit f7207a5

Please sign in to comment.