From 6850426ade52e908e26d71bc064daca325ac6b5a Mon Sep 17 00:00:00 2001 From: Polyglot AI <293096396+polyglotAI-bot@users.noreply.github.com> Date: Wed, 25 Nov 2026 16:37:19 +0000 Subject: [PATCH] ci: run the upstream SQL tests on a pull request with the tests:run-core-sql label upstream-sql-tests.yml runs nightly, manually, and on pull requests that change tests/clickhouse-client or the workflow. A pull request that changes only the clients does not start it. The `paths` filter of its pull_request trigger also applies to a `labeled` event, so a label cannot start it. The new workflow upstream-sql-tests-label.yml starts on a `labeled` event of a pull request. When the label is tests:run-core-sql, it calls upstream-sql-tests.yml (new `workflow_call` trigger, nothing else changes in that file) and then removes the label. The trigger is pull_request, not pull_request_target: the tests need no secrets, and the code of a fork runs with a read-only token. Only the separate remove-label job gets `pull-requests: write`, and it skips pull requests from forks. The README (CI) documents the label. Co-Authored-By: Claude Opus 5.5 --- .../workflows/upstream-sql-tests-label.yml | 46 +++++++++++++++++++ .github/workflows/upstream-sql-tests.yml | 4 ++ tests/clickhouse-client/README.md | 9 ++++ 3 files changed, 59 insertions(+) create mode 100644 .github/workflows/upstream-sql-tests-label.yml diff --git a/.github/workflows/upstream-sql-tests-label.yml b/.github/workflows/upstream-sql-tests-label.yml new file mode 100644 index 000000000..704b668a9 --- /dev/null +++ b/.github/workflows/upstream-sql-tests-label.yml @@ -0,0 +1,46 @@ +name: Upstream SQL tests by label + +# Runs upstream-sql-tests.yml on a pull request when a maintainer adds the +# tests:run-core-sql label. Use it for a pull request that does not start +# that workflow itself, for example a change in client-v2 or jdbc-v2. The run +# removes the label when it ends, so to run the tests again, add the label +# again. +on: + # Not pull_request_target: the tests need no secrets, and pull_request runs + # the code of a fork with a read-only token. The `paths` filter of the + # pull_request trigger in upstream-sql-tests.yml also applies to a + # `labeled` event, so the label needs this workflow of its own. + pull_request: + types: [labeled] + +permissions: {} + +jobs: + upstream-sql-tests: + name: Upstream SQL tests + if: github.event.label.name == 'tests:run-core-sql' + uses: ./.github/workflows/upstream-sql-tests.yml + permissions: + contents: read + + remove-label: + name: Remove the tests:run-core-sql label + needs: upstream-sql-tests + # The token of a pull request from a fork cannot write: remove the label + # by hand there. + if: >- + always() && github.event.label.name == 'tests:run-core-sql' && + github.event.pull_request.head.repo.full_name == github.repository + runs-on: ubuntu-latest + timeout-minutes: 5 + # A separate job, so that the pull request code in upstream-sql-tests + # never gets a token that can write. + permissions: + pull-requests: write + steps: + - name: Remove the label + env: + GH_TOKEN: ${{ github.token }} + REPO: ${{ github.repository }} + NUMBER: ${{ github.event.pull_request.number }} + run: gh api -X DELETE "repos/$REPO/issues/$NUMBER/labels/tests%3Arun-core-sql" || true diff --git a/.github/workflows/upstream-sql-tests.yml b/.github/workflows/upstream-sql-tests.yml index 3615d18f8..d3368d2cf 100644 --- a/.github/workflows/upstream-sql-tests.yml +++ b/.github/workflows/upstream-sql-tests.yml @@ -4,11 +4,15 @@ name: Upstream SQL tests # (tests/queries/0_stateless) through clickhouse-java, with the `client` # (client-v2) and the `jdbc` (jdbc-v2) backend of tests/clickhouse-client. # See tests/clickhouse-client/README.md. +# +# upstream-sql-tests-label.yml also calls it, for the tests:run-core-sql +# label on a pull request. permissions: contents: read on: + workflow_call: workflow_dispatch: inputs: clickhouse_version: diff --git a/tests/clickhouse-client/README.md b/tests/clickhouse-client/README.md index 9b12f786b..65871137e 100644 --- a/tests/clickhouse-client/README.md +++ b/tests/clickhouse-client/README.md @@ -418,6 +418,15 @@ tests read their own queries from `system.query_log`. runs the allowlist nightly, manually, and on pushes and pull requests that change this directory or the workflow. +A pull request that changes only the clients (for example the fix of a +client bug, rule 2 of [`AGENTS.md`](AGENTS.md)) does not start it. To run +it on such a pull request, add the `tests:run-core-sql` label +([`upstream-sql-tests-label.yml`](../../.github/workflows/upstream-sql-tests-label.yml)). +The run tests the pull request as it is when the label is added, and removes +the label when it ends: to test a later push, add the label again. The token +of a pull request from a fork cannot remove the label, so remove it by hand +before you add it again. + - The `build` job builds the shim against the source of the commit, runs its unit and live tests on the pinned server, and gives the jar to the test jobs.