From fb972e2fa5ac9d89e358daebfeee936ea1d0a447 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jeffry=20W=C3=BCrmli?= Date: Mon, 16 Nov 2026 00:00:18 +0100 Subject: [PATCH 1/3] ci: adopt doc-drift-checker for README drift on pull requests Adds a warn-only drift job pinned to doc-drift-checker v0.2.2 and a .docdrift.yaml that maps the Flags and Stopping safely sections. Exit codes stays unmapped on purpose: internal/cli/run.go changes with almost every feature. --- .docdrift.yaml | 49 +++++++++++++++++++++++++++++++++++++++ .github/workflows/ci.yaml | 20 ++++++++++++++++ CLAUDE.md | 4 ++++ README.md | 2 ++ 4 files changed, 75 insertions(+) create mode 100644 .docdrift.yaml diff --git a/.docdrift.yaml b/.docdrift.yaml new file mode 100644 index 0000000..db2be63 --- /dev/null +++ b/.docdrift.yaml @@ -0,0 +1,49 @@ +# 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 the anchor (`-flags`). +# "🔢 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..906d183 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -40,3 +40,23 @@ 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: + 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..20b3f66 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 the anchor); 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 From 4c9781c3ec5fdbf0bc9d403cb92d543f83ec50c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jeffry=20W=C3=BCrmli?= Date: Mon, 16 Nov 2026 00:01:18 +0100 Subject: [PATCH 2/3] ci: explain why the drift job uses the stable Go toolchain --- .github/workflows/ci.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 906d183..3cda3c1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -51,6 +51,7 @@ jobs: 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 From 5f6ee12ac90ad1cdcc7f7ad32ee3a8911a2e7370 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jeffry=20W=C3=BCrmli?= Date: Mon, 16 Nov 2026 00:03:52 +0100 Subject: [PATCH 3/3] docs: state the anchor key form for mappings --- .docdrift.yaml | 3 ++- CLAUDE.md | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.docdrift.yaml b/.docdrift.yaml index db2be63..b1f1e4a 100644 --- a/.docdrift.yaml +++ b/.docdrift.yaml @@ -38,7 +38,8 @@ ignore: - "LICENSE" - ".github/**" -# A key is the full heading text including the emoji, or the anchor (`-flags`). +# 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. diff --git a/CLAUDE.md b/CLAUDE.md index 20b3f66..a4171e1 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -38,7 +38,7 @@ 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 the anchor); 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. +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