Skip to content

Commit

Permalink
Merge branch 'release/2.2.0'
Browse files Browse the repository at this point in the history
* release/2.2.0:
  Version 2.2.0
  Call sync on LOG_FILE only (fixes #10) (#13)
  Allow parameterising GitHub urls with GITHUB variable (#12)
  • Loading branch information
wdeconinck committed Jan 20, 2025
2 parents 814873b + 62e399c commit 54c2787
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ecbundle/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
from ecbundle.project import * # noqa
from ecbundle.util import * # noqa

__version__ = "2.1.1"
__version__ = "2.2.0"
4 changes: 2 additions & 2 deletions ecbundle/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "=============================================================="
Expand Down
2 changes: 2 additions & 0 deletions ecbundle/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def parse(cls, url):


ECMWF_BITBUCKET_URL = "ssh://[email protected]"
GITHUB_URL = "https://github.com"


class BundleDownloader(object):
Expand Down Expand Up @@ -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)

Expand Down
10 changes: 10 additions & 0 deletions tests/bundle_download/bundle_github.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
### Bundle

name : test-bundle-https

projects :
- project1 :
git : ${GITHUB}/user/project1.git
version : 0.0.1
bundle : false
40 changes: 39 additions & 1 deletion tests/bundle_download/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -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://[email protected]"

Expand Down Expand Up @@ -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://[email protected]"]
)
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

0 comments on commit 54c2787

Please sign in to comment.