Skip to content

Commit f7207a5

Browse files
Merge pull request #3481 from edanielson-ginkgo/config_repos_from_env_vars
Configure the default module repository, branch, and path from environment variables.
2 parents 8451416 + b221780 commit f7207a5

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
### Modules
2020

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

2324
### Subworkflows
2425

nf_core/components/components_utils.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
import os
23
import re
34
from pathlib import Path
45
from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Union
@@ -15,9 +16,9 @@
1516
log = logging.getLogger(__name__)
1617

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

2223

2324
def get_repo_info(directory: Path, use_prompt: Optional[bool] = True) -> Tuple[Path, Optional[str], str]:

tests/components/test_components_utils.py

+24
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import importlib
2+
import os
3+
from unittest import mock
4+
15
import responses
26

37
import nf_core.components.components_utils
@@ -55,3 +59,23 @@ def test_get_biotools_ch_info_warn(self):
5559
response = nf_core.components.components_utils.get_biotools_response("bpipe")
5660
nf_core.components.components_utils.get_channel_info_from_biotools(response, "test")
5761
assert "Could not find an EDAM ontology term for 'test'" in self.caplog.text
62+
63+
def test_environment_variables_override(self):
64+
"""Test environment variables override default values"""
65+
mock_env = {
66+
"NF_CORE_MODULES_NAME": "custom-name",
67+
"NF_CORE_MODULES_REMOTE": "https://custom-repo.git",
68+
"NF_CORE_MODULES_DEFAULT_BRANCH": "custom-branch",
69+
}
70+
71+
try:
72+
with mock.patch.dict(os.environ, mock_env):
73+
importlib.reload(nf_core.components.components_utils)
74+
assert nf_core.components.components_utils.NF_CORE_MODULES_NAME == mock_env["NF_CORE_MODULES_NAME"]
75+
assert nf_core.components.components_utils.NF_CORE_MODULES_REMOTE == mock_env["NF_CORE_MODULES_REMOTE"]
76+
assert (
77+
nf_core.components.components_utils.NF_CORE_MODULES_DEFAULT_BRANCH
78+
== mock_env["NF_CORE_MODULES_DEFAULT_BRANCH"]
79+
)
80+
finally:
81+
importlib.reload(nf_core.components.components_utils)

0 commit comments

Comments
 (0)