From b91337e2dffd2dd7d3e72f4c8a32f1f91a542a81 Mon Sep 17 00:00:00 2001 From: Balthasar Reuter <6384870+reuterbal@users.noreply.github.com> Date: Tue, 30 Jul 2024 13:47:06 +0200 Subject: [PATCH 1/3] Allow parameterising GitHub urls with GITHUB variable (#12) --- ecbundle/download.py | 2 ++ tests/bundle_download/bundle_github.yml | 10 +++++++ tests/bundle_download/test_download.py | 40 ++++++++++++++++++++++++- 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 tests/bundle_download/bundle_github.yml diff --git a/ecbundle/download.py b/ecbundle/download.py index 16c3a1d..e609168 100644 --- a/ecbundle/download.py +++ b/ecbundle/download.py @@ -61,6 +61,7 @@ def parse(cls, url): ECMWF_BITBUCKET_URL = "ssh://git@git.ecmwf.int" +GITHUB_URL = "https://github.com" class BundleDownloader(object): @@ -152,6 +153,7 @@ def __init__(self, project): if project.git(): self.url = project.git() self.url = self.url.replace("${BITBUCKET}", ECMWF_BITBUCKET_URL) + self.url = self.url.replace("${GITHUB}", GITHUB_URL) else: error("git not given for package " + self.name) diff --git a/tests/bundle_download/bundle_github.yml b/tests/bundle_download/bundle_github.yml new file mode 100644 index 0000000..2e664e5 --- /dev/null +++ b/tests/bundle_download/bundle_github.yml @@ -0,0 +1,10 @@ +--- +### Bundle + +name : test-bundle-https + +projects : + - project1 : + git : ${GITHUB}/user/project1.git + version : 0.0.1 + bundle : false diff --git a/tests/bundle_download/test_download.py b/tests/bundle_download/test_download.py index d494367..bf1080c 100644 --- a/tests/bundle_download/test_download.py +++ b/tests/bundle_download/test_download.py @@ -14,7 +14,7 @@ import pytest from conftest import Watcher -from ecbundle import BundleDownloader, Git, logger +from ecbundle import GITHUB_URL, BundleDownloader, Git, logger os.environ["BITBUCKET"] = "ssh://git@git.ecmwf.int" @@ -337,3 +337,41 @@ def test_symlink_symlinked_project_subdir(args, here, project1_subdir1_dir, watc assert ("Following projects are symlinked in") in watcher.output assert "- subdir1 (symlink_project1/subdir1)" in watcher.output + + +@pytest.fixture( + name="github_env_var", params=[None, "https://github.com", "ssh://git@github.com"] +) +def fixture_github_env_var(request): + """ + Fixture to set the GITHUB environment variable to various values + """ + orig_value = os.environ.get("GITHUB", None) + + if request.param is None: + os.environ.pop("GITHUB", None) + else: + os.environ["GITHUB"] = request.param + + yield request.param or GITHUB_URL + + if orig_value is None: + os.environ.pop("GITHUB", None) + else: + os.environ["GITHUB"] = orig_value + + +def test_download_github(args, here, watcher, github_env_var): + """ + Simple bundle creation test that git clones a single project using + the provided GITHUB environment variable value + """ + args["bundle"] = "%s" % (here / "bundle_github.yml") + + with watcher: + BundleDownloader(**args).download() + + assert ( + "git clone -o origin " + github_env_var + "/user/project1" + ) in watcher.output + assert "git -c advice.detachedHead=false checkout 0.0.1" in watcher.output From 5ad20be610bf47a1fe3ec877cd4f9f0b7f16f22b Mon Sep 17 00:00:00 2001 From: Balthasar Reuter <6384870+reuterbal@users.noreply.github.com> Date: Tue, 30 Jul 2024 13:47:36 +0200 Subject: [PATCH 2/3] Call sync on LOG_FILE only (fixes #10) (#13) --- ecbundle/build.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ecbundle/build.py b/ecbundle/build.py index d6e699d..10236f3 100644 --- a/ecbundle/build.py +++ b/ecbundle/build.py @@ -134,13 +134,13 @@ def install(self, threads): # before the build is configured SCRIPT_DIR="$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )" -cd ${SCRIPT_DIR} +cd "${SCRIPT_DIR}" LOG_FILE=${SCRIPT_DIR}/build.log exec 1> >(tee -a "$LOG_FILE") 2>&1 shopt -s expand_aliases alias trace_on='set -x' -alias trace_off='{ PREV_STATUS=$? ; set +x; sync; } 2>/dev/null; (exit $PREV_STATUS)' +alias trace_off='{ PREV_STATUS=$? ; set +x; sync "${LOG_FILE}"; } 2>/dev/null; (exit $PREV_STATUS)' ### Environment echo "==============================================================" From 62e399c722e5e7eecba7bcb0c3f3293985a956ed Mon Sep 17 00:00:00 2001 From: Willem Deconinck Date: Mon, 20 Jan 2025 17:26:21 +0100 Subject: [PATCH 3/3] Version 2.2.0 --- ecbundle/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ecbundle/__init__.py b/ecbundle/__init__.py index 428e301..8e03473 100644 --- a/ecbundle/__init__.py +++ b/ecbundle/__init__.py @@ -16,4 +16,4 @@ from ecbundle.project import * # noqa from ecbundle.util import * # noqa -__version__ = "2.1.1" +__version__ = "2.2.0"