Skip to content

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.

feat(ci): evaluate SkillEvaluator skills and publish PR summaries (#409)

Narendran Raghavan62191aa1127e
diff --git a/.github/workflows/skill-checks-all-tiers.yml b/.github/workflows/skill-checks-all-tiers.yml
new file mode 100644
index 00000000..66c8f37c
--- /dev/null
+++ b/.github/workflows/skill-checks-all-tiers.yml
@@ -0,0 +1,39 @@
+# Generated by SkillEvaluator all-tier CI onboarding.
+name: Skill checks (all tiers)
+'on':
+ pull_request: null
+ push:
+ branches:
+ - main
+ workflow_dispatch: null
+permissions:
+ contents: read
+ id-token: write
+ pull-requests: read
+ actions: read
+jobs:
+ skills:
+ uses: NVIDIA/SkillEvaluator/.github/workflows/evaluate-all-tiers.yml@c3b298c2b1a1a89d520bb22009f2668520127931
+ with:
+ tiers: 1,2,3
+ paths: skills
+ min-score: 70
+ scan-mode: auto
+ env-mode: docker
+ provider: nv_build
+ embedding-provider: nv_build
+ model: nvidia/nemotron-3.5-lightning-30b-a3b
+ embedding-model: ''
+ agents: ''
+ runner: ubuntu-24.04
+ tools-repository: NVIDIA/SkillEvaluator
+ tools-ref: c3b298c2b1a1a89d520bb22009f2668520127931
+ image: ghcr.io/nvidia/skillevaluator-tier1@sha256:9d5483243918937be4f2178f74cf7c622a531dee41e3176906994d52fa14950a
+ n-attempts: 1
+ n-concurrent: 1
+ timeout-minutes: 300
+ environment: skillevaluator
+ secrets:
+ OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
+ ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
+ NVIDIA_API_KEY: ${{ secrets.NVIDIA_API_KEY }}
diff --git a/.github/workflows/skill-feedback-all-tiers.yml b/.github/workflows/skill-feedback-all-tiers.yml
new file mode 100644
index 00000000..8656384a
--- /dev/null
+++ b/.github/workflows/skill-feedback-all-tiers.yml
@@ -0,0 +1,20 @@
+# Generated by SkillEvaluator all-tier CI onboarding.
+name: Skill feedback (all tiers)
+'on':
+ workflow_run:
+ workflows:
+ - Skill checks (all tiers)
+ types:
+ - completed
+permissions:
+ actions: read
+ contents: read
+ pull-requests: write
+jobs:
+ feedback:
+ uses: NVIDIA/SkillEvaluator/.github/workflows/feedback-all-tiers.yml@c3b298c2b1a1a89d520bb22009f2668520127931
+ with:
+ tools-repository: NVIDIA/SkillEvaluator
+ tools-ref: c3b298c2b1a1a89d520bb22009f2668520127931
+ trusted-workflow-ref: NVIDIA/SkillEvaluator/.github/workflows/evaluate-all-tiers.yml@c3b298c2b1a1a89d520bb22009f2668520127931
+ trusted-caller-blobs: 66c8f37c7987ec680d66b8365fde8557208b5257
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e24780dc..1a957183 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,15 @@ All notable changes to SkillEvaluator are documented in this file.
### Added
+- Run SkillEvaluator's own `skills/` through the pinned three-tier GitHub
+ callers, retaining Tier 1 as required and Tier 2/3 as advisory. A separate
+ consumer feedback listener preserves the reusable publisher's public path;
+ onboarding and status recognize this filename collision without replacing
+ reusable workflow definitions. Automatic comments activate after the
+ listener reaches the default branch.
+ Document the shared chat/judge/agent model input and model-availability
+ troubleshooting for provider-backed CI.
+
- `skills/skillevaluator/` is an agent skill for operating SkillEvaluator: it
routes requests to the right tier, readiness check, dataset, report, or CI
command, and ships Tier 3 evaluation cases for itself. A test keeps every
diff --git a/docs/github-actions.mdx b/docs/github-actions.mdx
index d3cdc192..71a69218 100644
--- a/docs/github-actions.mdx
+++ b/docs/github-actions.mdx
@@ -33,6 +33,36 @@ enable checks or comments on SkillEvaluator's own pull requests. Each repository
including SkillEvaluator itself, needs the generated caller pair committed
there, with the trusted feedback caller on its default branch.
+SkillEvaluator evaluates its own `skills/` collection with
+`.github/workflows/skill-checks-all-tiers.yml`. Its consumer feedback listener is
+`.github/workflows/skill-feedback-all-tiers.yml`, preserving the public reusable
+publisher at `.github/workflows/feedback-all-tiers.yml`. The CLI selects this
+alternate filename when the conventional feedback file already defines a
+reusable workflow, and `ci status --tiers 1,2,3` recognizes it.
+
+The repository callers pin a reviewed `main` commit for the evaluator workflows
+and tools, and the verified released Tier 1 image. They use Docker, NVIDIA Build,
+one attempt and one concurrent task, and the committed native datasets. The
+caller's explicit `model` input selects chat, judging and the default live-agent
+model together; embeddings use the separate `embedding-model` input. Add
+`NVIDIA_API_KEY` as a repository Actions secret before expecting provider-backed
+results. Without it, Tier 2 and Tier 3
+remain incomplete/advisory; a passing Tier 1 gate is not an all-tier evaluation
+pass. Forks retain keyless Tier 1 checks. On PRs, ordinary software changes
+select no skills, skill changes select the affected skills, and CI configuration
+changes select the collection. Pushes to `main` and manual runs scan the collection.
+
+If a provider returns HTTP 404, verify that the selected model accepts chat
+requests with your account. Presence in the public model catalog alone does not
+prove serving availability. Change the caller's `model` input to an accessible
+model and refresh `trusted-caller-blobs` before retrying; do not change global
+provider defaults to troubleshoot one repository.
+
+The setup PR can exercise checks, but its first automatic comment requires
+the consumer feedback listener on `main` and a subsequent PR run. Repository
+maintainers configure branch protection separately if they want the Tier 1
+aggregate check to block merges.
+
The evaluation workflow calls the existing hardened Tier 1 container workflow
at the same evaluator revision. Tier 2 and Tier 3 run independently with
`fail-fast: false`, Python 3.12, and only their tier's installed extras. Native
diff --git a/src/skillevaluator/_ci_onboarding_all_tiers.py b/src/skillevaluator/_ci_onboarding_all_tiers.py
index dfb767e5..90a51831 100644
--- a/src/skillevaluator/_ci_onboarding_all_tiers.py
+++ b/src/skillevaluator/_ci_onboarding_all_tiers.py
@@ -19,6 +19,7 @@ from skillevaluator import _ci_onboarding_git as git
SCAN = ".github/workflows/skill-checks-all-tiers.yml"
FEEDBACK = ".github/workflows/feedback-all-tiers.yml"
+ALTERNATE_FEEDBACK = ".github/workflows/skill-feedback-all-tiers.yml"
GL_SCAN = ".gitlab-ci.yml"
GL_FEEDBACK = ".gitlab/skill-feedback.yml"
SETUP_BRANCH = "ci/skillevaluator-all-tiers-setup"
@@ -341,6 +342,32 @@ class Client:
return url
+def _is_reusable_workflow(text: str) -> bool:
+ """Recognize workflow_call without YAML 1.1's unquoted-on ambiguity."""
+ try:
+ document = yaml.load(text, Loader=yaml.BaseLoader)
+ except (yaml.YAMLError, RecursionError):
+ return False
+ if not isinstance(document, dict):
+ return False
+ events = document.get("on")
+ return events == "workflow_call" or (isinstance(events, (dict, list)) and "workflow_call" in events)
+
+
+def _github_feedback_path(repo: Path) -> str:
+ # This file may be the evaluator's public reusable workflow. Validate every
+ # path component before reading it, just as check_files does before writes.
+ git.no_symlinks(repo, FEEDBACK)
+ existing = repo / FEEDBACK
+ if existing.is_file():
+ try:
+ if _is_reusable_workflow(existing.read_text(encoding="utf-8")):
+ return ALTERNATE_FEEDBACK
+ except UnicodeError:
+ pass # check_files will refuse an unrelated non-UTF-8 file.
+ return FEEDBACK
+
+
def render(wizard, repo, release, platform, branch, roots, options):
common = {
"tiers": "1,2,3",
@@ -364,6 +391,7 @@ def render(wizard, repo, release, platform, branch, roots, options):
}
header = "# Generated by SkillEvaluator all-tier CI onboarding.\n"
if platform == "github":
+ feedback_path = _github_feedback_path(repo)
scan = {
"name": "Skill checks (all tiers)",
"on": {"pull_request": None, "push": {"branches": [branch]}, "workflow_dispatch": None},
@@ -396,7 +424,7 @@ def render(wizard, repo, release, platform, branch, roots, options):
}
},
}
- return {SCAN: scan_text, FEEDBACK: header + wizard.yaml_text(feedback)}
+ return {SCAN: scan_text, feedback_path: header + wizard.yaml_text(feedback)}
variables = {
"SKILL_EVAL_" + key.upper().replace("-", "_"): str(value).lower() if isinstance(value, bool) else str(value)
for key, value in common.items()
@@ -650,13 +678,22 @@ def initialize(
git.require_clean(repo)
if platform == "github":
# Git API commits bypass local clean filters; approve the uploaded bytes.
- feedback = yaml.safe_load(files[FEEDBACK])
+ feedback_path = ALTERNATE_FEEDBACK if ALTERNATE_FEEDBACK in files else FEEDBACK
+ feedback = yaml.safe_load(files[feedback_path])
feedback["jobs"]["feedback"]["with"]["trusted-caller-blobs"] = wizard.blob_id(files[SCAN])
- files[FEEDBACK] = "# Generated by SkillEvaluator all-tier CI onboarding.\n" + wizard.yaml_text(feedback)
+ files[feedback_path] = "# Generated by SkillEvaluator all-tier CI onboarding.\n" + wizard.yaml_text(
+ feedback
+ )
client = Client(wizard, platform, origin, name)
info = client.info()
if info.get("default_branch") != branch:
raise git.SetupError("The live default branch differs; rerun with --default-branch.")
+ if platform == "github" and ALTERNATE_FEEDBACK in files:
+ current = client.file(FEEDBACK, branch)
+ if current is None or not _is_reusable_workflow(current):
+ raise git.SetupError(
+ f"{FEEDBACK} is not a reusable workflow on the default branch; update your checkout before setup."
+ )
pending = {}
for path, content in files.items():
current = client.file(path, branch)
@@ -851,6 +888,9 @@ def inspect(wizard, repo, platform="auto", tiers=None):
branch = info["default_branch"]
scan_path, feedback_path = (SCAN, FEEDBACK) if platform == "github" else (GL_SCAN, GL_FEEDBACK)
scan, feedback = client.file(scan_path, branch), client.file(feedback_path, branch)
+ if platform == "github" and feedback is not None and _is_reusable_workflow(feedback):
+ feedback_path = ALTERNATE_FEEDBACK
+ feedback = client.file(feedback_path, branch)
problem, feedback_problem, feedback_inputs = None, None, {}
if platform == "github":
if scan is not None:
@@ -871,17 +911,16 @@ def inspect(wizard, repo, platform="auto", tiers=None):
),
markup=False,
)
- wizard.console.print(
- "Trusted feedback: "
- + (
- "missing"
- if feedback is None
- else f"{feedback_path} is present but not a trusted feedback configuration ({feedback_problem})"
- if feedback_problem
- else "configured"
- ),
- markup=False,
+ feedback_status = (
+ "missing"
+ if feedback is None
+ else f"{feedback_path} is present but not a trusted feedback configuration ({feedback_problem})"
+ if feedback_problem
+ else "configured"
)
+ if feedback_path == ALTERNATE_FEEDBACK and not feedback_problem:
+ feedback_status += f" ({feedback_path})"
+ wizard.console.print("Trusted feedback: " + feedback_status, markup=False)
# Advisory only; the trusted include check above keeps parity with feedback.
unguarded = gitlab_unguarded_jobs(scan) if scan and platform == "gitlab" and not problem else []
if unguarded:
diff --git a/tests/ci/test_image_build.py b/tests/ci/test_image_build.py
index 479017b2..e090356f 100644
--- a/tests/ci/test_image_build.py
+++ b/tests/ci/test_image_build.py
@@ -146,11 +146,26 @@ def test_pull_requests_read_but_never_write_the_layer_cache():
assert step["with"]["context"] == "."
assert step["with"]["file"] == "ci/Dockerfile.tier1"
assert step["with"]["load"] == "true" and "push" not in step["with"]
- # These events run in main's cache scope on input that a pull request controls.
+ # Privileged events must never execute PR-controlled image/cache code.
for path in (ROOT / ".github/workflows").glob("*.yml"):
- triggers = yaml.load(path.read_text(encoding="utf-8"), Loader=yaml.BaseLoader)["on"]
+ document = yaml.load(path.read_text(encoding="utf-8"), Loader=yaml.BaseLoader)
+ triggers = document["on"]
triggers = [triggers] if isinstance(triggers, str) else triggers
- assert {"pull_request_target", "workflow_run", "issue_comment"}.isdisjoint(triggers), path.name
+ assert {"pull_request_target", "issue_comment"}.isdisjoint(triggers), path.name
+ if "workflow_run" in triggers:
+ # The consumer listener calls only the immutable trusted publisher;
+ # it has no local steps, candidate checkout or image build/cache job.
+ assert path.name == "skill-feedback-all-tiers.yml"
+ assert set(triggers) == {"workflow_run"}
+ assert set(document["jobs"]) == {"feedback"}
+ caller = document["jobs"]["feedback"]
+ assert set(caller) == {"uses", "with"}
+ assert re.fullmatch(
+ r"NVIDIA/SkillEvaluator/\.github/workflows/feedback-all-tiers\.yml@[0-9a-f]{40}", caller["uses"]
+ )
+ source = caller["uses"].rsplit("@", 1)[1]
+ assert caller["with"]["tools-repository"] == "NVIDIA/SkillEvaluator"
+ assert caller["with"]["tools-ref"] == source
def test_release_builds_reuse_no_cached_layers():
diff --git a/tests/ci/test_repository_skill_ci.py b/tests/ci/test_repository_skill_ci.py
new file mode 100644
index 00000000..f5fb2b22
--- /dev/null
+++ b/tests/ci/test_repository_skill_ci.py
@@ -0,0 +1,81 @@
+# SPDX-License-Identifier: Apache-2.0
+"""Keep this repository's consumer callers compatible with trusted upstream CI."""
+
+import re
+import subprocess
+from pathlib import Path
+
+import yaml
+
+ROOT = Path(__file__).parents[2]
+SCAN = ".github/workflows/skill-checks-all-tiers.yml"
+FEEDBACK = ".github/workflows/skill-feedback-all-tiers.yml"
+
+
+def workflow(path):
+ return yaml.load((ROOT / path).read_text(), Loader=yaml.BaseLoader)
+
+
+def test_repository_skill_checks_use_reviewed_full_three_tier_configuration():
+ scan = workflow(SCAN)
+ assert set(scan["on"]) == {"pull_request", "push", "workflow_dispatch"}
+ assert scan["on"]["push"]["branches"] == ["main"]
+ assert scan["permissions"] == {
+ "contents": "read",
+ "actions": "read",
+ "pull-requests": "read",
+ "id-token": "write",
+ }
+ job = scan["jobs"]["skills"]
+ prefix = "NVIDIA/SkillEvaluator/.github/workflows/evaluate-all-tiers.yml@"
+ assert job["uses"].startswith(prefix)
+ runtime = job["uses"].removeprefix(prefix)
+ assert re.fullmatch(r"[0-9a-f]{40}", runtime)
+ inputs = job["with"]
+ assert re.fullmatch(r"ghcr.io/nvidia/skillevaluator-tier1@sha256:[0-9a-f]{64}", inputs["image"])
+ assert inputs["tools-repository"] == "NVIDIA/SkillEvaluator"
+ assert inputs["tools-ref"] == runtime
+ assert inputs["tiers"] == "1,2,3"
+ assert inputs["paths"] == "skills"
+ assert inputs["scan-mode"] == "auto"
+ assert inputs["env-mode"] == "docker"
+ assert inputs["min-score"] == "70"
+ assert inputs["provider"] == inputs["embedding-provider"] == "nv_build"
+ assert inputs["environment"] == "skillevaluator"
+ assert inputs["n-attempts"] == inputs["n-concurrent"] == "1"
+ assert "tier3-required" not in inputs
+ assert job["secrets"] == {
+ key: "${{ secrets." + key + " }}" for key in ("OPENAI_API_KEY", "ANTHROPIC_API_KEY", "NVIDIA_API_KEY")
+ }
+ assert "steps" not in job
+
+
+def test_repository_feedback_approves_exact_caller_and_preserves_public_publisher():
+ feedback = workflow(FEEDBACK)
+ assert feedback["on"] == {"workflow_run": {"workflows": [workflow(SCAN)["name"]], "types": ["completed"]}}
+ assert feedback["permissions"] == {"contents": "read", "actions": "read", "pull-requests": "write"}
+ job = feedback["jobs"]["feedback"]
+ # A consumer keeps its reviewed runtime when a later release descriptor changes.
+ runtime = workflow(SCAN)["jobs"]["skills"]["with"]["tools-ref"]
+ assert job["uses"] == ("NVIDIA/SkillEvaluator/.github/workflows/feedback-all-tiers.yml@" + runtime)
+ assert "steps" not in job
+ assert "secrets" not in job
+ inputs = job["with"]
+ assert inputs["tools-ref"] == runtime
+ assert inputs["trusted-workflow-ref"] == workflow(SCAN)["jobs"]["skills"]["uses"]
+ # Apply the checkout's clean filters exactly as committing the caller does.
+ blob = subprocess.check_output(["git", "hash-object", "--path", SCAN, SCAN], cwd=ROOT, text=True).strip()
+ assert inputs["trusted-caller-blobs"] == blob
+ public = workflow(".github/workflows/feedback-all-tiers.yml")
+ assert set(public["on"]) == {"workflow_call"}
+ assert public["jobs"]["feedback"]["steps"]
+
+
+def test_repository_skill_has_committed_complete_dataset_prerequisites():
+ from ci.run_tiers import dataset_preflight
+
+ skills = sorted((ROOT / "skills").glob("*/SKILL.md"))
+ assert skills
+ for manifest in skills:
+ digests = dataset_preflight(manifest.parent)
+ assert "evals/evals.json" in digests
diff --git a/tests/test_ci_onboarding_all_tiers.py b/tests/test_ci_onboarding_all_tiers.py
index 127d62a3..df4c19df 100644
--- a/tests/test_ci_onboarding_all_tiers.py
+++ b/tests/test_ci_onboarding_all_tiers.py
@@ -24,6 +24,45 @@ ALL_RELEASE = {
"tools_ref": "f" * 40,
}
+REUSABLE_FEEDBACK = """# Preserve this reusable interface.
+name: Trusted three-tier skill feedback
+on:
+ workflow_call:
+ inputs:
+ tools-ref:
+ type: string
+ required: true
+jobs:
+ feedback:
+ runs-on: ubuntu-24.04
+ steps:
+ - run: echo reusable
+"""
+
+
+def reusable_feedback(repository):
+ path = repository / ".github/workflows/feedback-all-tiers.yml"
+ path.write_text(REUSABLE_FEEDBACK)
+ subprocess.run(["git", "-C", str(repository), "add", str(path)], check=True)
+ subprocess.run(
+ [
+ "git",
+ "-c",
+ "core.hooksPath=/dev/null",
+ "-c",
+ "commit.gpgsign=false",
+ "-C",
+ str(repository),
+ "commit",
+ "-m",
+ "Add reusable feedback workflow",
+ ],
+ check=True,
+ capture_output=True,
+ )
+ return path
+
@pytest.fixture
def all_release(tmp_path):
@@ -56,6 +95,58 @@ def test_all_tiers_save_github_is_minimal_pinned_and_idempotent(repository, all_
assert invoke(repository, all_release, "--mode", "save", "--paths", "skills").exit_code == 0
+def test_all_tiers_save_preserves_reusable_feedback_workflow(repository, all_release, reusable_feedback):
+ before = {path.relative_to(repository).as_posix() for path in repository.glob(".github/workflows/*")}
+ original = reusable_feedback.read_bytes()
+ result = invoke(repository, all_release, "--mode", "save", "--paths", "skills")
+ assert result.exit_code == 0, result.output
+ after = {path.relative_to(repository).as_posix() for path in repository.glob(".github/workflows/*")}
+ assert after - before == {
+ ".github/workflows/skill-checks-all-tiers.yml",
+ ".github/workflows/skill-feedback-all-tiers.yml",
+ }
+ assert reusable_feedback.read_bytes() == original
+ alternate = repository / ".github/workflows/skill-feedback-all-tiers.yml"
+ feedback = yaml.safe_load(alternate.read_text())
+ assert feedback["jobs"]["feedback"]["uses"].endswith("@" + ALL_RELEASE["feedback_ref"])
+ generated = alternate.read_bytes()
+ result = invoke(repository, all_release, "--mode", "save", "--paths", "skills")
+ assert result.exit_code == 0, result.output
+ assert reusable_feedback.read_bytes() == original
+ assert alternate.read_bytes() == generated
+
+
+def test_reusable_feedback_does_not_bypass_conflicting_alternate(repository, all_release, reusable_feedback):
+ alternate = repository / ".github/workflows/skill-feedback-all-tiers.yml"
+ alternate.write_text("name: Keep this unrelated workflow\n")
+ result = invoke(repository, all_release, "--mode", "save")
+ assert result.exit_code != 0
+ assert "skill-feedback-all-tiers.yml already exists" in " ".join(result.output.split())
+ assert not (repository / ".github/workflows/skill-checks-all-tiers.yml").exists()
+ assert reusable_feedback.read_text() == REUSABLE_FEEDBACK
+ assert alternate.read_text() == "name: Keep this unrelated workflow\n"
+
+
+def test_reusable_feedback_detection_does_not_read_symlinks(repository, all_release, tmp_path, monkeypatch):
+ from pathlib import Path
+
+ outside = tmp_path / "outside.yml"
+ outside.write_text(REUSABLE_FEEDBACK)
+ target = repository / ".github/workflows/feedback-all-tiers.yml"
+ target.symlink_to(outside)
+ original_read = Path.read_text
+
+ def read_text(path, *args, **kwargs):
+ assert path != target, "A workflow symlink must be rejected before its contents are read"
+ return original_read(path, *args, **kwargs)
+
+ monkeypatch.setattr(Path, "read_text", read_text)
+ result = invoke(repository, all_release, "--mode", "preview")
+ assert result.exit_code != 0
+ assert "Symlink" in result.output
+ assert not (repository / ".github/workflows/skill-feedback-all-tiers.yml").exists()
+
+
def test_all_tiers_preview_offline_and_local_options(repository, all_release, monkeypatch):
monkeypatch.setenv("GH_HOST", "unrelated.example")
before = subprocess.check_output(["git", "-C", str(repository), "status", "--porcelain"])
@@ -101,13 +192,15 @@ def test_unsupported_runtime_configuration_is_rejected_before_files(repository,
assert subprocess.check_output(["git", "-C", str(repository), "status", "--porcelain"]) == before
-def test_all_tiers_conflict_does_not_partially_save(repository, all_release):
[email protected]("content", ["name: Keep me\n", "true:\n workflow_call:\n", "on:\n workflow_dispatch:\n"])
+def test_all_tiers_conflict_does_not_partially_save(repository, all_release, content):
target = repository / ".github/workflows/feedback-all-tiers.yml"
- target.write_text("name: Keep me\n")
+ target.write_text(content)
result = invoke(repository, all_release, "--mode", "save")
assert result.exit_code != 0
+ assert ".github/workflows/feedback-all-tiers.yml already exists" in " ".join(result.output.split())
assert not (repository / ".github/workflows/skill-checks-all-tiers.yml").exists()
- assert target.read_text() == "name: Keep me\n"
+ assert target.read_text() == content
def test_gitlab_feedback_bootstrap_pins_are_literal_inputs(repository, all_release):
@@ -170,9 +263,19 @@ def test_invalid_tier_selection_fails_before_writes(repository, all_release, tie
assert not (repository / ".github/workflows/skill-checks-all-tiers.yml").exists()
-def test_github_setup_pr_is_api_only_and_preserves_checkout(repository, all_release, monkeypatch):
[email protected]("has_reusable_feedback", [False, True])
+def test_github_setup_pr_is_api_only_and_preserves_checkout(
+ repository, all_release, monkeypatch, request, has_reusable_feedback
+):
+ import base64
+
from skillevaluator import ci_onboarding as wizard
+ if has_reusable_feedback:
+ request.getfixturevalue("reusable_feedback")
+ feedback_path = ".github/workflows/" + (
+ "skill-feedback-all-tiers.yml" if has_reusable_feedback else "feedback-all-tiers.yml"
+ )
mutations = []
before = subprocess.check_output(["git", "-C", str(repository), "status", "--porcelain"])
@@ -190,6 +293,8 @@ def test_github_setup_pr_is_api_only_and_preserves_checkout(repository, all_rele
raise AssertionError(endpoint)
if endpoint == "repos/example-org/consumer":
return {"default_branch": "trunk"}
+ if has_reusable_feedback and "/contents/.github/workflows/feedback-all-tiers.yml?" in endpoint:
+ return {"encoding": "base64", "content": base64.b64encode(REUSABLE_FEEDBACK.encode()).decode()}
if "/contents/" in endpoint or endpoint.endswith("/git/ref/heads/ci%2Fskillevaluator-all-tiers-setup"):
return None
if "/pulls?" in endpoint:
@@ -209,10 +314,10 @@ def test_github_setup_pr_is_api_only_and_preserves_checkout(repository, all_rele
tree = next(payload for endpoint, payload in mutations if endpoint.endswith("/git/trees"))
assert {entry["path"] for entry in tree["tree"]} == {
".github/workflows/skill-checks-all-tiers.yml",
- ".github/workflows/feedback-all-tiers.yml",
+ feedback_path,
}
texts = {entry["path"]: entry["content"] for entry in tree["tree"]}
- feedback = yaml.safe_load(texts[".github/workflows/feedback-all-tiers.yml"])
+ feedback = yaml.safe_load(texts[feedback_path])
setup = next(payload for endpoint, payload in mutations if endpoint.endswith("/pulls"))
assert "Tier 1 required" in setup["body"]
assert "Tier 2 and Tier 3 advisory" in setup["body"]
@@ -222,6 +327,32 @@ def test_github_setup_pr_is_api_only_and_preserves_checkout(repository, all_rele
assert subprocess.check_output(["git", "-C", str(repository), "status", "--porcelain"]) == before
[email protected]("live_content", [None, "name: Existing consumer feedback\n"])
+def test_github_setup_pr_refuses_reusable_feedback_drift(
+ repository, all_release, reusable_feedback, monkeypatch, live_content
+):
+ import base64
+
+ from skillevaluator import ci_onboarding as wizard
+
+ def api(method, endpoint, payload=None, **kwargs):
+ assert method == "GET", "Conflicting default-branch feedback must stop before mutation"
+ if endpoint == "repos/example-org/consumer":
+ return {"default_branch": "trunk"}
+ if "/contents/.github/workflows/feedback-all-tiers.yml?" in endpoint and live_content is not None:
+ return {"encoding": "base64", "content": base64.b64encode(live_content.encode()).decode()}
+ if "/contents/" in endpoint:
+ return None
+ raise AssertionError(endpoint)
+
+ monkeypatch.setattr(wizard, "github_api", api)
+ result = invoke(repository, all_release, "--mode", "pr", "--paths", "skills")
+ assert result.exit_code != 0
+ assert "default branch" in result.output
+ assert not (repository / ".github/workflows/skill-checks-all-tiers.yml").exists()
+ assert reusable_feedback.read_text() == REUSABLE_FEEDBACK
+
+
def test_gitlab_token_api_rejects_host_mismatch_before_network(monkeypatch):
from skillevaluator import _ci_onboarding_all_tiers as all_tiers
@@ -352,6 +483,55 @@ def test_live_all_tier_status_recognizes_scan_and_approval(repository, all_relea
assert "not a verified scan" in result.output
[email protected]("alternate", ["generated", None, "name: Unrelated alternate\n"])
+def test_github_status_recognizes_reusable_feedback_collision(repository, all_release, monkeypatch, alternate):
+ import base64
+
+ from skillevaluator import ci_onboarding as wizard
+
+ # The live default branch has a reusable workflow even though this local
+ # checkout has the ordinary consumer caller at the canonical feedback path.
+ assert invoke(repository, all_release, "--mode", "save").exit_code == 0
+ scan_path = ".github/workflows/skill-checks-all-tiers.yml"
+ alternate_path = ".github/workflows/skill-feedback-all-tiers.yml"
+ texts = {
+ scan_path: (repository / scan_path).read_text(),
+ ".github/workflows/feedback-all-tiers.yml": REUSABLE_FEEDBACK,
+ }
+ if alternate is not None:
+ texts[alternate_path] = (
+ (repository / ".github/workflows/feedback-all-tiers.yml").read_text()
+ if alternate == "generated"
+ else alternate
+ )
+
+ def api(method, endpoint, payload=None, **kwargs):
+ assert method == "GET"
+ if endpoint == "repos/example-org/consumer":
+ return {"default_branch": "trunk"}
+ for path, text in texts.items():
+ if "/contents/" + path + "?" in endpoint:
+ return {"encoding": "base64", "content": base64.b64encode(text.encode()).decode()}
+ if "/contents/" + alternate_path + "?" in endpoint:
+ return None
+ if "/runs?" in endpoint:
+ return {"workflow_runs": []}
+ raise AssertionError(endpoint)
+
+ monkeypatch.setattr(wizard, "github_api", api)
+ result = CliRunner().invoke(cli, ["ci", "status", "--repo", str(repository)])
+ assert result.exit_code == 0, result.output
+ assert alternate_path in " ".join(result.output.split())
+ if alternate == "generated":
+ assert "Trusted feedback: configured" in result.output
+ assert "Scan approval: matches exact workflow" in result.output
+ elif alternate is None:
+ assert "Trusted feedback: missing" in result.output
+ else:
+ assert "not a trusted feedback configuration" in " ".join(result.output.split())
+ assert "Trusted feedback: configured" not in result.output
+
+
@pytest.mark.parametrize(
("component", "content"),
[