Skip to content
Open
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
16 changes: 16 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,19 @@
pass_filenames: false
always_run: true
stages: [pre-push, manual]

# Lint a repository's own stdio MCP server on every commit. The command is one
# `args` entry, so a command with spaces stays one argument:
#
# - id: toolgauge-lint
# args: ["node dist/server.js"]
#
# The server is started once and its manifest is read; it needs no endpoint.
- id: toolgauge-lint
name: toolgauge MCP manifest lint
description: Lint a stdio MCP server's tool manifest and fail on a failed rule.
entry: toolgauge lint --command
language: system
pass_filenames: false
always_run: true
stages: [pre-commit, manual]
2 changes: 1 addition & 1 deletion docs/USING.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ than one from a single scan.
| GitHub | `uses: patsypppe/sentinel@v0.4.0`. Inputs: `endpoint`, `gate`, `config`, `baseline`, `snapshot`, `targets`, `safe`, `no-exec`, `token`. Writes a Markdown job summary, uploads SARIF. |
| GitLab | `include:` [`ci/gitlab/toolgauge.gitlab-ci.yml`](../ci/gitlab/toolgauge.gitlab-ci.yml) and `extends: .toolgauge-scan`. Publishes JUnit. |
| Any CI | `docker run ghcr.io/patsypppe/toolgauge scan --endpoint ...` |
| pre-commit | the `toolgauge-scan` hook (`pre-push`, so a few hundred requests do not run on every commit) |
| pre-commit | the `toolgauge-scan` hook (`pre-push`, so a few hundred requests do not run on every commit); `toolgauge-lint` checks a stdio server's manifest on every commit |
| PyPI | `uvx toolgauge scan --endpoint ...` |

Releases are signed with cosign (keyless, from the release workflow's own identity, so there is no
Expand Down
14 changes: 11 additions & 3 deletions tests/harness/test_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,22 @@ def test_every_flag_the_gitlab_template_passes_exists() -> None:


def test_the_precommit_hooks_are_well_formed_and_their_flags_exist() -> None:
hooks = load(".pre-commit-hooks.yaml")
assert {h["id"] for h in hooks} == {"toolgauge-scan", "toolgauge-scan-local"}
for hook in hooks:
hooks = {h["id"]: h for h in load(".pre-commit-hooks.yaml")}
assert set(hooks) == {"toolgauge-scan", "toolgauge-scan-local", "toolgauge-lint"}
for hook_id in ("toolgauge-scan", "toolgauge-scan-local"):
hook = hooks[hook_id]
assert hook["pass_filenames"] is False, "a scan is of a server, not of changed files"
assert hook["language"] in {"docker_image", "system"}
assert "pre-push" in hook["stages"], "a scan makes hundreds of requests"
assert set(re.findall(r"--[a-z][a-z0-9-]*", hook["entry"])) <= cli_flags("scan")

lint = hooks["toolgauge-lint"]
assert lint["pass_filenames"] is False
assert lint["language"] == "system", "the server runs on the machine being committed"
assert "pre-commit" in lint["stages"]
assert lint["entry"].endswith("--command"), "the user supplies the command as one argument"
assert set(re.findall(r"--[a-z][a-z0-9-]*", lint["entry"])) <= cli_flags("lint")


def test_the_gitlab_junit_report_is_what_the_scan_writes() -> None:
job = load("ci/gitlab/toolgauge.gitlab-ci.yml")[".toolgauge-scan"]
Expand Down