Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,17 @@ jobs:
tests/test_tier3_progress.py
tests/test_tier3_result_display.py
tests/test_harbor_runtime_preflight.py
tests/embedding/test_catalog.py::TestCatalogPersistence::test_catalog_io_supports_root_owned_tmp_alias

# Tier 2 is platform-independent Python, and Linux and Windows run the same
# tests on every pull request. This job never failed for a macOS-specific
# reason, so it runs after merge only. Its one macOS-only test, the /tmp
# alias test, runs in the Tier 3 macOS job above on every pull request. The
# job stays defined, and is skipped on pull requests, so the required check
# of the same name still reports.
tier2-macos:
name: Tier 2 (macos-latest)
needs: classify-changes
if: ${{ !cancelled() && needs.classify-changes.outputs.docs_only != 'true' }}
if: ${{ github.event_name != 'pull_request' }}
runs-on: macos-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,8 @@ All notable changes to SkillEvaluator are documented in this file.

### Fixed

- Direct Tier 1 validates the target, selected checks and LLM configuration before
preparing scanners, so configuration errors do not trigger downloads or stdout noise.
- 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 a
Expand Down
2 changes: 1 addition & 1 deletion src/skillevaluator/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3591,7 +3591,6 @@ def _tier1_workflow(
policy = resolve_policy(profile=profile, policy_path=policy_path)
except (FileNotFoundError, ValueError) as exc:
raise click.ClickException(str(exc)) from exc
_offer_scanner_install(checks, skip)
results = run_tier1_workflow(
skill_path,
checks=checks,
Expand All @@ -3603,6 +3602,7 @@ def _tier1_workflow(
profile=policy,
previous_version=previous_version,
skillspector_baseline=skillspector_baseline,
prepare_scanners=lambda: _offer_scanner_install(checks, skip),
)
# Resolved after the run so configuration errors still leave no output.
output_dir = _resolve_file_report_output_location(skill_path.resolve(), output_dir, report_formats)
Expand Down
5 changes: 5 additions & 0 deletions src/skillevaluator/tier_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from __future__ import annotations

import os
from collections.abc import Callable
from pathlib import Path
from typing import TYPE_CHECKING

Expand Down Expand Up @@ -75,7 +76,9 @@ def run_tier1_workflow(
pii_waivers: Path | None = None,
skillspector_baseline: Path | None = None,
skip: str | None = None,
prepare_scanners: Callable[[], None] | None = None,
) -> list[ValidationResult]:
"""Validate local configuration before optional scanner preparation and checks."""
require_skill(skill_path)
if checks is not None and not checks.strip(", \t\n"):
raise click.UsageError("--checks must name at least one static check.")
Expand All @@ -90,6 +93,8 @@ def run_tier1_workflow(
import openai # noqa: F401 -- fail before scanning if the LLM extra is absent
except ImportError as exc:
raise click.ClickException("Install skillevaluator[llm] to run LLM checks.") from exc
if prepare_scanners is not None:
prepare_scanners()
results = tier1.run_validation(
skill_path,
checks=selected,
Expand Down
103 changes: 102 additions & 1 deletion tests/cli/test_tier_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ def skill(tmp_path):
return path


@pytest.fixture(autouse=True)
def isolate_scanner_preparation(monkeypatch):
# Workflow composition tests do not install tools. Ordering tests below
# replace this stub with explicit spies for both rejected and valid inputs.
monkeypatch.setattr("skillevaluator.cli._offer_scanner_install", lambda *_args: None)


def _result(name):
result = ValidationResult(validator_name=name)
result.add_success("checked", "Completed this check")
Expand Down Expand Up @@ -150,7 +157,9 @@ def test_keyless_tier1_reports_unrun_llm_scope(skill, tmp_path):


@pytest.mark.parametrize("tier,options", [("tier1", ["--llm"]), ("tier2", [])])
def test_required_provider_failure_is_a_configuration_error(tier, options, skill, tmp_path):
def test_required_provider_failure_is_a_configuration_error(tier, options, skill, tmp_path, monkeypatch):
preparations = []
monkeypatch.setattr("skillevaluator.cli._offer_scanner_install", lambda *_args: preparations.append("prepare"))
result = CliRunner().invoke(cli, [tier, str(skill), *options, "-o", str(tmp_path / "reports")])
assert result.exit_code == 1
assert result.stdout == ""
Expand All @@ -159,6 +168,98 @@ def test_required_provider_failure_is_a_configuration_error(tier, options, skill
assert ("--no-llm" in result.stderr) is (tier == "tier1")
assert "No such command" not in result.output
assert not (tmp_path / "reports").exists()
assert preparations == []


@pytest.mark.parametrize("case", ["unknown_checks", "empty_checks", "missing_manifest"])
def test_tier1_rejects_local_configuration_before_scanner_preparation(case, skill, tmp_path, monkeypatch):
preparations = []
monkeypatch.setattr("skillevaluator.cli._offer_scanner_install", lambda *_args: preparations.append("prepare"))
options = ["--no-llm"]
if case == "unknown_checks":
options += ["--checks", "schema,unknown"]
elif case == "empty_checks":
options += ["--checks", " , "]
else:
(skill / "SKILL.md").unlink()

result = CliRunner().invoke(cli, ["tier1", str(skill), *options, "-o", str(tmp_path / "reports")])

assert result.exit_code == 2, result.output
assert preparations == []
assert not (tmp_path / "reports").exists()


def test_tier1_rejects_missing_llm_extra_before_scanner_preparation(skill, tmp_path, monkeypatch):
import sys

preparations = []
monkeypatch.setattr("skillevaluator.cli._offer_scanner_install", lambda *_args: preparations.append("prepare"))
monkeypatch.setenv("SKILL_EVAL_LLM_PROVIDER", "nv_build")
monkeypatch.setenv("NVIDIA_API_KEY", "test-credential")
monkeypatch.setitem(sys.modules, "openai", None)

result = CliRunner().invoke(cli, ["tier1", str(skill), "--llm", "-o", str(tmp_path / "reports")])

assert result.exit_code == 1, result.output
assert "Install skillevaluator[llm]" in result.stderr
assert result.stdout == ""
assert preparations == []
assert not (tmp_path / "reports").exists()


@pytest.mark.parametrize("mode", ["keyless", "no_llm", "configured_llm"])
def test_tier1_prepares_scanners_once_after_preflight_and_before_checks(mode, skill, tmp_path, monkeypatch):
from skillevaluator.tier1 import commands

stages = []
monkeypatch.setattr(
"skillevaluator.cli._offer_scanner_install",
lambda checks, skip: stages.append(("prepare", checks, skip)),
)

def validation(_path, **kwargs):
stages.append(("validation", kwargs["checks"], kwargs["skip"]))
return _result("Schema Validation")

def rubric(_path, **_kwargs):
stages.append(("rubric", None, None))
return _result("Rubric Evaluation")

monkeypatch.setattr(commands, "run_validation", validation)
monkeypatch.setattr(commands, "run_rubric_eval", rubric)
options = []
if mode == "no_llm":
options = ["--no-llm"]
elif mode == "configured_llm":
monkeypatch.setenv("SKILL_EVAL_LLM_PROVIDER", "nv_build")
monkeypatch.setenv("NVIDIA_API_KEY", "test-credential")
options = ["--llm"]
reports = tmp_path / "reports"

result = CliRunner().invoke(
cli,
[
"tier1",
str(skill),
"--checks",
"schema,security",
"--skip",
"security",
*options,
"-r",
"json",
"-o",
str(reports),
],
)

assert result.exit_code == 0, result.output
expected = [("prepare", "schema,security", "security"), ("validation", "schema,security", "security")]
if mode == "configured_llm":
expected.append(("rubric", None, None))
assert stages == expected
assert _report(reports)["results"][0]["workflow"]["tier"] == 1


def test_tier2_combines_intra_and_catalog_comparison_once(skill, tmp_path, monkeypatch):
Expand Down
25 changes: 24 additions & 1 deletion tests/test_ci_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
"tier3-macos": "Tier 3 macOS contract and progress",
"native-windows-local-mode": "Native Windows local mode fails closed",
}
HEAVY_CI_JOBS = set(REQUIRED_CI_JOBS) - {"test-python-312"}
# Required jobs that are skipped on every pull request and run after merge.
AFTER_MERGE_ONLY_CI_JOBS = {"tier2-macos"}
HEAVY_CI_JOBS = set(REQUIRED_CI_JOBS) - {"test-python-312"} - AFTER_MERGE_ONLY_CI_JOBS
RUN_UNLESS_CANCELLED_IF = "${{ !cancelled() }}"
FULL_LANE_IF = "${{ !cancelled() && needs.classify-changes.outputs.docs_only != 'true' }}"
NOT_DOCS_ONLY_IF = "${{ needs.classify-changes.outputs.docs_only != 'true' }}"
Expand All @@ -42,6 +44,7 @@
"${{ github.event_name == 'pull_request' && needs.classify-changes.outputs.docs_only == 'true' }}"
)
MAIN_COVERAGE_IF = "${{ github.event_name != 'pull_request' }}"
AFTER_MERGE_ONLY_IF = "${{ github.event_name != 'pull_request' }}"
PR_CONCURRENCY = {
"group": "${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}",
"cancel-in-progress": "true",
Expand Down Expand Up @@ -244,6 +247,26 @@ def test_ci_skips_every_other_required_job_only_after_classification() -> None:
assert jobs[job_id]["if"] == FULL_LANE_IF


def test_tier2_runs_on_macos_after_merge_only_and_keeps_its_required_name() -> None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Required local checks not run

The PR reports focused tests but leaves make test and make build unchecked. Both remain mandatory under the contribution gate, including for CI-only changes.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

jobs = _load("ci.yml")["jobs"]

for job_id in AFTER_MERGE_ONLY_CI_JOBS:
job = jobs[job_id]
# The job is skipped on pull requests, not removed: a skipped job still
# reports, so the required check of the same name does not block a merge.
assert job["name"] == REQUIRED_CI_JOBS[job_id]
assert job["if"] == AFTER_MERGE_ONLY_IF
# The classifier only runs on pull requests, where this job never runs.
assert "needs" not in job

# The one Tier 2 test that only runs on macOS keeps running on pull requests.
assert (
"tests/embedding/test_catalog.py::TestCatalogPersistence::test_catalog_io_supports_root_owned_tmp_alias"
in _runs(jobs["tier3-macos"])
)
assert jobs["tier3-macos"]["if"] == FULL_LANE_IF


def test_full_lane_keeps_the_existing_commands_and_runners() -> None:
jobs = _load("ci.yml")["jobs"]

Expand Down
Loading