Skip to content

ci: migrate issue #523 to internal linting tool - #1680

Merged
josecelano merged 8 commits into
torrust:developfrom
josecelano:523-internal-linting-tool
Apr 8, 2026
Merged

josecelano merged 8 commits into
torrust:developfrom
josecelano:523-internal-linting-tool

Conversation

@josecelano

@josecelano josecelano commented Apr 8, 2026 •

Copy link
Copy Markdown
Member

Summary

  • implement issue Install MegaLinter #523 using internal Torrust linting tool instead of MegaLinter
  • add/adapt linter config files for markdown, yaml, and toml
  • fix lint violations by category (clippy, cspell, markdown, yaml, toml) with separate commits
  • update .github/workflows/testing.yaml static-analysis job to run linter all

Why

Use the organization internal linting workflow for consistent lint behavior across Torrust repositories.

Validation

  • local linter all passes

Related

@josecelano
josecelano requested a review from a team as a code owner April 8, 2026 16:00
@josecelano josecelano self-assigned this Apr 8, 2026
@josecelano

Copy link
Copy Markdown
Member Author

ACK 1d3ba50

@codecov

codecov Bot commented Apr 8, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.44%. Comparing base (1ef5b41) to head (1d3ba50).
⚠️ Report is 9 commits behind head on develop.

Files with missing lines Patch % Lines
...ackages/axum-rest-tracker-api-server/src/server.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1680   +/-   ##
========================================
  Coverage    86.44%   86.44%           
========================================
  Files          288      288           
  Lines        22672    22672           
  Branches     22672    22672           
========================================
  Hits         19599    19599           
  Misses        2840     2840           
  Partials       233      233           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@josecelano

Copy link
Copy Markdown
Member Author

ACK 1d3ba50

@josecelano
josecelano merged commit 4088c82 into torrust:develop Apr 8, 2026
20 of 21 checks passed

@da2ce7 da2ce7 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.

This is a post-merge review of the change from #1680 as it stands at e170b9620 on the default branch.

What still runs: the linter all step that replaced the separate cargo check, cargo clippy, cargo doc and cargo machete steps, now inside the unit job (.github/workflows/testing.yaml:95-97), together with the Node.js setup it added (testing.yaml:62-66); the rewritten release-branch version check in .github/workflows/container.yaml:185-197, which came in with the yamllint fixes and is not mentioned in the description; and the four linter configuration files .markdownlint.json, .taplo.toml, .yamllint-ci.yml and cspell.json, since extended with more ignore entries. The unpinned linter install it added is now a pinned [email protected] install (testing.yaml:82), and the rustdoc check it removed was restored for library targets by 632760d (testing.yaml:104-107).

[Minor] No CI job checks for unused dependencies any more. #1680 removed the cargo machete step together with the steps that linter all does cover, but the linter does not run cargo-machete: the pre-commit hook runs cargo machete --with-metadata and linter all as two separate steps (contrib/dev-tools/git/hooks/pre-commit.sh:59 and :62), and no workflow at e170b9620 runs cargo-machete as a check. A pull request that adds a dependency to a Cargo.toml without using it, from a contributor who does not run the hook, passes every check, although AGENTS.md:138 requires the check before each commit and AGENTS.md:49 names CI the merge authority. The plan committed with the change asked to remove replaced jobs only after verifying coverage parity (docs/issues/closed/523-internal-linting-tool/ISSUE.md:158); for this step that parity does not hold. Smallest fix: add cargo-machete to the tool: list at testing.yaml:88 and a step running cargo machete --with-metadata on one matrix entry (for example if: ${{ matrix.run_format }}).

[Minor] The lint job runs on an end-of-life Node.js. testing.yaml:66 sets node-version: "20", which #1680 introduced for the Node-based linters that linter all runs (markdownlint and cspell). Node.js 20 reached end of life on 2026-04-30, so these linters, which read the content of every pull request, run on a runtime that no longer receives security or bug fixes, and a linter release that raises its minimum Node.js version breaks the job wherever the linter installs that release. Smallest fix: node-version: "24" here and at .github/workflows/docs-lint.yaml:48, which copied the value.

[Nit] A malformed release branch passes silently. At container.yaml:189-192, a push to releases/3.0.0 (without the v prefix that docs/release-process/tracker.md:62 prescribes) prints a message and runs exit 0, so the context job succeeds, both publish jobs are skipped, and the run is green with no image published. The code it replaced behaved the same way (it fell through to the Not Correct Branch branch), but the rewrite was the occasion to make a failed release push visible. Smallest fix: echo "::error::Not a valid release branch semver" followed by exit 1 for a refs/heads/releases/ ref that does not match.

[Nit] container.yaml:185 and :187 expand ${{ github.ref }} into the script text, so a branch name containing $(...) or a double quote, both legal in a git ref, is executed as shell in the context job. Only accounts that can push to the repository can create such a branch, and they can already change the workflow, so this grants nothing new; it is still the pattern the GitHub Actions hardening guidance advises against, in lines #1680 rewrote. Smallest fix: env: { REF: "${{ github.ref }}" } on the step and "$REF" in the script.

[Nit] The stable entry runs rustfmt without installing it. #1680 added the rustfmt component to the lint job because linter all runs rustfmt (AGENTS.md:68). At e170b9620 the stable entry lists only clippy, llvm-tools-preview (testing.yaml:45) and sets run_format: false (testing.yaml:47), yet runs linter all (testing.yaml:97), so its rustfmt check depends on the hosted runner image providing rustfmt for stable and contradicts the run_format setting. Smallest fix: add rustfmt to the stable components, or run linter all on the nightly entry only if a stable rustfmt run is not wanted.

[Nit] README.md:115-116: to satisfy markdownlint, #1680 escaped the emphasis markers instead of correcting them, so the rendered README shows the literal characters _** and ___ around the link to the latest stable (or nightly) Rust and around Recommended 16GB.. Smallest fix: **_[latest stable (or nightly) version of rust][rust]_** and **_Recommended 16GB._**.

Checked and found sound: the semver expression at container.yaml:186 accepts the same strings as the PCRE pattern it replaced ([0-9] correctly stands in for \d, which ERE lacks, and the anchored match makes POSIX longest-match and PCRE first-match semantics agree), and the stripped v-prefixed version still reaches docker/metadata-action as before; the removed cargo check is covered by the --all-targets --all-features test build at testing.yaml:111; the yamllint, taplo, markdownlint and cspell configurations are well formed for their tools, their ignore lists cover the generated and runtime directories, and the 200-column yamllint limit is in force (lines longer than the default 80 columns pass at the tip); the cspell.json and cSpell.json pair that #1680 left side by side, which collide on case-insensitive file systems, was merged into one file by 760fafc.

This branch was previously deployed

1 inactive deployment
coverage — 1d3ba500 Deployed Apr 8, 2026 by josecelano via Generate Coverage Report #1063
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.

Install MegaLinter

2 participants