diff --git a/.docdrift.yaml b/.docdrift.yaml new file mode 100644 index 0000000..b1f1e4a --- /dev/null +++ b/.docdrift.yaml @@ -0,0 +1,50 @@ +# doc-drift-checker: reports README sections whose linked code changed while the +# section did not. Runs on pull requests in CI (job `drift`), warn-only for now. +docs: + - "README.md" + +# A present `ignore` key replaces the built-in list, so the defaults are repeated. +ignore: + # tests + - "**/*_test.go" + - "**/*.test.*" + - "**/*.spec.*" + - "**/test/**" + - "**/tests/**" + - "**/__tests__/**" + - "**/testdata/**" + # generated code + - "**/*.pb.go" + - "**/*_gen.go" + - "**/*.generated.*" + - "**/generated/**" + - "**/*.min.js" + # lockfiles + - "**/go.sum" + - "**/package-lock.json" + - "**/yarn.lock" + - "**/pnpm-lock.yaml" + - "**/composer.lock" + - "**/Cargo.lock" + - "**/Gemfile.lock" + - "**/poetry.lock" + - "**/uv.lock" + # vendored code + - "**/vendor/**" + - "**/node_modules/**" + - "**/third_party/**" + # not described by README sections + - "CHANGELOG.md" + - "LICENSE" + - ".github/**" + +# A key is the full heading text including the emoji, or "#" plus the anchor +# ("#-flags"). A key that matches no heading is ignored silently. +# "🔢 Exit codes" is deliberately not mapped: the exit codes come out of +# internal/cli/run.go, which changes with almost every feature, so a mapping +# would report drift on changes that leave the exit codes untouched. +mappings: + "🚩 Flags": + - "internal/cli/root.go" + "🛡️ Stopping safely": + - "internal/kill/**" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index abceccc..3cda3c1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -40,3 +40,24 @@ jobs: - uses: golangci/golangci-lint-action@v8 with: version: latest + + drift: + # Warn-only: reports README sections whose linked code changed (see .docdrift.yaml). + if: github.event_name == 'pull_request' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-go@v5 + with: + # The checker is built independently of this project's Go version. + go-version: stable + - name: Install doc-drift-checker + run: go install github.com/JtheGunner/doc-drift-checker/cmd/doc-drift-checker@v0.2.2 + - name: Check README drift + env: + BASE_REF: ${{ github.base_ref }} + run: | + git fetch --no-tags origin "+refs/heads/${BASE_REF}:refs/remotes/origin/${BASE_REF}" + "$(go env GOPATH)/bin/doc-drift-checker" check --base "origin/${BASE_REF}" --format github --warn-only diff --git a/CLAUDE.md b/CLAUDE.md index a697ee3..a4171e1 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -36,6 +36,10 @@ go test -tags e2e ./e2e go run ./cmd/portwhy 3000 ``` +## README drift check + +CI job `drift` (pull requests only, warn-only) runs doc-drift-checker, pinned to a version in `ci.yaml`, with `.docdrift.yaml`. A `mappings` key is the full heading text including the emoji (or `#` plus the anchor, e.g. `#-flags`); a key that matches no heading is ignored silently, so verify with `doc-drift-checker links`. `🔢 Exit codes` is deliberately unmapped (`internal/cli/run.go` changes with almost every feature). A present `ignore` key replaces the built-in list, so the defaults are repeated there; keep them in sync when upgrading the tool. Moving to `--min-severity high` is a separate decision after a few weeks of warnings. + ## Decisions on record - macOS socket data comes from an own `lsof`/`netstat` parser (`internal/socket`); `gopsutil` is not adopted. Spike outcome: it was not added or run (no network access), but from memory its macOS connection listing also shells out to `lsof` (unverified), so it would add a dependency without removing the external tool, and without root `lsof` sees only own processes either way, which the `netstat` merge (PID 0 for invisible owners) covers. Revisit only if the parser proves fragile. Process data (`ps`) follows in the process-reader ticket. diff --git a/README.md b/README.md index 8b0c367..0a389b7 100644 --- a/README.md +++ b/README.md @@ -204,6 +204,8 @@ go test -tags e2e ./e2e # end-to-end tests against real local listeners go run ./cmd/portwhy --version ``` +Pull requests are also checked by [doc-drift-checker](https://github.com/JtheGunner/doc-drift-checker), which warns when code linked to a README section changed but the section did not. The links live in [`.docdrift.yaml`](.docdrift.yaml); the check only warns and never fails the build. + --- ## 📝 Changelog