Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

option to only install nightlies #1125

Merged
merged 3 commits into from
Nov 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion bin/lib/ce_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,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 @@ -189,6 +190,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 @@ -215,14 +217,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 @@ -91,6 +91,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