Skip to content

Commit

Permalink
[release/3.x] Cherry pick: Infra: fix for new Debian package name for…
Browse files Browse the repository at this point in the history
… 3.x releases (#4490) (#4496)
  • Loading branch information
github-actions[bot] authored Nov 8, 2022
1 parent 5d62bd9 commit 6021b56
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 12 deletions.
42 changes: 31 additions & 11 deletions tests/infra/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,17 @@ def get_major_version_from_branch_name(branch_name):
)


def get_debian_package_url_from_tag_name(tag_name):
return f'{REMOTE_URL}/releases/download/{tag_name}/{tag_name.replace("-", "_")}{DEBIAN_PACKAGE_EXTENSION}'
def get_debian_package_prefix_with_platform(tag_name, platform="sgx"):
tag_components = tag_name.split("-")
tag_components[0] += f"_{platform}"
return "-".join(tag_components)


def get_debian_package_url_from_tag_name(tag_name, platform="sgx"):
if get_version_from_tag_name(tag_name) >= Version("3.0.0-rc0"):
return f'{REMOTE_URL}/releases/download/{tag_name}/{get_debian_package_prefix_with_platform(tag_name, platform).replace("-", "_")}{DEBIAN_PACKAGE_EXTENSION}'
else:
return f'{REMOTE_URL}/releases/download/{tag_name}/{tag_name.replace("-", "_")}{DEBIAN_PACKAGE_EXTENSION}'


class GitEnv:
Expand Down Expand Up @@ -244,13 +253,20 @@ def get_lts_releases(self, branch):
major_version += 1
return releases

def install_release(self, tag):
def install_release(self, tag, platform="sgx"):
stripped_tag = strip_release_tag_name(tag)
install_directory = f"{INSTALL_DIRECTORY_PREFIX}{stripped_tag}"
install_path = os.path.abspath(
os.path.join(install_directory, INSTALL_DIRECTORY_SUB_PATH)
)
debian_package_url = get_debian_package_url_from_tag_name(tag)
if get_version_from_tag_name(tag) >= Version("3.0.0-rc1"):
install_path = os.path.abspath(
os.path.join(
install_directory, f"{INSTALL_DIRECTORY_SUB_PATH}_{platform}"
)
)
else:
install_path = os.path.abspath(
os.path.join(install_directory, INSTALL_DIRECTORY_SUB_PATH)
)
debian_package_url = get_debian_package_url_from_tag_name(tag, platform)
installed_file_path = os.path.join(install_path, INSTALL_SUCCESS_FILE)

# Skip downloading release if it already exists
Expand Down Expand Up @@ -348,15 +364,19 @@ def get_first_tag_for_next_release_branch(self, branch):
LOG.debug(f"{branch} is development branch")
return None

def install_latest_lts_for_branch(self, branch, this_release_branch_only):
def install_latest_lts_for_branch(
self, branch, this_release_branch_only, platform="sgx"
):
latest_tag = self.get_latest_released_tag_for_branch(
branch, this_release_branch_only
)
return self.install_release(latest_tag) if latest_tag else (None, None)
return (
self.install_release(latest_tag, platform) if latest_tag else (None, None)
)

def install_next_lts_for_branch(self, branch):
def install_next_lts_for_branch(self, branch, platform="sgx"):
next_tag = self.get_first_tag_for_next_release_branch(branch)
return self.install_release(next_tag) if next_tag else (None, None)
return self.install_release(next_tag, platform) if next_tag else (None, None)


if __name__ == "__main__":
Expand Down
15 changes: 14 additions & 1 deletion tests/lts_compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@
DEFAULT_NODE_CERTIFICATE_VALIDITY_DAYS = 365


def platform_from_enclave_type(enclave_type):
if enclave_type == "virtual":
if IS_SNP:
return "snp"
else:
return "virtual"
else:
return "sgx"


def issue_activity_on_live_service(network, args):
log_capture = []
network.txs.issue(
Expand Down Expand Up @@ -402,6 +412,7 @@ def run_live_compatibility_with_latest(
lts_version, lts_install_path = repo.install_latest_lts_for_branch(
os.getenv(ENV_VAR_LATEST_LTS_BRANCH_NAME, local_branch),
this_release_branch_only,
platform=platform_from_enclave_type(args.enclave_type),
)
else:
lts_version = infra.github.get_version_from_install(lts_install_path)
Expand Down Expand Up @@ -456,7 +467,9 @@ def run_ledger_compatibility_since_first(args, local_branch, use_snapshot):
txs = app.LoggingTxs(jwt_issuer=jwt_issuer)
for idx, (_, lts_release) in enumerate(lts_releases.items()):
if lts_release:
version, install_path = repo.install_release(lts_release)
version, install_path = repo.install_release(
lts_release, platform_from_enclave_type(args.enclave_type)
)
lts_versions.append(version)
set_js_args(args, install_path)
else:
Expand Down

0 comments on commit 6021b56

Please sign in to comment.