Skip to content

Commit

Permalink
fix(reana-dev): update container image labels when releasing (#765)
Browse files Browse the repository at this point in the history
Fixes `reana-dev git-create-release-commit` behaviour to also update the
container image label version when releasing the cluster components.
  • Loading branch information
tiborsimko committed Mar 4, 2024
1 parent a6f95ac commit d54ffe7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
3 changes: 3 additions & 0 deletions reana/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@
TIMEOUT = 900
"""Maximum timeout to wait for results when running demo analyses in CI."""

DOCKER_VERSION_FILE = "Dockerfile"
"""Docker version file."""

HELM_VERSION_FILE = "Chart.yaml"
"""Helm package version file."""

Expand Down
10 changes: 7 additions & 3 deletions reana/reana_dev/git.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# This file is part of REANA.
# Copyright (C) 2020, 2021 CERN.
# Copyright (C) 2020, 2021, 2023, 2024 CERN.
#
# REANA is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
Expand All @@ -18,6 +18,7 @@
from reana.config import (
COMPONENTS_USING_SHARED_MODULE_COMMONS,
COMPONENTS_USING_SHARED_MODULE_DB,
DOCKER_VERSION_FILE,
GIT_DEFAULT_BASE_BRANCH,
HELM_VERSION_FILE,
JAVASCRIPT_VERSION_FILE,
Expand Down Expand Up @@ -135,7 +136,9 @@ def git_create_release_branch(component: str, next_version: Optional[str]):
if not next_version:
# bump current version depending on whether it is semver2 or pep440
current_version = get_current_component_version_from_source_files(component)
if version_files.get(HELM_VERSION_FILE):
if version_files.get(DOCKER_VERSION_FILE):
next_version = bump_semver2_version(current_version)
elif version_files.get(HELM_VERSION_FILE):

Check warning on line 141 in reana/reana_dev/git.py

View check run for this annotation

Codecov / codecov/patch

reana/reana_dev/git.py#L139-L141

Added lines #L139 - L141 were not covered by tests
next_version = bump_semver2_version(current_version)
elif version_files.get(PYTHON_VERSION_FILE):
next_version = bump_pep440_version(current_version)
Expand All @@ -146,7 +149,8 @@ def git_create_release_branch(component: str, next_version: Optional[str]):
else:
# provided next_version is always in pep440 version
if (
HELM_VERSION_FILE in version_files
DOCKER_VERSION_FILE in version_files
or HELM_VERSION_FILE in version_files
or JAVASCRIPT_VERSION_FILE in version_files
):
next_version = translate_pep440_to_semver2(next_version)
Expand Down
25 changes: 22 additions & 3 deletions reana/reana_dev/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import importlib.util
import json
import os
import re
import subprocess
import sys
from concurrent import futures
Expand All @@ -28,6 +29,7 @@
CLUSTER_DEPLOYMENT_MODES,
COMPONENTS_USING_SHARED_MODULE_COMMONS,
COMPONENTS_USING_SHARED_MODULE_DB,
DOCKER_VERSION_FILE,
GIT_DEFAULT_BASE_BRANCH,
HELM_VERSION_FILE,
JAVASCRIPT_VERSION_FILE,
Expand Down Expand Up @@ -609,6 +611,7 @@ def get_component_version_files(component, abs_path=False) -> Dict[str, str]:
"""Get a dictionary with all component's version files."""
version_files = {}
for file_ in [
DOCKER_VERSION_FILE,
HELM_VERSION_FILE,
OPENAPI_VERSION_FILE,
JAVASCRIPT_VERSION_FILE,
Expand Down Expand Up @@ -647,7 +650,17 @@ def get_current_component_version_from_source_files(
all_version_files = {version_file: all_version_files[version_file]}

version = ""
if all_version_files.get(HELM_VERSION_FILE):
if all_version_files.get(DOCKER_VERSION_FILE):
with open(all_version_files.get(DOCKER_VERSION_FILE)) as f:

Check warning on line 654 in reana/reana_dev/utils.py

View check run for this annotation

Codecov / codecov/patch

reana/reana_dev/utils.py#L653-L654

Added lines #L653 - L654 were not covered by tests
for line in f.readlines():
match = re.match(
r'LABEL org.opencontainers.image.version="(.*?)"', line
)
if match:
version = match.groups(1)[0]

Check warning on line 660 in reana/reana_dev/utils.py

View check run for this annotation

Codecov / codecov/patch

reana/reana_dev/utils.py#L656-L660

Added lines #L656 - L660 were not covered by tests
break

elif all_version_files.get(HELM_VERSION_FILE):

Check warning on line 663 in reana/reana_dev/utils.py

View check run for this annotation

Codecov / codecov/patch

reana/reana_dev/utils.py#L663

Added line #L663 was not covered by tests
with open(all_version_files.get(HELM_VERSION_FILE)) as f:
chart_yaml = yaml.safe_load(f.read())
version = chart_yaml["version"]
Expand Down Expand Up @@ -860,7 +873,11 @@ def bump_component_version(
component, version_file=file_type
)

if file_type in [HELM_VERSION_FILE, JAVASCRIPT_VERSION_FILE]:
if file_type in [

Check warning on line 876 in reana/reana_dev/utils.py

View check run for this annotation

Codecov / codecov/patch

reana/reana_dev/utils.py#L876

Added line #L876 was not covered by tests
DOCKER_VERSION_FILE,
HELM_VERSION_FILE,
JAVASCRIPT_VERSION_FILE,
]:

Check warning on line 880 in reana/reana_dev/utils.py

View check run for this annotation

Codecov / codecov/patch

reana/reana_dev/utils.py#L880

Added line #L880 was not covered by tests
new_version = (
translate_pep440_to_semver2(next_version)
if next_version
Expand All @@ -885,7 +902,9 @@ def bump_component_version(
next_version_per_file_type[file_type] = new_version

# depending on a component, return proper component version
if HELM_VERSION_FILE in next_version_per_file_type.keys():
if DOCKER_VERSION_FILE in next_version_per_file_type.keys():
return next_version_per_file_type[DOCKER_VERSION_FILE], updated_files

Check warning on line 906 in reana/reana_dev/utils.py

View check run for this annotation

Codecov / codecov/patch

reana/reana_dev/utils.py#L905-L906

Added lines #L905 - L906 were not covered by tests
elif HELM_VERSION_FILE in next_version_per_file_type.keys():
return next_version_per_file_type[HELM_VERSION_FILE], updated_files
elif JAVASCRIPT_VERSION_FILE in next_version_per_file_type:
return next_version_per_file_type[JAVASCRIPT_VERSION_FILE], updated_files
Expand Down

0 comments on commit d54ffe7

Please sign in to comment.