Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

ci: request pytest from readiness labels (#7117)

LearningCircuit959e885543d3
diff --git a/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md
index fdc099effe..9fb83dc4eb 100644
--- a/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md
+++ b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md
@@ -4,7 +4,7 @@ Fixes #
## CI test coverage
-Lint, security and focused checks run automatically. The shared test image is built only when full pytest or a selected focused check needs it. When this PR is nearly ready, a maintainer must add `test:pytest` to run the full pytest suite. Passing full pytest remains required before merge; until requested, that check reports a short failure explaining the missing label. Later pushes rerun the suite while the label remains.
+Lint, security and focused checks run automatically. The shared test image is built only when full pytest or a selected focused check needs it. When this PR is nearly ready, add `test:pytest`, `code-ready`, `code-ready-preliminary`, or `auto-merge` to request the full pytest suite. Passing full pytest remains required before merge; until requested, that check reports a short failure explaining the missing label. Later pushes rerun the suite while any of those labels remains.
Additional heavy suites use these labels:
diff --git a/.github/labels.yml b/.github/labels.yml
index 4df50eb5e4..6daac9febe 100644
--- a/.github/labels.yml
+++ b/.github/labels.yml
@@ -192,6 +192,9 @@
- name: 'test:pytest'
color: '0e8a16'
description: 'Maintainer request for full pytest before merge; reruns on later pushes while the label remains.'
+- name: code-ready-preliminary
+ color: 'c2e0c6'
+ description: 'Preliminary readiness; requests full pytest. Not human-verified; re-check before code-ready.'
- name: ai_code_review
color: '6f42c1'
description: 'Maintainer-only: apply or re-add to run AI code review. Release notes: 🔄 Automation (18/20).'
@@ -203,7 +206,7 @@
description: 'Branch synchronization PR. Release notes: 🔄 Branch Syncs & Automation (18/20).'
- name: auto-merge
color: 'ededed'
- description: 'PR approved for automatic merging. Release notes: 🔄 Branch Syncs & Automation (18/20).'
+ description: 'PR approved for automatic merging; requests full pytest. Release notes: 🔄 Automation (18/20).'
- name: merge-blocked
color: 'ededed'
description: 'PR is blocked from merging. Release notes: 🚧 Review & Blocked Items (19/20).'
@@ -226,4 +229,4 @@
description: PR needs substantive rework before it can be reviewed in depth
- name: code-ready
color: '006b75'
- description: Code looks technically ready; still needs CI + approver. Apply manually — never auto-applied.
+ description: Code looks ready; requests full pytest, still needs approval. Apply manually — never auto-applied.
diff --git a/.github/workflows/README.md b/.github/workflows/README.md
index a25b64b926..50995fdac1 100644
--- a/.github/workflows/README.md
+++ b/.github/workflows/README.md
@@ -5,12 +5,22 @@ This directory contains GitHub Actions workflows for automated development tasks
## Full pytest scheduling
`docker-tests.yml` keeps **All Pytest Tests + Coverage** required before merge.
-A maintainer adds `test:pytest` when a PR is nearly ready. Adding that label
-starts full pytest against the PR's test merge commit; later pushes and reopen
-events rerun it while the label remains. Remove the label to stop full pytest
-on future pushes. Removing and re-adding it requests another run.
-
-Without the label, the required job fails a short guard before checkout or test
+A PR requests full pytest when it carries any of these labels:
+
+- `test:pytest` — explicit full-suite request.
+- `code-ready` — code is ready for CI and approval.
+- `code-ready-preliminary` — preliminary readiness; full validation is needed.
+- `auto-merge` — the PR has been marked for merging.
+
+Adding any request label starts full pytest against the PR's test merge commit;
+later pushes and reopen events rerun it while at least one remains. Remove all
+request labels to stop full pytest on future pushes. Removing and re-adding one
+requests another run. These labels request tests; they do not approve or merge
+a PR. A label added by a workflow using `GITHUB_TOKEN` does not itself start
+another workflow; apply it with a maintainer token or GitHub App, or validation
+will wait for a later eligible PR event.
+
+Without a request label, the required job fails a short guard before checkout or test
setup. This is an intentional merge block, not a failing test. A skipped job
would satisfy GitHub's required-check rule, so the job must not be skipped for
an unrequested PR. Failed or cancelled image builds also cannot make it pass.
@@ -19,7 +29,7 @@ cannot cancel a real PR run or overwrite its required checks.
The shared test image is built only when full pytest is requested or an
automatic focused check needs it (LLM, infrastructure, or accessibility paths).
-An unlabeled PR with none of those checks skips the image build while the
+A PR without request labels or any of those checks skips the image build while the
required pytest request guard still blocks merging. Production-image smoke
tests retain their separate path-based build and do not need the test image.
@@ -27,7 +37,11 @@ Main retains automatic full pytest on pushes as a second check of the code that
landed, plus a daily run at **03:23 UTC**. Both can publish validated coverage for
the current main commit. Manual dispatch and reusable callers (including
mandatory release validation and the full UI label) also run the full suite.
-Manual runs are useful for diagnosis; request PR validation with the label so
+The full UI label already requests full pytest through its reusable strict
+workflow; it is not also a direct trigger, which would run the suite twice.
+Topic and review-request labels (such as `python`, `tests`, `security`, or
+`ai_code_review`) do not request full pytest.
+Manual runs are useful for diagnosis; request PR validation with a label so
the run uses a `pull_request` event and satisfies required checks.
New direct PR runs cancel obsolete predecessors. The required pytest job uses
@@ -42,7 +56,7 @@ newest pending run is retained. Intermediate queued main commits may therefore
be superseded; the required pre-merge validation still applies to every PR.
Reusable release runs and the daily run have isolated concurrency groups.
-The label is declared in `.github/labels.yml` and maintained by label sync.
+The request labels are declared in `.github/labels.yml` and maintained by label sync.
The existing required check name is preserved; no branch-rule change is
needed. Existing PRs receive the policy when their workflow includes this
change; merging this change does not cancel or rewrite already queued runs.
diff --git a/.github/workflows/docker-tests.yml b/.github/workflows/docker-tests.yml
index aaec752f70..76b63e3cdb 100644
--- a/.github/workflows/docker-tests.yml
+++ b/.github/workflows/docker-tests.yml
@@ -30,6 +30,8 @@ on:
required: false
workflow_dispatch:
+# Full pytest request labels: test:pytest, code-ready, code-ready-preliminary,
+# and auto-merge. Keep event filters and PR-label checks aligned.
# Cancel obsolete direct PR runs before they consume build/test capacity.
# Main pushes share one group: finish the active run and retain only the newest
# pending run (GitHub's default), so frequent merges do not starve validation.
@@ -41,12 +43,12 @@ on:
concurrency:
group: >-
${{ !inputs.reusable-invocation && github.event_name == 'pull_request' &&
- (github.event.action != 'labeled' || github.event.label.name == 'test:pytest') &&
+ (github.event.action != 'labeled' || contains(fromJSON('["test:pytest", "code-ready", "code-ready-preliminary", "auto-merge"]'), github.event.label.name)) &&
format('docker-tests-direct-pr-{0}', github.event.pull_request.number) ||
!inputs.reusable-invocation && github.event_name == 'push' &&
github.ref == 'refs/heads/main' && 'docker-tests-direct-main' ||
format('docker-tests-isolated-run-{0}', github.run_id) }}
- cancel-in-progress: ${{ !inputs.reusable-invocation && github.event_name == 'pull_request' && (github.event.action != 'labeled' || github.event.label.name == 'test:pytest') }}
+ cancel-in-progress: ${{ !inputs.reusable-invocation && github.event_name == 'pull_request' && (github.event.action != 'labeled' || contains(fromJSON('["test:pytest", "code-ready", "code-ready-preliminary", "auto-merge"]'), github.event.label.name)) }}
# Top-level permissions set to minimum (OSSF Scorecard Token-Permissions)
permissions: {}
@@ -58,8 +60,8 @@ env:
jobs:
# Detect which paths changed to conditionally run certain jobs
detect-changes:
- name: ${{ github.event_name == 'pull_request' && github.event.action == 'labeled' && github.event.label.name != 'test:pytest' && !inputs.reusable-invocation && 'Ignored label (change detection)' || 'detect-changes' }}
- if: github.event_name != 'pull_request' || github.event.action != 'labeled' || github.event.label.name == 'test:pytest' || inputs.reusable-invocation
+ name: ${{ github.event_name == 'pull_request' && github.event.action == 'labeled' && !contains(fromJSON('["test:pytest", "code-ready", "code-ready-preliminary", "auto-merge"]'), github.event.label.name) && !inputs.reusable-invocation && 'Ignored label (change detection)' || 'detect-changes' }}
+ if: github.event_name != 'pull_request' || github.event.action != 'labeled' || contains(fromJSON('["test:pytest", "code-ready", "code-ready-preliminary", "auto-merge"]'), github.event.label.name) || inputs.reusable-invocation
runs-on: ubuntu-latest
outputs:
llm: ${{ steps.filter.outputs.llm }}
@@ -138,11 +140,14 @@ jobs:
build-test-image:
runs-on: ubuntu-latest
needs: detect-changes
- name: ${{ github.event_name == 'pull_request' && github.event.action == 'labeled' && github.event.label.name != 'test:pytest' && !inputs.reusable-invocation && 'Ignored label (image build)' || 'Build Test Image' }}
+ name: ${{ github.event_name == 'pull_request' && github.event.action == 'labeled' && !contains(fromJSON('["test:pytest", "code-ready", "code-ready-preliminary", "auto-merge"]'), github.event.label.name) && !inputs.reusable-invocation && 'Ignored label (image build)' || 'Build Test Image' }}
if: |
- (github.event_name != 'pull_request' || github.event.action != 'labeled' || github.event.label.name == 'test:pytest' || inputs.reusable-invocation) &&
+ (github.event_name != 'pull_request' || github.event.action != 'labeled' || contains(fromJSON('["test:pytest", "code-ready", "code-ready-preliminary", "auto-merge"]'), github.event.label.name) || inputs.reusable-invocation) &&
(github.event_name != 'pull_request' || inputs.reusable-invocation ||
- contains(github.event.pull_request.labels.*.name, 'test:pytest') ||
+ (contains(github.event.pull_request.labels.*.name, 'test:pytest') ||
+ contains(github.event.pull_request.labels.*.name, 'code-ready') ||
+ contains(github.event.pull_request.labels.*.name, 'code-ready-preliminary') ||
+ contains(github.event.pull_request.labels.*.name, 'auto-merge')) ||
needs.detect-changes.outputs.llm == 'true' ||
needs.detect-changes.outputs.infrastructure == 'true' ||
needs.detect-changes.outputs.accessibility == 'true')
@@ -185,10 +190,10 @@ jobs:
# cancellation release an obsolete queued job without first needing a runner.
pytest-tests:
runs-on: ubuntu-latest
- name: ${{ github.event_name == 'pull_request' && github.event.action == 'labeled' && github.event.label.name != 'test:pytest' && !inputs.reusable-invocation && 'Ignored label (pytest)' || 'All Pytest Tests + Coverage' }}
+ name: ${{ github.event_name == 'pull_request' && github.event.action == 'labeled' && !contains(fromJSON('["test:pytest", "code-ready", "code-ready-preliminary", "auto-merge"]'), github.event.label.name) && !inputs.reusable-invocation && 'Ignored label (pytest)' || 'All Pytest Tests + Coverage' }}
if: >-
!cancelled() &&
- (github.event_name != 'pull_request' || github.event.action != 'labeled' || github.event.label.name == 'test:pytest' || inputs.reusable-invocation)
+ (github.event_name != 'pull_request' || github.event.action != 'labeled' || contains(fromJSON('["test:pytest", "code-ready", "code-ready-preliminary", "auto-merge"]'), github.event.label.name) || inputs.reusable-invocation)
# Cap exists so a hung run doesn't inherit GitHub's 360-minute default
# (observed 2026-06-10 on PR #4491: a flaked run sat in the main pytest
# step for 2+ hours before being cancelled manually). The original
@@ -214,13 +219,18 @@ jobs:
- name: Require a pytest request and successful image build
id: pytest_request
env:
- PYTEST_REQUESTED: ${{ github.event_name != 'pull_request' || inputs.reusable-invocation || contains(github.event.pull_request.labels.*.name, 'test:pytest') }}
+ PYTEST_REQUESTED: >-
+ ${{ github.event_name != 'pull_request' || inputs.reusable-invocation ||
+ contains(github.event.pull_request.labels.*.name, 'test:pytest') ||
+ contains(github.event.pull_request.labels.*.name, 'code-ready') ||
+ contains(github.event.pull_request.labels.*.name, 'code-ready-preliminary') ||
+ contains(github.event.pull_request.labels.*.name, 'auto-merge') }}
TEST_IMAGE_RESULT: ${{ needs.build-test-image.result }}
run: |
set -euo pipefail
if [ "$PYTEST_REQUESTED" != 'true' ]; then
- echo 'Full pytest has not been requested. A maintainer must add test:pytest when this PR is ready for full validation.' >> "$GITHUB_STEP_SUMMARY"
- echo '::error::Full pytest is required before merging. Add the test:pytest label to run it.'
+ echo 'Full pytest has not been requested. Add test:pytest, code-ready, code-ready-preliminary, or auto-merge when this PR is ready for full validation.' >> "$GITHUB_STEP_SUMMARY"
+ echo '::error::Full pytest is required before merging. Add test:pytest or a readiness label (code-ready, code-ready-preliminary, auto-merge) to run it.'
exit 1
fi
if [ "$TEST_IMAGE_RESULT" != 'success' ]; then
diff --git a/changelog.d/+pytest-readiness-labels.misc.md b/changelog.d/+pytest-readiness-labels.misc.md
new file mode 100644
index 0000000000..a3dda14905
--- /dev/null
+++ b/changelog.d/+pytest-readiness-labels.misc.md
@@ -0,0 +1 @@
+Full pytest now starts automatically for PRs labeled `code-ready`, `code-ready-preliminary`, or `auto-merge`, as well as `test:pytest`, and reruns on later pushes while any request label remains. Full validation remains required before merging; unrelated labels and existing release validation retain their behavior.
diff --git a/tests/ci/standalone/test_pytest_scheduling.py b/tests/ci/standalone/test_pytest_scheduling.py
index d8b2cf68c7..db17718120 100644
--- a/tests/ci/standalone/test_pytest_scheduling.py
+++ b/tests/ci/standalone/test_pytest_scheduling.py
@@ -8,6 +8,7 @@ GitHub's scheduler or proof of a hosted run's final check conclusion.
"""
import ast
+import json
import os
import re
import subprocess
@@ -24,6 +25,12 @@ TOKEN = re.compile(
r"\s*('(?:[^']|'')*'|&&|\|\||==|!=|!|[(),]|"
r"[A-Za-z_][A-Za-z0-9_.*-]*|[0-9]+)"
)
+REQUEST_LABELS = (
+ "test:pytest",
+ "code-ready",
+ "code-ready-preliminary",
+ "auto-merge",
+)
REQUIRED = {
"detect-changes": "detect-changes",
"build-test-image": "Build Test Image",
@@ -80,6 +87,7 @@ def evaluate(expression, context, *, cancelled=False, success=True):
"success",
"contains",
"format",
+ "fromJSON",
"hashFiles",
}
operators = {"&&": "and", "||": "or", "!": "not"}
@@ -112,6 +120,7 @@ def evaluate(expression, context, *, cancelled=False, success=True):
calls = {
"lookup": lookup,
+ "fromJSON": json.loads,
"always": lambda: True,
"cancelled": lambda: cancelled,
"success": lambda: success,
@@ -170,14 +179,17 @@ def context(
*,
requested=False,
reusable=False,
+ labels=None,
):
return {
"github.event_name": event,
"github.event.action": action,
"github.event.label.name": label,
- "github.event.pull_request.labels.*.name": ["test:pytest"]
- if requested
- else [],
+ "github.event.pull_request.labels.*.name": (
+ list(labels)
+ if labels is not None
+ else (["test:pytest"] if requested else [])
+ ),
"github.event.pull_request.number": 42,
"github.ref": "refs/pull/42/merge"
if event == "pull_request"
@@ -216,13 +228,18 @@ class PytestSchedulingTests(unittest.TestCase):
requested,
)
- def test_only_pytest_label_runs_or_replaces_required_checks(self):
- for label in ("test:pytest", "bugfix", "test:notes"):
+ def test_only_request_labels_run_or_replace_required_checks(self):
+ for label in (
+ *REQUEST_LABELS,
+ "bugfix",
+ "test:notes",
+ "test:ui-full-shards",
+ ):
for requested in (False, True):
ctx = context(
action="labeled", label=label, requested=requested
)
- relevant = label == "test:pytest"
+ relevant = label in REQUEST_LABELS
with self.subTest(label=label, requested=requested):
for name, required in REQUIRED.items():
self.assertEqual(
@@ -236,6 +253,90 @@ class PytestSchedulingTests(unittest.TestCase):
relevant,
)
+ def test_each_readiness_label_requests_full_pytest_on_events_and_later_pushes(
+ self,
+ ):
+ for label, action in product(
+ REQUEST_LABELS, ("opened", "labeled", "synchronize", "reopened")
+ ):
+ ctx = context(action=action, label=label, labels=[label])
+ with self.subTest(label=label, action=action):
+ for name, required in REQUIRED.items():
+ self.assertTrue(
+ evaluate_condition(field(job(name), "if", 4), ctx)
+ )
+ self.assertEqual(
+ evaluate(field(job(name), "name", 4), ctx), required
+ )
+ self.assertTrue(
+ evaluate(
+ field(job("pytest-tests"), "PYTEST_REQUESTED", 10), ctx
+ )
+ )
+ self.assertTrue(
+ evaluate(field(WORKFLOW, "cancel-in-progress", 2), ctx)
+ )
+ self.assertEqual(
+ evaluate(field(WORKFLOW, "group", 2), ctx),
+ evaluate(field(WORKFLOW, "group", 2), context()),
+ )
+
+ def test_unrelated_labels_do_not_interrupt_a_readiness_requested_run(self):
+ for requested_label, event_label in product(
+ REQUEST_LABELS,
+ (
+ "bugfix",
+ "python",
+ "security",
+ "tests",
+ "test:notes",
+ "test:ui-full-shards",
+ ),
+ ):
+ ctx = context(
+ action="labeled",
+ label=event_label,
+ labels=[requested_label, event_label],
+ )
+ with self.subTest(
+ requested_label=requested_label, event_label=event_label
+ ):
+ for name, required in REQUIRED.items():
+ self.assertFalse(
+ evaluate_condition(field(job(name), "if", 4), ctx)
+ )
+ self.assertNotEqual(
+ evaluate(field(job(name), "name", 4), ctx), required
+ )
+ self.assertFalse(
+ evaluate(field(WORKFLOW, "cancel-in-progress", 2), ctx)
+ )
+ self.assertNotEqual(
+ evaluate(field(WORKFLOW, "group", 2), ctx),
+ evaluate(field(WORKFLOW, "group", 2), context()),
+ )
+
+ def test_readiness_requests_still_fail_closed_and_allow_cancellation(self):
+ for label, result in product(
+ REQUEST_LABELS, ("failure", "skipped", "cancelled")
+ ):
+ ctx = context(action="labeled", label=label, labels=[label])
+ ctx["needs.build-test-image.result"] = result
+ with self.subTest(label=label, image_result=result):
+ self.assertTrue(
+ evaluate_condition(
+ field(job("pytest-tests"), "if", 4), ctx, success=False
+ )
+ )
+ self.assertFalse(
+ evaluate_condition(
+ field(job("pytest-tests"), "if", 4),
+ ctx,
+ cancelled=True,
+ success=False,
+ )
+ )
+
def test_main_push_runs_full_pytest_without_a_pr_label(self):
ctx = context("push")
self.assertTrue(