From 6897a75ded31275190c998524dadd79c83bb9f02 Mon Sep 17 00:00:00 2001 From: Polyglot AI <293096396+polyglotAI-bot@users.noreply.github.com> Date: Thu, 19 Nov 2026 15:28:56 +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 only for pull requests that change the harness or the workflow. 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 the labeled event, calls upstream-sql-tests.yml through a new workflow_call trigger, and removes the label when the run ends, as the tests:run-cloud label does. It uses pull_request, not pull_request_target: the tests need no secrets, and the code of a fork runs with a read-only token. That token cannot remove the label, so the job skips forks. Co-Authored-By: Claude Opus 5.5 --- .../workflows/upstream-sql-tests-label.yml | 41 +++++++++++++++++++ .github/workflows/upstream-sql-tests.yml | 3 ++ tests/clickhouse-test-runner/AGENTS.md | 4 +- tests/clickhouse-test-runner/README.md | 6 +++ 4 files changed, 53 insertions(+), 1 deletion(-) 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..3d95bbded --- /dev/null +++ b/.github/workflows/upstream-sql-tests-label.yml @@ -0,0 +1,41 @@ +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 a client. 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 129c10996..bb51402af 100644 --- a/.github/workflows/upstream-sql-tests.yml +++ b/.github/workflows/upstream-sql-tests.yml @@ -3,11 +3,14 @@ name: Upstream SQL tests # Runs a curated subset of the ClickHouse core SQL tests (tests/queries/0_stateless) through the HTTP client # (ClickHouse.Driver) and the native TCP client (ClickHouse.Driver.Tcp). See # tests/clickhouse-test-runner/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-test-runner/AGENTS.md b/tests/clickhouse-test-runner/AGENTS.md index 64bde9e58..4fdbdb6da 100644 --- a/tests/clickhouse-test-runner/AGENTS.md +++ b/tests/clickhouse-test-runner/AGENTS.md @@ -21,7 +21,9 @@ Do not hide it. test in its test project (read the `AGENTS.md` of the client first, as the root `AGENTS.md` says). Do not fix a client bug in a pull request that changes the harness: one change per pull request. Some logic exists in both clients (see the root `AGENTS.md`), so check the other client too. When someone files an - issue for a group, put it on the `Issue:` line of the group. + issue for a group, put it on the `Issue:` line of the group. Such a pull request does not start the + workflow of the harness: to check that the fix breaks no test of the allowlist, add the + `tests:run-core-sql` label (see the README, CI). 3. **The default for a shim bug is a fix in the shim.** Make the shim copy `clickhouse-client` more exactly. Do not change the shim to hide a client bug, for example by another read method, a type-name workaround or a correction of a wrong value. The shim must use each client as a user does: `http` reads each value diff --git a/tests/clickhouse-test-runner/README.md b/tests/clickhouse-test-runner/README.md index 97a5e1aeb..cd0f915ba 100644 --- a/tests/clickhouse-test-runner/README.md +++ b/tests/clickhouse-test-runner/README.md @@ -284,6 +284,12 @@ of more than 7 elements (`[tcp-tuple-over-7-elements]`). manually, and on pushes and pull requests that change this directory or the workflow. A pull request that changes only the clients does not start it; the nightly run tests the clients of `main`. +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 once (`scripts/build.sh`), and the test jobs use it. The `harness-tests` job runs the unit and live tests of the shim. - The matrix of the test jobs is `{protocol: http, tcp} × {shard: 1..8}`, at `-j 4` on 4-vCPU runners.