Skip to content

Commit

Permalink
option to only install nightlies (#1125)
Browse files Browse the repository at this point in the history
  • Loading branch information
partouf authored Nov 18, 2023
1 parent 0c4c92c commit 53f5460
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 2 deletions.
8 changes: 7 additions & 1 deletion bin/lib/ce_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ def squash_mount_check(rootfolder, subdir, context):
show_default=True,
)
@click.option("--enable", metavar="TYPE", multiple=True, help='Enable targets of type TYPE (e.g. "nightly")')
@click.option("--only-nightly", is_flag=True, help="Only install the nightly targets")
@click.option(
"--cache",
metavar="DIR",
Expand Down Expand Up @@ -187,6 +188,7 @@ def cli(
s3_dir: str,
dry_run: bool,
enable: List[str],
only_nightly: bool,
cache: Optional[Path],
yaml_dir: Path,
allow_unsafe_ssl: bool,
Expand All @@ -213,14 +215,18 @@ def cli(
s3_url=f"https://s3.amazonaws.com/{s3_bucket}/{s3_dir}",
dry_run=dry_run,
is_nightly_enabled="nightly" in enable,
only_nightly=only_nightly,
cache=cache,
yaml_dir=yaml_dir,
allow_unsafe_ssl=allow_unsafe_ssl,
resource_dir=resource_dir,
keep_staging=keep_staging,
)
ctx.obj = CliContext(
installation_context=context, enabled=enable, filter_match_all=filter_match_all, parallel=parallel
installation_context=context,
enabled=enable,
filter_match_all=filter_match_all,
parallel=parallel,
)


Expand Down
3 changes: 3 additions & 0 deletions bin/lib/installable/installable.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ def verify(self) -> bool:
return True

def should_install(self) -> bool:
if self.install_context.only_nightly and not self.nightly_like:
return False

return self.install_always or not self.is_installed()

def should_build(self):
Expand Down
2 changes: 2 additions & 0 deletions bin/lib/installation_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def __init__(
s3_url: str,
dry_run: bool,
is_nightly_enabled: bool,
only_nightly: bool,
cache: Optional[Path],
yaml_dir: Path,
allow_unsafe_ssl: bool,
Expand All @@ -55,6 +56,7 @@ def __init__(
self.s3_url = s3_url
self.dry_run = dry_run
self.is_nightly_enabled = is_nightly_enabled
self.only_nightly = only_nightly
retry_strategy = requests.adapters.Retry(
total=10,
backoff_factor=1,
Expand Down
36 changes: 35 additions & 1 deletion bin/test/installable/git_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,16 @@ def _ensure_no_global_config():

@pytest.fixture(name="fake_context")
def fake_context_fixture():
return mock.Mock(spec_set=InstallationContext)
ctx = mock.Mock(spec=InstallationContext)
ctx.only_nightly = False
return ctx


@pytest.fixture(name="fake_context_nightly")
def fake_context_nightly_fixture():
ctx = mock.Mock(spec=InstallationContext)
ctx.only_nightly = True
return ctx


@pytest.fixture(name="staging_path")
Expand Down Expand Up @@ -130,6 +139,31 @@ def test_should_install_when_not_present(fake_context, tmp_path, fake_remote_rep
assert ghi.should_install()


def test_should_not_install_when_not_nightly(fake_context_nightly, tmp_path, fake_remote_repo):
fake_context_nightly.prior_installation = fake_context_nightly.destination = tmp_path / "nonexistent"
ghi = GitHubInstallable(
fake_context_nightly,
dict(context=["outer", "inner"], name="fake", domainrepo="", repo=fake_remote_repo, check_file="fake-none"),
)
assert not ghi.should_install()


def test_should_install_when_nightly(fake_context_nightly, tmp_path, fake_remote_repo):
fake_context_nightly.prior_installation = fake_context_nightly.destination = tmp_path / "nonexistent"
ghi = GitHubInstallable(
fake_context_nightly,
dict(
context=["outer", "inner"],
name="fake",
domainrepo="",
method="nightlyclone",
repo=fake_remote_repo,
check_file="fake-none",
),
)
assert ghi.should_install()


def test_should_not_install_when_present_and_up_to_date(previously_installed_ghi):
assert not previously_installed_ghi.should_install()

Expand Down

0 comments on commit 53f5460

Please sign in to comment.