diff --git a/.github/workflows/osd-increment-plugin-versions.yml b/.github/workflows/osd-increment-plugin-versions.yml index d4b6e66fc7..33f559eba3 100644 --- a/.github/workflows/osd-increment-plugin-versions.yml +++ b/.github/workflows/osd-increment-plugin-versions.yml @@ -16,7 +16,7 @@ on: - warning - debug jobs: - osd-plugin-version-increment: + plugin-version-increment-sync: runs-on: ubuntu-latest strategy: fail-fast: false diff --git a/src/manifests_workflow/input_manifests.py b/src/manifests_workflow/input_manifests.py index cf8c58fd08..3bbf5b7f18 100644 --- a/src/manifests_workflow/input_manifests.py +++ b/src/manifests_workflow/input_manifests.py @@ -59,8 +59,12 @@ def cron_jenkinsfile(self) -> str: return os.path.join(self.jenkins_path(), "check-for-build.jenkinsfile") @classmethod - def versionincrement_workflow(self) -> str: - return os.path.join(self.workflows_path(), "increment-plugin-versions.yml") + def os_versionincrement_workflow(self) -> str: + return os.path.join(self.workflows_path(), "os-increment-plugin-versions.yml") + + @classmethod + def osd_versionincrement_workflow(self) -> str: + return os.path.join(self.workflows_path(), "osd-increment-plugin-versions.yml") @classmethod def files(self, name: str) -> List: @@ -192,29 +196,31 @@ def add_to_cron(self, version: str) -> None: logging.info(f"Wrote {jenkinsfile}") def add_to_versionincrement_workflow(self, version: str) -> None: - versionincrement_workflow_file = self.versionincrement_workflow() + versionincrement_workflow_files = [self.os_versionincrement_workflow(), self.osd_versionincrement_workflow()] yaml = ruamel.yaml.YAML() yaml.explicit_start = True # type: ignore yaml.preserve_quotes = True # type: ignore - with open(versionincrement_workflow_file) as f: - data = yaml.load(f) - - version_entry = [] - major_version_entry = version.split(".")[0] + ".x" - minor_version_entry = version.rsplit(".", 1)[0] - if minor_version_entry not in data["jobs"]["plugin-version-increment-sync"]["strategy"]["matrix"]["branch"]: - print(f"Adding {minor_version_entry} to {versionincrement_workflow_file}") - version_entry.append(minor_version_entry) - if major_version_entry not in data["jobs"]["plugin-version-increment-sync"]["strategy"]["matrix"]["branch"]: - print(f"Adding {major_version_entry} to {versionincrement_workflow_file}") - version_entry.append(major_version_entry) - - if version_entry: - branch_list = list(data["jobs"]["plugin-version-increment-sync"]["strategy"]["matrix"]["branch"]) - branch_list.extend(version_entry) - data["jobs"]["plugin-version-increment-sync"]["strategy"]["matrix"]["branch"] = branch_list - yaml.indent(mapping=2, sequence=4, offset=2) - with open(versionincrement_workflow_file, 'w') as f: - yaml.dump(data, f) - logging.info("Added new version to the version increment workflow") + for workflow_file in versionincrement_workflow_files: + + with open(workflow_file) as f: + data = yaml.load(f) + + version_entry = [] + major_version_entry = version.split(".")[0] + ".x" + minor_version_entry = version.rsplit(".", 1)[0] + if minor_version_entry not in data["jobs"]["plugin-version-increment-sync"]["strategy"]["matrix"]["branch"]: + print(f"Adding {minor_version_entry} to {workflow_file}") + version_entry.append(minor_version_entry) + if major_version_entry not in data["jobs"]["plugin-version-increment-sync"]["strategy"]["matrix"]["branch"]: + print(f"Adding {major_version_entry} to {workflow_file}") + version_entry.append(major_version_entry) + + if version_entry: + branch_list = list(data["jobs"]["plugin-version-increment-sync"]["strategy"]["matrix"]["branch"]) + branch_list.extend(version_entry) + data["jobs"]["plugin-version-increment-sync"]["strategy"]["matrix"]["branch"] = branch_list + yaml.indent(mapping=2, sequence=4, offset=2) + with open(workflow_file, 'w') as f: + yaml.dump(data, f) + logging.info("Added new version to the version increment workflow") diff --git a/tests/tests_manifests_workflow/test_input_manifests.py b/tests/tests_manifests_workflow/test_input_manifests.py index 99b321a7a4..e9d2b109a5 100644 --- a/tests/tests_manifests_workflow/test_input_manifests.py +++ b/tests/tests_manifests_workflow/test_input_manifests.py @@ -129,17 +129,26 @@ def test_add_to_cron(self, mock_open: MagicMock) -> None: f"TARGET_JOB_NAME=distribution-build-test;BUILD_PLATFORM=linux;BUILD_DISTRIBUTION=tar\n" ) - def test_versionincrement_workflow(self) -> None: + def test_os_versionincrement_workflow(self) -> None: self.assertEqual( - InputManifests.versionincrement_workflow(), - os.path.realpath(os.path.join(os.path.dirname(__file__), "..", "..", ".github", "workflows", "increment-plugin-versions.yml")) + InputManifests.os_versionincrement_workflow(), + os.path.realpath(os.path.join(os.path.dirname(__file__), "..", "..", ".github", "workflows", "os-increment-plugin-versions.yml")) ) + self.assertTrue(os.path.exists(InputManifests.os_versionincrement_workflow())) + + def test_osd_versionincrement_workflow(self) -> None: + self.assertEqual( + InputManifests.osd_versionincrement_workflow(), + os.path.realpath(os.path.join(os.path.dirname(__file__), "..", "..", ".github", "workflows", "osd-increment-plugin-versions.yml")) + ) + self.assertTrue(os.path.exists(InputManifests.osd_versionincrement_workflow())) + - @patch("builtins.open", new_callable=mock_open) @patch("manifests_workflow.input_manifests.InputManifests.add_to_versionincrement_workflow") - def test_add_to_versionincrement_workflow(self, *mocks: Any) -> None: + def test_add_to_versionincrement_workflow(self, mock_add_to_versionincrement_workflow: MagicMock) -> None: input_manifests = InputManifests("test") - input_manifests.add_to_versionincrement_workflow('0.1.2') + input_manifests.add_to_versionincrement_workflow('1.0.0') + mock_add_to_versionincrement_workflow.assert_called_with("1.0.0") def test_create_manifest_with_components(self) -> None: pass