Skip to content
Closed
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
6 changes: 3 additions & 3 deletions packaging_automation/tests/test_citus_package_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def test_get_postgres_versions():
def test_build_package_debian():
input_output_parameters = InputOutputParameters.build(
PACKAGING_EXEC_FOLDER,
f"{OUTPUT_FOLDER}/debian-stretch",
f"{OUTPUT_FOLDER}/debian-bookworm",
output_validation=False,
)

Expand All @@ -156,7 +156,7 @@ def test_build_package_debian():
build_package(
github_token=GH_TOKEN,
build_type=BuildType.release,
docker_platform="debian-stretch",
docker_platform="debian-bookworm",
postgres_version="all",
input_output_parameters=input_output_parameters,
is_test=True,
Expand Down Expand Up @@ -205,7 +205,7 @@ def test_sign_packages():
input_output_parameters=input_output_parameters,
)
sign_packages(
sub_folder="debian-stretch",
sub_folder="debian-bookworm",
signing_credentials=signing_credentials,
input_output_parameters=input_output_parameters,
)
Expand Down
65 changes: 45 additions & 20 deletions packaging_automation/tests/test_update_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@
update_docker_file_for_latest_postgres,
update_regular_docker_compose_file,
update_docker_file_alpine,
update_docker_file_for_postgres15,
update_docker_file_for_postgres14,
update_docker_file_for_postgres16,
update_docker_file_for_postgres17,
update_docker_file_for_postgres18,
update_changelog,
)

BASE_PATH = os.getenv("BASE_PATH", default=pathlib2.Path(__file__).parents[2])
TEST_BASE_PATH = f"{BASE_PATH}/docker"
PROJECT_VERSION = "12.0.0"

POSTGRES_15_VERSION = "15.4"
POSTGRES_14_VERSION = "14.9"
POSTGRES_18_VERSION = "18.1"
POSTGRES_17_VERSION = "17.6"
POSTGRES_16_VERSION = "16.10"

PROJECT_NAME = "citus"
version_details = get_version_details(PROJECT_VERSION)
Expand All @@ -45,7 +47,7 @@ def teardown_module():

def test_update_docker_file_for_latest_postgres():
update_docker_file_for_latest_postgres(
PROJECT_VERSION, TEMPLATE_PATH, TEST_BASE_PATH, POSTGRES_14_VERSION
PROJECT_VERSION, TEMPLATE_PATH, TEST_BASE_PATH, POSTGRES_18_VERSION
)
with open(
f"{TEST_BASE_PATH}/Dockerfile",
Expand All @@ -55,7 +57,7 @@ def test_update_docker_file_for_latest_postgres():
) as reader:
content = reader.read()
lines = content.splitlines()
assert lines[2].strip() == f"FROM postgres:{POSTGRES_14_VERSION}"
assert lines[2].strip() == f"FROM postgres:{POSTGRES_18_VERSION}"
assert lines[3].strip() == f"ARG VERSION={PROJECT_VERSION}"
assert (
f"postgresql-$PG_MAJOR-{PROJECT_NAME}-"
Expand Down Expand Up @@ -83,7 +85,7 @@ def test_update_regular_docker_compose_file():

def test_update_docker_file_alpine():
update_docker_file_alpine(
PROJECT_VERSION, TEMPLATE_PATH, TEST_BASE_PATH, POSTGRES_14_VERSION
PROJECT_VERSION, TEMPLATE_PATH, TEST_BASE_PATH, POSTGRES_18_VERSION
)
with open(
f"{TEST_BASE_PATH}/alpine/Dockerfile",
Expand All @@ -93,24 +95,24 @@ def test_update_docker_file_alpine():
) as reader:
content = reader.read()
lines = content.splitlines()
assert lines[2].strip() == f"FROM postgres:{POSTGRES_14_VERSION}-alpine"
assert lines[2].strip() == f"FROM postgres:{POSTGRES_18_VERSION}-alpine"
assert lines[3].strip() == f"ARG VERSION={PROJECT_VERSION}"
assert len(lines) == 58


def test_update_docker_file_for_postgres14():
update_docker_file_for_postgres14(
PROJECT_VERSION, TEMPLATE_PATH, TEST_BASE_PATH, POSTGRES_14_VERSION
def test_update_docker_file_for_postgres16():
update_docker_file_for_postgres16(
PROJECT_VERSION, TEMPLATE_PATH, TEST_BASE_PATH, POSTGRES_16_VERSION
)
with open(
f"{TEST_BASE_PATH}/postgres-14/Dockerfile",
f"{TEST_BASE_PATH}/postgres-16/Dockerfile",
"r",
encoding=DEFAULT_ENCODING_FOR_FILE_HANDLING,
errors=DEFAULT_UNICODE_ERROR_HANDLER,
) as reader:
content = reader.read()
lines = content.splitlines()
assert lines[2].strip() == f"FROM postgres:{POSTGRES_14_VERSION}"
assert lines[2].strip() == f"FROM postgres:{POSTGRES_16_VERSION}"
assert lines[3].strip() == f"ARG VERSION={PROJECT_VERSION}"
assert (
f"postgresql-$PG_MAJOR-{PROJECT_NAME}-"
Expand All @@ -120,19 +122,41 @@ def test_update_docker_file_for_postgres14():
assert len(lines) == 42


def test_update_docker_file_for_postgres15():
update_docker_file_for_postgres15(
PROJECT_VERSION, TEMPLATE_PATH, TEST_BASE_PATH, POSTGRES_15_VERSION
def test_update_docker_file_for_postgres17():
update_docker_file_for_postgres17(
PROJECT_VERSION, TEMPLATE_PATH, TEST_BASE_PATH, POSTGRES_17_VERSION
)
with open(
f"{TEST_BASE_PATH}/postgres-15/Dockerfile",
f"{TEST_BASE_PATH}/postgres-17/Dockerfile",
"r",
encoding=DEFAULT_ENCODING_FOR_FILE_HANDLING,
errors=DEFAULT_UNICODE_ERROR_HANDLER,
) as reader:
content = reader.read()
lines = content.splitlines()
assert lines[2].strip() == f"FROM postgres:{POSTGRES_15_VERSION}"
assert lines[2].strip() == f"FROM postgres:{POSTGRES_17_VERSION}"
assert lines[3].strip() == f"ARG VERSION={PROJECT_VERSION}"
assert (
f"postgresql-$PG_MAJOR-{PROJECT_NAME}-"
f"{version_details['major']}.{version_details['minor']}=$CITUS_VERSION"
in lines[21]
)
assert len(lines) == 42


def test_update_docker_file_for_postgres18():
update_docker_file_for_postgres18(
PROJECT_VERSION, TEMPLATE_PATH, TEST_BASE_PATH, POSTGRES_18_VERSION
)
with open(
f"{TEST_BASE_PATH}/postgres-18/Dockerfile",
"r",
encoding=DEFAULT_ENCODING_FOR_FILE_HANDLING,
errors=DEFAULT_UNICODE_ERROR_HANDLER,
) as reader:
content = reader.read()
lines = content.splitlines()
assert lines[2].strip() == f"FROM postgres:{POSTGRES_18_VERSION}"
assert lines[3].strip() == f"ARG VERSION={PROJECT_VERSION}"
assert (
f"postgresql-$PG_MAJOR-{PROJECT_NAME}-"
Expand Down Expand Up @@ -177,5 +201,6 @@ def test_update_changelog_without_postgres():

def test_pkgvar_postgres_version_existence():
config = dotenv_values(PKGVARS_FILE)
assert config["postgres_15_version"]
assert config["postgres_14_version"]
assert config["postgres_16_version"]
assert config["postgres_17_version"]
assert config["postgres_18_version"]
56 changes: 3 additions & 53 deletions packaging_automation/update_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,15 @@ class SupportedDockerImages(Enum):
latest = 1
docker_compose = 2
alpine = 3
postgres14 = 4
postgres15 = 5
postgres16 = 6
postgres17 = 7
postgres18 = 8
postgres16 = 4
postgres17 = 5
postgres18 = 6


docker_templates = {
SupportedDockerImages.latest: "latest/latest.tmpl.dockerfile",
SupportedDockerImages.docker_compose: "latest/docker-compose.tmpl.yml",
SupportedDockerImages.alpine: "alpine/alpine.tmpl.dockerfile",
SupportedDockerImages.postgres14: "postgres-14/postgres-14.tmpl.dockerfile",
SupportedDockerImages.postgres15: "postgres-15/postgres-15.tmpl.dockerfile",
SupportedDockerImages.postgres16: "postgres-16/postgres-16.tmpl.dockerfile",
SupportedDockerImages.postgres17: "postgres-17/postgres-17.tmpl.dockerfile",
SupportedDockerImages.postgres18: "postgres-18/postgres-18.tmpl.dockerfile",
Expand All @@ -51,8 +47,6 @@ class SupportedDockerImages(Enum):
SupportedDockerImages.latest: "Dockerfile",
SupportedDockerImages.docker_compose: "docker-compose.yml",
SupportedDockerImages.alpine: "alpine/Dockerfile",
SupportedDockerImages.postgres14: "postgres-14/Dockerfile",
SupportedDockerImages.postgres15: "postgres-15/Dockerfile",
SupportedDockerImages.postgres16: "postgres-16/Dockerfile",
SupportedDockerImages.postgres17: "postgres-17/Dockerfile",
SupportedDockerImages.postgres18: "postgres-18/Dockerfile",
Expand Down Expand Up @@ -159,40 +153,6 @@ def update_docker_file_for_postgres16(
write_to_file(content, dest_file_name)


def update_docker_file_for_postgres15(
project_version: str, template_path: str, exec_path: str, postgres_version: str
):
minor_version = get_minor_project_version_for_docker(project_version)
debian_project_version = project_version.replace("_", "-")
content = process_template_file_with_minor(
debian_project_version,
template_path,
docker_templates[SupportedDockerImages.postgres15],
minor_version,
postgres_version,
)
dest_file_name = f"{exec_path}/{docker_outputs[SupportedDockerImages.postgres15]}"
create_directory_if_not_exists(dest_file_name)
write_to_file(content, dest_file_name)


def update_docker_file_for_postgres14(
project_version: str, template_path: str, exec_path: str, postgres_version: str
):
minor_version = get_minor_project_version_for_docker(project_version)
debian_project_version = project_version.replace("_", "-")
content = process_template_file_with_minor(
debian_project_version,
template_path,
docker_templates[SupportedDockerImages.postgres14],
minor_version,
postgres_version,
)
dest_file_name = f"{exec_path}/{docker_outputs[SupportedDockerImages.postgres14]}"
create_directory_if_not_exists(dest_file_name)
write_to_file(content, dest_file_name)


def create_directory_if_not_exists(dest_file_name):
dir_name = os.path.dirname(dest_file_name)
if not os.path.exists(dir_name):
Expand Down Expand Up @@ -237,8 +197,6 @@ def update_all_docker_files(project_version: str, exec_path: str):
postgres_18_version,
postgres_17_version,
postgres_16_version,
postgres_15_version,
postgres_14_version,
) = read_postgres_versions(pkgvars_file)

latest_postgres_version = postgres_18_version
Expand All @@ -250,12 +208,6 @@ def update_all_docker_files(project_version: str, exec_path: str):
update_docker_file_alpine(
project_version, template_path, exec_path, latest_postgres_version
)
update_docker_file_for_postgres14(
project_version, template_path, exec_path, postgres_14_version
)
update_docker_file_for_postgres15(
project_version, template_path, exec_path, postgres_15_version
)
update_docker_file_for_postgres16(
project_version, template_path, exec_path, postgres_16_version
)
Expand All @@ -274,8 +226,6 @@ def read_postgres_versions(pkgvars_file: str) -> Tuple[str, str, str]:
config["postgres_18_version"],
config["postgres_17_version"],
config["postgres_16_version"],
config["postgres_15_version"],
config["postgres_14_version"],
)


Expand Down
Loading