From d558270a13d4276dba6bc85803ad88f6d94f2056 Mon Sep 17 00:00:00 2001 From: MyroTk Date: Thu, 30 Jul 2026 11:26:25 -0400 Subject: [PATCH 1/2] add tag push to master --- .github/workflows/master.yml | 2 ++ ci/praktika/yaml_generator.py | 7 ++++++- ci/tests/test_clickhouse_version.py | 24 +++++++++++++++++++++++- ci/workflows/master.py | 2 ++ tests/ci/version_helper.py | 26 ++++++++++++++++++++++++++ 5 files changed, 59 insertions(+), 2 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 0bc14cf2eece..b55f06dab7cf 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -10,6 +10,8 @@ on: required: false type: boolean default: false + push: + tags: ['*'] env: # Force the stdout and stderr streams to be unbuffered diff --git a/ci/praktika/yaml_generator.py b/ci/praktika/yaml_generator.py index 7d7fa7b86caa..b50b9f95d479 100644 --- a/ci/praktika/yaml_generator.py +++ b/ci/praktika/yaml_generator.py @@ -105,7 +105,7 @@ class Templates: on: workflow_dispatch: - inputs:{DISPATCH_INPUTS} + inputs:{DISPATCH_INPUTS}{TAG_PUSH_TRIGGER} env: # Force the stdout and stderr streams to be unbuffered @@ -519,6 +519,11 @@ def _all_needs(job_name: str) -> set: base_template = YamlGenerator.Templates.TEMPLATE_DISPATCH_WORKFLOW format_kwargs = { "DISPATCH_INPUTS": dispatch_inputs, + "TAG_PUSH_TRIGGER": ( + f"\n push:\n tags: {self.workflow_config.tags}" + if self.workflow_config.tags + else "" + ), "GH_TOKEN_PERMISSIONS": ( YamlGenerator.Templates.TEMPLATE_GH_TOKEN_PERMISSIONS ), diff --git a/ci/tests/test_clickhouse_version.py b/ci/tests/test_clickhouse_version.py index cf4ec9b6a13e..25bd9e4013c8 100644 --- a/ci/tests/test_clickhouse_version.py +++ b/ci/tests/test_clickhouse_version.py @@ -1,5 +1,5 @@ """ -Tests for `ci.jobs.scripts.clickhouse_version.CHVersion.get_current_version_as_dict`. +Tests for ClickHouse CI version handling. This branch uses the release version from `cmake/autogenerated_versions.txt` as-is instead of deriving CI-only version fields from the current checkout. @@ -8,9 +8,12 @@ import os import sys +import pytest + sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../..")) from ci.jobs.scripts.clickhouse_version import CHVersion +from version_helper import check_tag_version _RELEASE = { "major": 99, @@ -91,3 +94,22 @@ def test_master_shallow_checkout_uses_release_version_as_is(monkeypatch): ) version = CHVersion.get_current_version_as_dict() assert version == _RELEASE + + +def test_matching_tag(monkeypatch): + monkeypatch.setattr( + "version_helper.read_versions", + lambda _: {"describe": "v1.2.3.4.altinitystable"}, + ) + + check_tag_version("v1.2.3.4.altinitystable") + + +def test_mismatching_tag(monkeypatch): + monkeypatch.setattr( + "version_helper.read_versions", + lambda _: {"describe": "v1.2.3.4.altinitystable"}, + ) + + with pytest.raises(ValueError, match="does not match VERSION_DESCRIBE"): + check_tag_version("v1.2.3.5.altinitystable") diff --git a/ci/workflows/master.py b/ci/workflows/master.py index 0970e78cfc81..b3ffe686f331 100644 --- a/ci/workflows/master.py +++ b/ci/workflows/master.py @@ -23,6 +23,7 @@ workflow = Workflow.Config( name="MasterCI", event=Workflow.Event.DISPATCH, + tags=["*"], inputs=[ Workflow.Config.InputConfig( name="no_cache", @@ -106,6 +107,7 @@ enable_commit_status_on_failure=True, enable_slack_feed=False, pre_hooks=[ + '[ "$GITHUB_REF_TYPE" != "tag" ] || python3 ./tests/ci/version_helper.py --check-tag', # "python3 ./ci/jobs/scripts/workflow_hooks/store_data.py", # NOTE (carlosfelipeor): we don't use this in master CI "python3 ./ci/jobs/scripts/workflow_hooks/version_log.py", "python3 ./ci/jobs/scripts/workflow_hooks/parse_ci_tags.py", diff --git a/tests/ci/version_helper.py b/tests/ci/version_helper.py index 62194a253639..e96f4eb25a42 100755 --- a/tests/ci/version_helper.py +++ b/tests/ci/version_helper.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 import logging +import os from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, ArgumentTypeError from pathlib import Path from typing import Any, Dict, Iterable, List, Literal, Optional, Set, Tuple, Union @@ -297,6 +298,19 @@ def read_versions(versions_path: Union[Path, str] = FILE_WITH_VERSION_PATH) -> V return versions +def check_tag_version( + tag: str, versions_path: Union[Path, str] = FILE_WITH_VERSION_PATH +) -> None: + expected_tag = read_versions(versions_path)["describe"] + if tag != expected_tag: + raise ValueError( + f"Tag [{tag}] does not match VERSION_DESCRIBE [{expected_tag}] " + f"in {versions_path}" + ) + + print(f"Tag [{tag}] matches {versions_path}") + + def get_version_from_repo( versions_path: Union[Path, str] = FILE_WITH_VERSION_PATH, git: Optional[Git] = None, @@ -524,12 +538,24 @@ def main(): help=f"update {GENERATED_CONTRIBUTORS} file and exit, " "doesn't work on shallow repo", ) + parser.add_argument( + "--check-tag", + action="store_true", + help="check that GITHUB_REF_NAME matches VERSION_DESCRIBE and exit", + ) args = parser.parse_args() if args.update_contributors: update_contributors() return + if args.check_tag: + tag = os.getenv("GITHUB_REF_NAME", "") + if not tag: + raise ValueError("GITHUB_REF_NAME is empty") + check_tag_version(tag, args.version_path) + return + version = get_version_from_repo(args.version_path, Git(True)) if args.update_part: From 500098c47506b15a81e60f8e2e6a39a889db1ee3 Mon Sep 17 00:00:00 2001 From: MyroTk Date: Fri, 31 Jul 2026 12:10:18 -0400 Subject: [PATCH 2/2] disable cache on tag run --- .github/workflows/master.yml | 1 + ci/praktika/yaml_generator.py | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index b55f06dab7cf..94c61cb6e696 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -18,6 +18,7 @@ env: PYTHONUNBUFFERED: 1 GH_TOKEN: ${{ github.token }} CHECKOUT_REF: "" + DISABLE_CI_CACHE: ${{ github.ref_type == 'tag' && '1' || github.event.inputs.no_cache || '0' }} DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} CLICKHOUSE_TEST_STAT_URL: ${{ secrets.CLICKHOUSE_TEST_STAT_URL }} CLICKHOUSE_TEST_STAT_LOGIN: ${{ secrets.CLICKHOUSE_TEST_STAT_LOGIN }} diff --git a/ci/praktika/yaml_generator.py b/ci/praktika/yaml_generator.py index b50b9f95d479..b790a96f2a38 100644 --- a/ci/praktika/yaml_generator.py +++ b/ci/praktika/yaml_generator.py @@ -531,6 +531,11 @@ def _all_needs(job_name: str) -> set: ENV_CHECKOUT_REFERENCE = ( YamlGenerator.Templates.TEMPLATE_ENV_CHECKOUT_REF_DEFAULT ) + if self.workflow_config.tags: + ENV_CHECKOUT_REFERENCE += ( + "\n DISABLE_CI_CACHE: " + "${{{{ github.ref_type == 'tag' && '1' || github.event.inputs.no_cache || '0' }}}}" + ) elif self.workflow_config.event in (Workflow.Event.MERGE_QUEUE,): base_template = YamlGenerator.Templates.TEMPLATE_MERGE_QUEUE_0 format_kwargs = {}