Skip to content

fix(registry): add --tests to cargo-clippy, add test coverage#176

Merged
zeitlinger merged 6 commits intomainfrom
fix/clippy-tests
Apr 17, 2026
Merged

fix(registry): add --tests to cargo-clippy, add test coverage#176
zeitlinger merged 6 commits intomainfrom
fix/clippy-tests

Conversation

@zeitlinger
Copy link
Copy Markdown
Member

Summary

  • Add --tests to cargo-clippy registry entry — test code was previously unlinted
  • Apply resulting clippy fixes (unused var, if-let chains, type_complexity allow)
  • Add failure-in-tests e2e case to verify test code linting works
  • Fix existing failure fixture: (lib)(lib test) in error message (changed by --tests)

Motivated by a bug caught immediately: missing arg in test call sites went undetected until CI.

Test plan

  • CI passes (Linux, macOS, Windows)

@zeitlinger zeitlinger marked this pull request as ready for review April 16, 2026 13:40
@zeitlinger zeitlinger requested a review from a team as a code owner April 16, 2026 13:40
Copilot AI review requested due to automatic review settings April 16, 2026 13:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the Rust cargo-clippy registry check to lint test code as well, and adds an e2e fixture to ensure clippy failures originating from test modules are caught by CI.

Changes:

  • Update the cargo-clippy registry entry to include test linting and adjust the fix command accordingly.
  • Apply clippy-driven refactors in test/helpers and internal code (if let chains, type_complexity allow, minor collection cleanup).
  • Add a new failure-in-tests e2e case and update existing cargo-clippy failure snapshot output.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/registry.rs Adds --tests to the cargo-clippy check/fix commands; minor test helper adjustment (headers.to_vec()).
tests/e2e.rs Refactors snapshot writer to use if let chains when serializing optional TOML tables.
tests/cases/cargo-clippy/failure/test.toml Updates expected clippy failure output to match new target diagnostics.
tests/cases/cargo-clippy/failure-in-tests/test.toml Adds new snapshot asserting clippy fails on test-only code.
tests/cases/cargo-clippy/failure-in-tests/files/src/lib.rs Introduces a unit test that triggers an unused_variables failure under clippy.
tests/cases/cargo-clippy/failure-in-tests/files/Cargo.toml New fixture crate manifest for the e2e case.
tests/cases/cargo-clippy/failure-in-tests/files/mise.toml Uses rust = "latest" for the fixture environment.
src/linters/renovate_deps.rs Adds a local #[allow(clippy::type_complexity)] in tests.
src/init/mod.rs Refactors component insertion logic using an if let chain.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/registry.rs
--tests runs clippy in test configuration, which excludes #[cfg(not(test))]
code paths. --all-targets checks lib, bins, tests, and examples, giving
broader coverage without dropping any build targets.

Update failure fixture: --all-targets emits two "could not compile" lines
(lib then lib test) vs one with --tests.
Signed-off-by: Gregor Zeitlinger <[email protected]>
@zeitlinger
Copy link
Copy Markdown
Member Author

@martincostello can you check?

@martincostello
Copy link
Copy Markdown
Member

Will look tomorrow - been busy with upstream work most of this week.

@zeitlinger zeitlinger merged commit 52a27fd into main Apr 17, 2026
13 checks passed
@zeitlinger zeitlinger deleted the fix/clippy-tests branch April 17, 2026 10:28
@github-actions github-actions Bot mentioned this pull request Apr 17, 2026
zeitlinger added a commit that referenced this pull request Apr 20, 2026
Ports #176 (cargo-clippy --all-targets) onto the split registry module:
- `src/registry/checks.rs` — add `--all-targets` to `check_cargo_clippy`
- `src/registry/tests.rs` — `headers.iter().copied().collect()` → `headers.to_vec()`

Also keeps the newer mise `v2026.4.16` bump already on this branch and
adopts the let-chain style for `components()` in `src/init/mod.rs`.
Signed-off-by: Gregor Zeitlinger <[email protected]>
zeitlinger added a commit that referenced this pull request Apr 21, 2026
## Summary

Experiment: add a Win-only step before `Setup mise` that excludes
`$env:LOCALAPPDATA\mise` from Defender real-time scanning.

## Why

PR #176 CI timings:

| OS      | Setup mise | Test  | Total |
|---------|-----------:|------:|------:|
| Linux   |        10s |   39s | 1m06s |
| macOS   |        37s |   57s | 2m02s |
| Windows |        86s |   71s | 3m22s |

Win mise-action log
([job](https://github.com/grafana/flint/actions/runs/24515242200/job/71657207651)):
```
14:15:03  Cache hit (568 MB tzst)
14:15:07  tar -xf … cache.tzst
14:16:27  Cache restored successfully   ← 80s
14:16:27  mise install → "all tools are installed" (0s)
```

All 80s is tar extract of many-small-files (node_modules, pipx, dotnet
SDK). Defender real-time scanning on each `CreateFile` is the usual
suspect on Win hosted runners.

Keeping compression (GH cache limit 10 GB) — not switching archiver.
Exclusion is cheapest lever to try.

## Test plan

- [ ] CI runs on this PR (Win, Mac, Linux)
- [ ] Compare new Win `Setup mise` timing against 86s baseline
- [ ] If impact significant (>20s savings), consider filing upstream at
jdx/mise-action; otherwise revert

---------

Signed-off-by: Gregor Zeitlinger <[email protected]>
Co-authored-by: Copilot <[email protected]>
@github-actions github-actions Bot mentioned this pull request Apr 21, 2026
zeitlinger pushed a commit that referenced this pull request Apr 21, 2026
### Added

- *(registry)* switch shfmt to aqua backend
([#175](#175))

### Fixed

- treat cargo-clippy as a partial fixer
([#197](#197))
- *(registry)* add --tests to cargo-clippy, add test coverage
([#176](#176))

### Other

- *(deps)* update taiki-e/install-action digest to 055f5df
([#180](#180))
- *(deps)* update dependency npm:@biomejs/biome to v2.4.12
([#191](#191))
- *(deps)* update rust crate clap to v4.6.1
([#196](#196))
- *(deps)* update rust crate tokio to v1.52.1
([#192](#192))
- *(deps)* update dependency pipx:ruff to v0.15.11
([#198](#198))
- *(deps)* update node.js to v24.15.0
([#194](#194))
- *(deps)* update dependency npm:prettier to v3.8.3
([#193](#193))
- exclude mise install dir from Windows Defender
([#188](#188))
- *(deps)* update dependency npm:renovate to v43.129.0
([#200](#200))
- restructure README/docs and split registry module
([#187](#187))
- *(deps)* update dependency mise to v2026.4.15
([#199](#199))

> [!IMPORTANT]
> Close and reopen this PR to trigger CI checks.

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

3 participants