mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
5840ac5f6e
## Problem `Docs CI` fails on PRs that only touch binary assets under `docs/`. Example: [#25314](https://github.com/coder/coder/pull/25314), which swaps a single PNG and produces thousands of `MD010/no-hard-tabs`, `MD049/emphasis-style`, and `MD018/no-missing-space-atx` errors at columns like 16,285 of the image. ## Root cause The single `tj-actions/changed-files` step was doing two jobs at once: detecting which Markdown files changed (for `lint` and `fmt`), and gating whether the workflow had anything to do at all. Its `files` filter matched `docs/**` in addition to `**.md`, so any non-Markdown file under `docs/` (PNG, GIF, JPG, MP4, SVG) ended up in `all_changed_files` and was passed straight to `markdownlint-cli2`, which opened the file and parsed the binary bytes as Markdown. `markdownlint-cli2`'s own `ignores` setting is a discovery-time filter and does not gate files passed explicitly on the command line, so the filtering has to happen in the caller. ## Fix Adopt a per-tool convention: each downstream tool gets its own `changed-files` step scoped to the files that tool can process. For now that is a single `changed-md` step matching `**.md`, consumed by `lint` and `fmt`. A future tool (e.g. an image linter, video size check, or link checker) can be added purely additively, by appending another `changed-*` step and a step that consumes its output, without changing the existing filters. The workflow-level `on.push.paths` / `on.pull_request.paths` triggers stay broad (`docs/**`, `**.md`) so the workflow still runs on screenshot-only PRs; the per-tool filters decide which individual steps execute. On a screenshot-only PR the existing `if: steps.changed-md.outputs.any_changed == 'true'` guard skips `lint` and `fmt` cleanly. ## Verification - `actionlint .github/workflows/docs-ci.yaml` passes. - Reproduced the original failure locally: `pnpm exec markdownlint-cli2 docs/images/install/install_from_deployment.png` produces the same flood of violations seen in the failing CI run on #25314. - First revision of this PR (workflow with `**.md`-only filter, single `changed-files` step) was green on `Docs CI`; the current revision is structurally equivalent for the existing tools and just renames the step id and adds the per-tool comment. <details> <summary>Decision log</summary> - Considered adding `ignores` to `.markdownlint-cli2.jsonc` to skip non-Markdown files. Rejected: `markdownlint-cli2` treats `ignores` as a discovery-time glob filter and still lints files passed explicitly on the command line, so it would not have fixed the failure. - Considered narrowing the existing single `changed-files` step's `files` filter to `**.md` only. Rejected as the final shape: it solves the immediate bug but conflates "which Markdown files changed" with "should the workflow run at all", so adding a second tool with a different file set later (e.g. an image linter) would require contorting or duplicating that step. - Chose the per-tool-filter shape so adding a future tool is additive: one new `changed-*` step plus one new step that consumes its output, with no edits to existing steps. </details> ## Disclosure Opened on behalf of @nickvigilante by Coder Agents.