Files
max-sixty__worktrunk/.pre-commit-config.yaml
Maximilian Roos c8de0d872a ci: move lychee link check to the nightly workflow (#3402)
Moves the lychee link check out of PR CI into the `nightly` workflow.
Link health depends on external sites (429s, bot-blocking, link rot),
which made `lint` the flakiest PR check, and breakage isn't correlated
with the PR that trips it: the most recent main run's lint job went red
on the docs.anthropic.com restructure (fixed in #3399) with no code
change involved.

The hook stays defined once in `.pre-commit-config.yaml`, moved to the
`manual` stage, so the PR `lint` job, local `pre-commit run
--all-files`, and the `wt merge` gate all skip it (the wt.toml Windows
conditional existed only to skip lychee and collapses). The new
`link-check` nightly job runs that stage with the pinned lychee and is
wired into `create-issue-on-nightly-failure`, so breakage lands in the
nightly-failure issue for tend instead of blocking unrelated PRs.
Running through pre-commit rather than `git ls-files | xargs lychee`
keeps file selection at one definition: pre-commit's `types: [file]`
filter excludes the 16 tracked `.md`/`.txt` symlinks, which would
otherwise false-positive on relative links resolved against the
symlink's directory.

The trade: a PR that introduces a genuinely wrong URL now merges green
and is caught up to a day later, asynchronously.

Verified locally that the default stage no longer selects the hook and
that `pre-commit run lychee-system --all-files --hook-stage manual`
reproduces the CI lint run's selection exactly (same two flagged
inputs). The nightly job itself first runs on the next cron or a
`workflow_dispatch`.

> _This was written by Claude Code on behalf of max_

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-09 20:12:03 -07:00

94 lines
3.8 KiB
YAML

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: end-of-file-fixer
exclude: '.*\.snap$|^vendor/'
- id: check-yaml
- id: mixed-line-ending
exclude: '^vendor/'
- id: trailing-whitespace
# rustfmt handles rust files, and in snapshots we expect trailing spaces.
exclude: '.*\.(rs|snap)$|^vendor/'
# pre-commit autoupdate reverts to mutable v1 tag; update manually
- repo: https://github.com/crate-ci/typos
rev: v1
hooks:
- id: typos
# https://github.com/crate-ci/typos/issues/347
pass_filenames: false
- repo: https://github.com/r0x0d/pre-commit-rust
rev: v1.0.1
hooks:
- id: fmt
exclude: '^vendor/'
- repo: https://github.com/r0x0d/pre-commit-rust
rev: v1.0.1
hooks:
- id: clippy
args: ["--all-targets", "--all-features", "--", "-D", "warnings"]
# pre-commit autoupdate reverts to mutable nightly tag; update manually
- repo: https://github.com/lycheeverse/lychee
rev: nightly
hooks:
# Check links using .config/lychee.toml exclusions
# Uses lychee-system (requires `cargo install lychee`) to avoid /bin/bash dependency on Windows
#
# Manual stage only: link health depends on external sites (429s,
# bot-blocking, link rot), so it runs as the `link-check` job in the
# nightly workflow, not on every commit/PR.
- id: lychee-system
stages: [manual]
files: '\.(md|txt)$'
args:
- --config=.config/lychee.toml
- repo: local
hooks:
- id: cargo-lock
name: cargo-lock
description: Ensure Cargo.lock is in sync with Cargo.toml
language: system
entry: cargo check --locked
pass_filenames: false
files: (Cargo\.toml|Cargo\.lock)$
- id: no-dbg
name: no-dbg
description: We shouldn't merge code with `dbg!` in
language: pygrep
types: ["rust"]
entry: "dbg!"
- id: no-manual-ansi
name: no-manual-ansi
description: Use anstyle/osc8/strip-ansi-escapes instead of manual ANSI codes
language: pygrep
types: ["rust"]
entry: '\\x1b\['
# format.rs strips ANSI codes injected by wrap_ansi crate
# picker tests verify ANSI dimming behavior
# src/testing: validate_ansi_codes tests raw escape sequences
exclude: '^(tests/|.*_test\.rs$|src/styling/(mod|format)\.rs$|src/commands/picker/|src/testing/|vendor/)'
- id: no-std-canonicalize-in-tests
name: no-std-canonicalize-in-tests
description: Use dunce::canonicalize in tests to avoid Windows \\?\ prefix issues
language: pygrep
entry: '\.canonicalize\(\)'
files: '^tests/'
- id: no-direct-cmd-output
name: no-direct-cmd-output
description: Use shell_exec::Cmd instead of cmd.output() for consistent logging
language: pygrep
types: ["rust"]
entry: '\.output\(\)'
# shell_exec.rs: defines Cmd which legitimately calls .output()
# picker: skim API's selected.output() is not Command::output()
# tests/benches: test utilities run commands directly
# src/config/{test,expansion,mod}.rs: TestRepo test fixtures use git init directly
# src/config/user/tests.rs: TestRepo test fixtures use git init directly
# src/styling/mod.rs: terminal width detection probes should be silent/quick
exclude: '^(src/shell_exec\.rs|src/commands/picker/|src/config/(test|expansion|mod)\.rs|src/config/user/tests\.rs|src/styling/mod\.rs|src/testing/|tests/|benches/)'
ci:
# pre-commit.ci doesn't have Rust toolchain, so skip Rust-specific hooks.
skip: [fmt, clippy, cargo-lock]
autoupdate_commit_msg: "chore: pre-commit autoupdate"