Skip to content

ci(lint-python): split linting into code, docs, and linkcheck jobs - #199

Merged
lengau merged 9 commits into
mainfrom
work/separate-linkcheck
Oct 23, 2026
Merged

lengau merged 9 commits into
mainfrom
work/separate-linkcheck

Conversation

@lengau

@lengau lengau commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Splits the lint workflow into jobs so that a red run identifies which lint stage broke, and so link checking no longer blocks or delays the rest of the documentation linting.

Job Target Runs when
filter none always; classifies the changed files
files make -k lint-code source files changed
docs make -k docs-lint documentation changed
linkcheck make -k docs-linkcheck documentation changed

Draft: the workflow shape is settled, but nothing has run against a real runner yet.

Related starbase change

The starbase side of this split is canonical/starbase#625, which adds an
explicit docs-linkcheck target. Its docs-% passthrough routes
docs-linkcheck the same way, so this workflow works either way, but #625
makes the target explicit and keeps make lint running link checking.

Merge order matters. Both orders are being tested:

Changes

Makefile

  • Renamed the lint target to lint-code.
  • Removed linkcheck from docs-lint. No new target was added: the existing docs-% passthrough already routes docs-linkcheck to make -C docs linkcheck.

lint-python.yaml

  • Added a filter job that runs dorny/paths-filter once and exports source-files and docs-files as job outputs. The three linting jobs take needs: filter and gate at job level.
  • Added a docs-files filter covering docs/**, **/*.md, **/*.rst, and .readthedocs.yaml.
  • The docs and linkcheck jobs keep only the setup-uv step, since neither the documentation linters nor Sphinx's linkchecker need the snap-installed linters.
  • pull-requests: read now exists only on filter, which is the only job that calls the pull request API.

README

  • Documents the three jobs, the renamed lint-code target, the previously undocumented docs-lint and docs-linkcheck targets, and the source-files input.

Review responses

All four Copilot findings and the zizmor alert were addressed:

  • Truncated setup-uv SHA (2c77769).
  • Documentation filters omitting .readthedocs.yaml (46f37bc).
  • Step-level instead of job-level gating (46f37bc).
  • Renaming lint against the documented contract (46f37bc). This one is a deliberate breaking change for consumers, discussed below.

Behaviour changes worth reviewing

The source-files input only exists for workflow_call. On push and pull_request events it is empty, so the old condition inputs.source-files == 'true' never matched and self-linting runs of this repository only ever executed the documentation linters. The files job now uses inputs.source-files != 'false', so an unset input counts as "not docs-only" and the code linters run on pushes and pull requests to main. Callers that pass source-files: 'false' still skip them.

Mixed changes now run both code and documentation linting. A pull request touching source files and documentation runs all three linting jobs, where the previous exclusive either/or would have run only the code linters. Gating both documentation jobs on a single shared filter also means a pull request that changes only source files no longer starts a runner for docs and linkcheck, which previously checked out the repository and installed uv before the final step's condition was evaluated.

Consumers must rename lint to lint-code. Any repository calling this workflow needs the renamed target. An alias in this repository's Makefile would not help, since callers supply their own. If a non-breaking change is preferred, the alternative is to keep invoking lint and drop the rename.

Testing

  • make -n lint-code, make -n docs-lint, and make -n docs-linkcheck all resolve to the expected recipes.
  • prettier --check passes over the repository glob.
  • Every uses: reference in the workflow is pinned to a 40-character commit SHA.
  • Workflow YAML parses, and the job graph and conditions were inspected directly.

Not yet verified against a real runner.

Run the three lint stages as separate jobs so that a failure points at
the stage that broke, and so link checking is no longer bundled with the
documentation linters.

- Rename the Makefile `lint` target to `lint-code`.
- Drop `linkcheck` from `docs-lint`. It runs in its own job through the
  existing `docs-%` passthrough, so no new target is needed.
- Gate the new `docs` and `linkcheck` jobs on a `docs-files` path filter
  covering the docs directory, Markdown files, and reStructuredText
  files.
- Treat an unset `source-files` input as "not docs-only". Outside of
  `workflow_call` the input is empty, so the previous
  `== 'true'` comparison meant that pushes and pull requests to main
  only ever ran the documentation linters.
Copilot AI lite review requested due to automatic review settings October 14, 2026 23:27
Comment thread .github/workflows/lint-python.yaml Fixed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Critical workflow and compatibility issues remain unresolved.

4 open findings
What changed in this PR

Splits Python linting into independent code, documentation, and link-check workflow jobs.

Changes:

  • Renames lint to lint-code and separates documentation link checking.
  • Adds path-filtered docs and linkcheck jobs.
  • Updates source-file gating for push, pull request, and reusable workflow runs.
File Review findings
Makefile Critical (4 votes): Renaming lint breaks the documented reusable-workflow contract; retain a compatibility alias or update/version the contract.
.github/​workflows/​lint-python.yaml Critical (2 votes): The linkcheck setup reference uses a truncated SHA. Moderate: Job gating remains step-level, .readthedocs.yaml is omitted from documentation filters, and RST changes are not excluded from the source filter.

🧠 Review effort: Lite


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread .github/workflows/lint-python.yaml Outdated
Comment thread Makefile
Comment thread .github/workflows/lint-python.yaml Outdated
Comment thread .github/workflows/lint-python.yaml
Move the paths filter into its own job that exposes `source-files` and
`docs-files` as job outputs, so the `files`, `docs`, and `linkcheck`
jobs can be gated at job level. Previously the conditions sat on the
final step, which meant a source-only change still started a runner for
both documentation jobs, checked out the repository, and installed `uv`
before the filter decided there was nothing to do.

- Add `.readthedocs.yaml` to the documentation filter. It was already
  excluded from the source filter, so a change touching only that file
  previously ran no linters at all.
- Drop `pull-requests: read` from the three linting jobs. Only the
  filter job reads the pull request API.

Document the renamed target and the documentation targets in the
README, and describe the `source-files` input.
The previous commit rewrote the whole workflow file and reverted the
rename from "Lint Python" to "Lint" in f360004.
The filter job only checks out the repository and classifies changed
files, so it does not need the full runner image. The three linting
jobs are unchanged and still use ubuntu-latest.
lengau added a commit to canonical/craft-cli that referenced this pull request Oct 15, 2026
The starflow lint workflow is being split so that the code linters run
as their own job, and it calls the code linters as `make -k lint-code`
(see canonical/starflow#199).

Split the aggregate `lint` target so the code linters can be addressed as
`lint-code`, matching the repositories that already provide it. `lint`
still runs everything for local use.
lengau added a commit to canonical/debcraft that referenced this pull request Oct 15, 2026
The starflow lint workflow is being split so that the code linters run
as their own job, and it calls the code linters as `make -k lint-code`
(see canonical/starflow#199).

Split the aggregate `lint` target so the code linters can be addressed as
`lint-code`, matching the repositories that already provide it. `lint`
still runs everything for local use.
@lengau
lengau marked this pull request as ready for review October 22, 2026 16:35
@lengau
lengau requested a review from a team October 22, 2026 18:25

@mr-cal mr-cal left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of the example PRs made a doc change, so the linkchecker and doc workflows haven't been proven. Are you able to adjust it so we can see those run?

@lengau

lengau commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

@mr-cal I believe canonical/starbase#632 is what you're looking for.

@lengau
lengau requested review from a team and mr-cal October 23, 2026 16:29
@lengau

lengau commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

@mr-cal and here's one that skips the code linting but runs the docs/linkcheck: LoweRAM/charmcraft#1

@mr-cal

mr-cal commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Thanks for the runs, interesting failure on the linkchecker: https://github.com/LoweRAM/charmcraft/actions/runs/39987431539/job/120530361084?pr=1#step:4:339

@lengau

lengau commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

Odd that it did that in that charmcraft one but not in craft-application. Looking...

@lengau

lengau commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

@mr-cal ok I've added make setup-docs as a step for both the docs linters and for linkcheck: https://github.com/LoweRAM/charmcraft/actions/runs/40000066581/job/120573734845

@lengau
lengau merged commit c1dfe41 into main Oct 23, 2026
13 checks passed
@lengau
lengau deleted the work/separate-linkcheck branch October 23, 2026 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants