Multi-tier framework for evaluating AI agent skills and plugins with quality gates, security scanning, harness compatibility checks, semantic overlap detection, synthetic evaluation dataset generation, and live agent evaluation that measures how skills affect agent behavior. Ships reusable CI templates that bring every check to any repository.
Python agent-evaluationagent-pluginsagent-securityagent-skillsagentic-aibenchmarkci-templatesclaude-codecodexevaluateevaluationharnesspluginplugin-evaluationsecurity-scannerskill-evalskill-evaluationskill-evaluatorskill-gap-analysisskills
ci: run only the documentation tests for docs, changelog and readme changes (#701)
Christopher Kevina9097b68da8b
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 7bcffb9c..bd9e48b0 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -50,21 +50,20 @@ jobs:- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0with:persist-credentials: false+ # The setup steps and the boundary scan run in both lanes. The docs lane+ # needs the project installed for the documentation tests, and the scan+ # reads the documentation a docs-only pull request changes.- name: Set up Python- if: ${{ needs.classify-changes.outputs.docs_only != 'true' }}uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0with:python-version: "3.12"- name: Set up uv- if: ${{ needs.classify-changes.outputs.docs_only != 'true' }}uses: astral-sh/setup-uv@d31148d669074a8d0a63714ba94f3201e7020bc3 # v8.3.0with:version: "0.13.8"- name: Install dependencies- if: ${{ needs.classify-changes.outputs.docs_only != 'true' }}run: uv sync --all-extras --locked --python 3.12- name: Scan OSS source boundary- if: ${{ needs.classify-changes.outputs.docs_only != 'true' }}run: python scripts/check_oss_boundary.py --root . --allowlist config/oss_boundary_allowlist.json- name: Lint committed BENCHMARK.md fixtures for leak patternsif: ${{ needs.classify-changes.outputs.docs_only != 'true' }}@@ -92,6 +91,18 @@ jobs:echoecho "Validated docs and Fern configuration with Fern CLI $FERN_VERSION."} >> "$GITHUB_STEP_SUMMARY"+ # A docs-only pull request skips every other job, so this is where its+ # documentation tests run: every test file that reads a documentation file.+ # The selection is a plain assignment so that a failing selector stops the+ # step; pytest with no paths would run the whole suite.+ - name: Run documentation tests+ if: ${{ github.event_name == 'pull_request' && needs.classify-changes.outputs.docs_only == 'true' }}+ shell: bash+ run: |+ set -euo pipefail+ docs_tests="$(python -m scripts.select_docs_tests)"+ mapfile -t docs_test_files <<< "$docs_tests"+ uv run pytest -q -n auto "${docs_test_files[@]}"# Pull requests run the suite in parallel without coverage, like the 3.13# and 3.14 jobs. No pull-request check reads the coverage report, and# tracing it on one core made this the slowest required job by far.diff --git a/CHANGELOG.md b/CHANGELOG.mdindex e6343035..67b4d6d7 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -426,6 +426,8 @@ All notable changes to SkillEvaluator are documented in this file.### Fixed+- Documentation-only CI follows imports through collected test modules and+ package initializers, so dependent documentation assertions are included.- The Tier 1 PII scan no longer stalls on a long identifier before an IPv4-shaped value. A line with a30-letter name followed by `= "8.8.0.8"` took about a minute to scan, and every further letter doubled that.- On Windows, stopping a Tier 3 Harbor run no longer fails with `Harbor process-tree cleanup could not bediff --git a/scripts/classify_ci_changes.py b/scripts/classify_ci_changes.pyindex 0897af59..e6f8262d 100644--- a/scripts/classify_ci_changes.py+++ b/scripts/classify_ci_changes.py@@ -15,12 +15,16 @@ from collections.abc import Sequencefrom pathlib import PathDOC_PREFIXES = (b"docs/",)-DOC_FILES = frozenset({b"fern/docs.yml"})+# The root changelog and readme are documentation too: nearly every docs pull+# request adds a changelog line, and that line used to send it down the full+# lane. The docs lane runs the tests that read these files, so a broken entry is+# still caught on the pull request.+DOC_FILES = frozenset({b"fern/docs.yml", b"CHANGELOG.md", b"README.md"})KNOWN_STATUSES = frozenset(b"ACDMRTUXB")def is_docs_only(paths: Sequence[bytes]) -> bool:- """Return whether every changed path belongs to published documentation."""+ """Return whether every changed path is documentation the docs lane covers."""return bool(paths) and all(path.startswith(DOC_PREFIXES) or path in DOC_FILES for path in paths)diff --git a/scripts/select_docs_tests.py b/scripts/select_docs_tests.pynew file mode 100644index 00000000..819fde32--- /dev/null+++ b/scripts/select_docs_tests.py@@ -0,0 +1,123 @@+#!/usr/bin/env python3+# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.+# SPDX-License-Identifier: Apache-2.0++"""List the test files that read documentation, for the docs-only CI lane.++A docs-only pull request skips the platform matrix, so the tests that pin+documentation text have to run somewhere else. This prints every test file that+names a path the change classifier treats as documentation, or that imports a+test helper which does.++The match is on file text and is generous on purpose. An extra test file costs+seconds; a missed one lets a broken page reach ``main``. Two things are not+followed: a ``conftest.py`` fixture that reads documentation, and a helper+imported by a computed name.+"""++from __future__ import annotations++import argparse+import ast+import re+import sys+from collections.abc import Sequence+from fnmatch import fnmatch+from pathlib import Path, PurePosixPath++from scripts.classify_ci_changes import DOC_FILES, DOC_PREFIXES++# The same patterns pytest collects (``python_files`` in pyproject.toml).+_TEST_FILE_PATTERNS = ("test_*.py", "*_test.py")+++def doc_reference_pattern() -> re.Pattern[str]:+ """Match the ways a test names a path the classifier calls documentation.++ The patterns come from the classifier's own lists, so a path added there is+ covered here without a second edit.+ """+ alternatives = sorted({re.escape(PurePosixPath(path.decode()).name) for path in DOC_FILES})+ for directory in sorted({PurePosixPath(prefix.decode()).name for prefix in DOC_PREFIXES}):+ name = re.escape(directory)+ # ``"docs/page.mdx"`` as one string, or ``root / "docs" / "page.mdx"``.+ alternatives.append(rf"(?<![\w.-]){name}/")+ alternatives.append(rf"""["']{name}["']""")+ return re.compile("|".join(alternatives))+++def _is_test_file(path: Path) -> bool:+ return any(fnmatch(path.name, pattern) for pattern in _TEST_FILE_PATTERNS)+++def _imported_names(source: str) -> set[str] | None:+ """Every name an import statement mentions, or ``None`` if the file does not parse."""+ try:+ tree = ast.parse(source)+ except (SyntaxError, ValueError):+ return None+ names: set[str] = set()+ for node in ast.walk(tree):+ if isinstance(node, ast.Import):+ for alias in node.names:+ names.update(alias.name.split("."))+ elif isinstance(node, ast.ImportFrom):+ if node.module:+ names.update(node.module.split("."))+ names.update(alias.name for alias in node.names)+ return names+++def select_docs_tests(root: Path) -> list[str]:+ """Return the test files under ``root/tests`` that read documentation, as sorted POSIX paths."""+ pattern = doc_reference_pattern()+ reading: set[Path] = set()+ imports: dict[Path, set[str]] = {}+ for path in sorted((root / "tests").rglob("*.py")):+ if path.name == "conftest.py":+ continue+ source = path.read_text(encoding="utf-8", errors="replace")+ names = _imported_names(source)+ if names is None or pattern.search(source):+ # A file that does not parse cannot be ruled out, so it is selected.+ reading.add(path)+ else:+ imports[path] = names++ # A test can read documentation through a helper, and that helper through+ # another one, so follow imports until nothing new turns up.+ while True:+ # Collected test modules can also supply helpers. A package's reader+ # lives in __init__.py but is imported by the package directory's name.+ helper_names = {path.stem for path in reading}+ helper_names.update(path.parent.name for path in reading if path.name == "__init__.py")+ found = {path for path, names in imports.items() if names & helper_names}+ if not found:+ break+ reading |= found+ for path in found:+ del imports[path]++ return sorted(path.relative_to(root).as_posix() for path in reading if _is_test_file(path))+++def _parser() -> argparse.ArgumentParser:+ parser = argparse.ArgumentParser(description=__doc__)+ parser.add_argument("--root", type=Path, default=Path.cwd(), help="repository root to inspect")+ return parser+++def main(argv: Sequence[str] | None = None) -> int:+ """Print the selected test files, one per line."""+ args = _parser().parse_args(argv)+ selected = select_docs_tests(args.root)+ if not selected:+ # pytest with no paths runs the whole suite, so an empty answer must stop the lane.+ print("no documentation tests found; refusing to run an empty selection", file=sys.stderr)+ return 1+ print("\n".join(selected))+ return 0+++if __name__ == "__main__":+ raise SystemExit(main())diff --git a/tests/test_ci_change_classifier.py b/tests/test_ci_change_classifier.pyindex 0c085f14..d198ae67 100644--- a/tests/test_ci_change_classifier.py+++ b/tests/test_ci_change_classifier.py@@ -34,7 +34,7 @@ def git_repo(tmp_path: Path) -> tuple[Path, str]:_git(tmp_path, "config", "user.name", "CI Test")(tmp_path / "docs").mkdir()(tmp_path / "docs" / "index.mdx").write_text("docs source\n", encoding="utf-8")- (tmp_path / "README.md").write_text("root source\n", encoding="utf-8")+ (tmp_path / "pyproject.toml").write_text("root source\n", encoding="utf-8")return tmp_path, _commit(tmp_path, "initial")@@ -52,8 +52,15 @@ def git_repo(tmp_path: Path) -> tuple[Path, str]:([b"fern"], False),([b"docs-old/index.mdx"], False),([b"fernicious/docs.yml"], False),- ([b"README.md"], False),- ([b"CHANGELOG.md"], False),+ ([b"README.md"], True),+ ([b"CHANGELOG.md"], True),+ ([b"CHANGELOG.md", b"docs/index.mdx", b"fern/docs.yml"], True),+ ([b"CHANGELOG.md", b"src/skillevaluator/cli.py"], False),+ ([b"changelog.md"], False),+ ([b"CONTRIBUTING.md"], False),+ ([b"skills/skillevaluator/README.md"], False),+ ([b"tests/CHANGELOG.md"], False),+ ([b"skills/skillevaluator/SKILL.md"], False),([b"src/skillevaluator/tier3/reference_skills/demo/SKILL.md"], False),([b"tests/golden/benchmark_tier1.md"], False),([b"docs/index.mdx", b"src/skillevaluator/cli.py"], False),@@ -196,7 +203,7 @@ def test_main_checks_the_source_of_a_rename_into_docs(monkeypatch: pytest.MonkeyPatch,) -> None:repo, base = git_repo- _git(repo, "mv", "README.md", "docs/readme.mdx")+ _git(repo, "mv", "pyproject.toml", "docs/pyproject.mdx")head = _commit(repo, "rename into docs")assert _classify(repo, base, head, tmp_path / "github-output", monkeypatch) == 0@@ -207,13 +214,13 @@ def test_changed_paths_detects_an_unmodified_copy_source_outside_docs(git_repo: tuple[Path, str],) -> None:repo, base = git_repo- (repo / "docs" / "copied-readme.mdx").write_bytes((repo / "README.md").read_bytes())+ (repo / "docs" / "copied-root.mdx").write_bytes((repo / "pyproject.toml").read_bytes())head = _commit(repo, "copy root file into docs")paths = changed_paths(repo, base, head)- assert b"README.md" in paths- assert b"docs/copied-readme.mdx" in paths+ assert b"pyproject.toml" in paths+ assert b"docs/copied-root.mdx" in pathsassert is_docs_only(paths) is Falsediff --git a/tests/test_ci_workflows.py b/tests/test_ci_workflows.pyindex c2d69bc7..d68028db 100644--- a/tests/test_ci_workflows.py+++ b/tests/test_ci_workflows.py@@ -38,6 +38,9 @@ NOT_DOCS_ONLY_IF = "${{ needs.classify-changes.outputs.docs_only != 'true' }}"PULL_REQUEST_TESTS_IF = ("${{ github.event_name == 'pull_request' && needs.classify-changes.outputs.docs_only != 'true' }}")+DOCS_ONLY_TESTS_IF = (+ "${{ github.event_name == 'pull_request' && needs.classify-changes.outputs.docs_only == 'true' }}"+)MAIN_COVERAGE_IF = "${{ github.event_name != 'pull_request' }}"PR_CONCURRENCY = {"group": "${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}",@@ -137,11 +140,21 @@ def test_ci_validates_fern_on_the_required_python_312_context() -> None:assert job["runs-on"] == "ubuntu-latest"assert job["steps"][0]["with"]["persist-credentials"] == "false"- full_lane_step_names = {+ # The docs lane runs the documentation tests, so it needs the project+ # installed. It also scans for private integration names, because the scan+ # reads the documentation a docs-only pull request changes.+ both_lane_step_names = {"Set up Python","Set up uv","Install dependencies","Scan OSS source boundary",+ }+ both_lane_steps = {step.get("name"): step for step in job["steps"] if step.get("name") in both_lane_step_names}+ assert set(both_lane_steps) == both_lane_step_names+ assert all("if" not in step for step in both_lane_steps.values())++ full_lane_step_names = {+ "Lint committed BENCHMARK.md fixtures for leak patterns","Lint",}full_lane_steps = {step.get("name"): step for step in job["steps"] if step.get("name") in full_lane_step_names}@@ -149,6 +162,19 @@ def test_ci_validates_fern_on_the_required_python_312_context() -> None:assert all(step["if"] == NOT_DOCS_ONLY_IF for step in full_lane_steps.values())step_names = [step.get("name") for step in job["steps"]]+ # A docs-only pull request skips every other job, so this step is the only+ # place its documentation tests run.+ docs_tests = job["steps"][step_names.index("Run documentation tests")]+ assert docs_tests["if"] == DOCS_ONLY_TESTS_IF+ assert docs_tests["shell"] == "bash"+ docs_tests_run = docs_tests["run"].splitlines()+ assert docs_tests_run[0] == "set -euo pipefail"+ # The selection is captured with a plain assignment so that a failing+ # selector stops the step. pytest with no paths would run the whole suite.+ assert 'docs_tests="$(python -m scripts.select_docs_tests)"' in docs_tests_run+ assert 'mapfile -t docs_test_files <<< "$docs_tests"' in docs_tests_run+ assert 'uv run pytest -q -n auto "${docs_test_files[@]}"' in docs_tests_run+ assert "<(" not in docs_tests["run"], "a process substitution would hide a failing selector"pull_request_tests = job["steps"][step_names.index("Run tests")]main_tests = job["steps"][step_names.index("Run tests with coverage")]# Pull requests wait on this required job, so they run it like the 3.13 and@@ -168,12 +194,17 @@ def test_ci_validates_fern_on_the_required_python_312_context() -> None:"--cov-report=xml:coverage.xml",]pytest_steps = [step.get("name") for step in job["steps"] if "pytest" in step.get("run", "")]- assert pytest_steps == ["Run tests", "Run tests with coverage"], "exactly one pytest step runs per event"+ assert pytest_steps == [+ "Run documentation tests",+ "Run tests",+ "Run tests with coverage",+ ], "exactly one pytest step runs per event"node_step = next(step for step in job["steps"] if step.get("name") == "Set up Node.js for docs")docs_step = next(step for step in job["steps"] if step.get("name") == "Validate Fern documentation")# A failing suite must not hide a docs break, and the docs verdict should# not wait for the suite.+ assert step_names.index("Validate Fern documentation") < step_names.index("Run documentation tests")assert step_names.index("Validate Fern documentation") < step_names.index("Run tests")assert "if" not in node_step, "Fern validation must run for mixed and Fern dependency PRs"assert len(node_step["uses"].split("@", 1)[1]) == 40diff --git a/tests/test_select_docs_tests.py b/tests/test_select_docs_tests.pynew file mode 100644index 00000000..2ccf264e--- /dev/null+++ b/tests/test_select_docs_tests.py@@ -0,0 +1,179 @@+# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.+# SPDX-License-Identifier: Apache-2.0++from __future__ import annotations++from pathlib import Path++import pytest+from scripts.classify_ci_changes import DOC_FILES, DOC_PREFIXES+from scripts.select_docs_tests import main, select_docs_tests++REPO_ROOT = Path(__file__).resolve().parents[1]+++def _write(root: Path, relative: str, text: str) -> None:+ path = root / relative+ path.parent.mkdir(parents=True, exist_ok=True)+ path.write_text(text, encoding="utf-8")+++ "source",+ [+ 'TEXT = (ROOT / "CHANGELOG.md").read_text()\n',+ 'TEXT = (ROOT / "README.md").read_text()\n',+ 'PAGE = ROOT / "docs" / "reports.mdx"\n',+ "PAGE = ROOT / 'docs' / 'reports.mdx'\n",+ 'PAGE = ROOT / "docs/reports.mdx"\n',+ 'NAV = ROOT / "fern" / "docs.yml"\n',+ 'NAV = ROOT / "fern/docs.yml"\n',+ ],+)+def test_selects_a_test_file_that_names_a_documentation_file(tmp_path: Path, source: str) -> None:+ _write(tmp_path, "tests/test_reads_docs.py", source)+ _write(tmp_path, "tests/test_unrelated.py", 'VALUE = json.loads("{}")\n')++ assert select_docs_tests(tmp_path) == ["tests/test_reads_docs.py"]+++ "source",+ [+ 'NAME = "mydocs/page.mdx"\n',+ 'NAME = "docstring"\n',+ "import json\n",+ 'NAME = "CHANGELOG"\n',+ ],+)+def test_leaves_out_a_test_file_that_names_no_documentation_file(tmp_path: Path, source: str) -> None:+ _write(tmp_path, "tests/test_unrelated.py", source)++ assert select_docs_tests(tmp_path) == []+++def test_every_path_the_classifier_calls_documentation_selects_its_tests(tmp_path: Path) -> None:+ """A path added to the classifier is covered here without a second edit."""+ expected = []+ for index, path in enumerate(sorted(DOC_FILES)):+ expected.append(f"tests/test_file_{index}.py")+ _write(tmp_path, expected[-1], f'TEXT = (ROOT / "{path.decode()}").read_text()\n')+ for index, prefix in enumerate(DOC_PREFIXES):+ expected.append(f"tests/test_prefix_{index}.py")+ _write(tmp_path, expected[-1], f'PAGE = ROOT / "{prefix.decode()}page.mdx"\n')+ _write(tmp_path, "tests/test_unrelated.py", "VALUE = 1\n")++ assert select_docs_tests(tmp_path) == sorted(expected)+++def test_selects_a_test_file_that_reads_documentation_through_a_helper(tmp_path: Path) -> None:+ _write(tmp_path, "tests/changelog_entries.py", 'CHANGELOG = ROOT / "CHANGELOG.md"\n')+ _write(tmp_path, "tests/middle.py", "import changelog_entries\n")+ _write(tmp_path, "tests/test_plain_import.py", "from changelog_entries import CHANGELOG\n")+ _write(tmp_path, "tests/reporting/test_package_import.py", "from tests.changelog_entries import CHANGELOG\n")+ _write(tmp_path, "tests/reporting/test_relative_import.py", "from .. import changelog_entries\n")+ _write(tmp_path, "tests/test_through_two_helpers.py", "import middle\n")+ _write(tmp_path, "tests/test_unrelated.py", "import json\n")++ assert select_docs_tests(tmp_path) == [+ "tests/reporting/test_package_import.py",+ "tests/reporting/test_relative_import.py",+ "tests/test_plain_import.py",+ "tests/test_through_two_helpers.py",+ ]+++def test_lists_only_collected_test_files(tmp_path: Path) -> None:+ reads_docs = 'TEXT = (ROOT / "README.md").read_text()\n'+ _write(tmp_path, "tests/test_prefixed.py", reads_docs)+ _write(tmp_path, "tests/tier3/suffixed_test.py", reads_docs)+ _write(tmp_path, "tests/helper.py", reads_docs)+ _write(tmp_path, "tests/conftest.py", reads_docs)+ _write(tmp_path, "src/test_outside_tests.py", reads_docs)++ assert select_docs_tests(tmp_path) == ["tests/test_prefixed.py", "tests/tier3/suffixed_test.py"]++[email protected]("helper_module", ["test_doc_reader", "doc_reader_test"])+def test_follows_a_documentation_reader_in_another_collected_test_module(+ tmp_path: Path, helper_module: str+) -> None:+ _write(+ tmp_path,+ f"tests/{helper_module}.py",+ 'def read_page():\n return (ROOT / "README.md").read_text()\n\ndef test_smoke():\n assert True\n',+ )+ _write(+ tmp_path,+ "tests/test_consumer.py",+ f'from {helper_module} import read_page\n\ndef test_readme_contract():\n assert "required" in read_page()\n',+ )++ assert select_docs_tests(tmp_path) == sorted([f"tests/{helper_module}.py", "tests/test_consumer.py"])+++def test_follows_a_documentation_reader_in_a_package_initializer(tmp_path: Path) -> None:+ _write(+ tmp_path,+ "tests/doc_helpers/__init__.py",+ 'def read_page():\n return (ROOT / "README.md").read_text()\n',+ )+ _write(tmp_path, "tests/middle.py", "from doc_helpers import read_page\n")+ _write(+ tmp_path,+ "tests/test_consumer.py",+ 'from middle import read_page\n\ndef test_readme_contract():\n assert "required" in read_page()\n',+ )++ assert select_docs_tests(tmp_path) == ["tests/test_consumer.py"]+++def test_selects_a_test_file_it_cannot_parse(tmp_path: Path) -> None:+ """Its imports are unknown, so it cannot be ruled out; pytest then reports the syntax error."""+ _write(tmp_path, "tests/test_broken.py", "def broken(:\n")++ assert select_docs_tests(tmp_path) == ["tests/test_broken.py"]+++def test_main_prints_one_selected_file_per_line(tmp_path: Path, capsys: pytest.CaptureFixture[str]) -> None:+ _write(tmp_path, "tests/test_b.py", 'TEXT = "CHANGELOG.md"\n')+ _write(tmp_path, "tests/test_a.py", 'TEXT = "README.md"\n')+ _write(tmp_path, "tests/test_unrelated.py", "VALUE = 1\n")++ assert main(["--root", str(tmp_path)]) == 0++ assert capsys.readouterr().out == "tests/test_a.py\ntests/test_b.py\n"+++def test_main_refuses_an_empty_selection(tmp_path: Path, capsys: pytest.CaptureFixture[str]) -> None:+ """pytest with no paths runs the whole suite, so an empty answer must not look like success."""+ _write(tmp_path, "tests/test_unrelated.py", "VALUE = 1\n")++ assert main(["--root", str(tmp_path)]) == 1++ captured = capsys.readouterr()+ assert captured.out == ""+ assert "no documentation tests found" in captured.err+++def test_the_repository_selection_covers_tests_known_to_read_documentation() -> None:+ selected = set(select_docs_tests(REPO_ROOT))+ every_test_file = {+ path.relative_to(REPO_ROOT).as_posix()+ for pattern in ("test_*.py", "*_test.py")+ for path in (REPO_ROOT / "tests").rglob(pattern)+ }++ assert {+ # Documentation pages.+ "tests/test_metrics_reference_docs.py",+ "tests/test_benchmark_rollout_docs.py",+ # The readme and the changelog.+ "tests/test_oss_packaging.py",+ # The changelog, in a subdirectory.+ "tests/reporting/test_tier3_incomplete_arms.py",+ # The Fern navigation file.+ "tests/test_ci_workflows.py",+ } <= selected+ assert selected <= every_test_file+ assert len(selected) < len(every_test_file) / 2, "the docs lane should stay a small part of the suite"