Skip to content

Commit 4088c82

Browse files
committed
Merge #1680: ci: migrate issue #523 to internal linting tool
1d3ba50 ci(lint): switch testing workflow to internal linting tool (Jose Celano) 7085250 fix(lint/toml): normalize taplo formatting across workspace (Jose Celano) 0e174af fix(lint/yaml): resolve workflow yamllint issues (Jose Celano) b654fa5 fix(lint/markdown): resolve markdownlint violations (Jose Celano) f9b59f0 fix(lint/cspell): configure ignores and dictionary for repo (Jose Celano) bc1f8cc fix(lint/clippy): resolve pedantic duration and style violations (Jose Celano) fa3b491 ci(lint): add linter config files (Jose Celano) f2612dc docs(issue-523): add internal linting implementation plan (Jose Celano) Pull request description: ## Summary - implement issue #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 - Closes #523 ACKs for top commit: josecelano: ACK 1d3ba50 Tree-SHA512: 14ce3772b280c3f1e47bcdebd91e46dacc2f4aa5911c41e8bf118cffeed80cc6b4fe20d6e98a63fe028afa94cb2a9828da225fcd5b715914ea2f024fa6703311
2 parents 1ef5b41 + 1d3ba50 commit 4088c82

51 files changed

Lines changed: 483 additions & 215 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.cargo/config.toml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ time = "build --timings --all-targets"
77

88
[build]
99
rustflags = [
10-
"-D",
11-
"warnings",
12-
"-D",
13-
"future-incompatible",
14-
"-D",
15-
"let-underscore",
16-
"-D",
17-
"nonstandard-style",
18-
"-D",
19-
"rust-2018-compatibility",
20-
"-D",
21-
"rust-2018-idioms",
22-
"-D",
23-
"rust-2021-compatibility",
24-
"-D",
25-
"unused",
10+
"-D",
11+
"warnings",
12+
"-D",
13+
"future-incompatible",
14+
"-D",
15+
"let-underscore",
16+
"-D",
17+
"nonstandard-style",
18+
"-D",
19+
"rust-2018-compatibility",
20+
"-D",
21+
"rust-2018-idioms",
22+
"-D",
23+
"rust-2021-compatibility",
24+
"-D",
25+
"unused",
2626
]

.github/workflows/container.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,15 @@ jobs:
8080
echo "continue=true" >> $GITHUB_OUTPUT
8181
echo "On \`develop\` Branch, Type: \`development\`"
8282
83-
elif [[ $(echo "${{ github.ref }}" | grep -P '^(refs\/heads\/releases\/)(v)(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$') ]]; then
83+
elif [[ "${{ github.ref }}" =~ ^refs/heads/releases/ ]]; then
84+
semver_regex='^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*)(\.(0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*))*))?(\+([0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*))?$'
85+
version=$(echo "${{ github.ref }}" | sed -n -E 's#^refs/heads/releases/##p')
86+
87+
if [[ ! "$version" =~ $semver_regex ]]; then
88+
echo "Not a valid release branch semver. Will Not Continue"
89+
exit 0
90+
fi
8491
85-
version=$(echo "${{ github.ref }}" | sed -n -E 's/^(refs\/heads\/releases\/)//p')
8692
echo "version=$version" >> $GITHUB_OUTPUT
8793
echo "type=release" >> $GITHUB_OUTPUT
8894
echo "continue=true" >> $GITHUB_OUTPUT

.github/workflows/coverage.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
- id: coverage
4545
name: Generate Coverage Report
4646
run: |
47-
cargo clean
47+
cargo clean
4848
cargo llvm-cov --all-features --workspace --codecov --output-path ./codecov.json
4949
5050
- id: upload
@@ -54,4 +54,4 @@ jobs:
5454
verbose: true
5555
token: ${{ secrets.CODECOV_TOKEN }}
5656
files: ${{ github.workspace }}/codecov.json
57-
fail_ci_if_error: true
57+
fail_ci_if_error: true

.github/workflows/generate_coverage_pr.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
- id: coverage
4545
name: Generate Coverage Report
4646
run: |
47-
cargo clean
47+
cargo clean
4848
cargo llvm-cov --all-features --workspace --codecov --output-path ./codecov.json
4949
5050
- name: Store PR number and commit SHA

.github/workflows/testing.yaml

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ jobs:
3333
run: cargo fmt --check
3434

3535
check:
36-
name: Static Analysis
36+
name: Linting
3737
runs-on: ubuntu-latest
3838
needs: format
39+
timeout-minutes: 15
3940

4041
strategy:
4142
matrix:
@@ -51,39 +52,25 @@ jobs:
5152
uses: dtolnay/rust-toolchain@stable
5253
with:
5354
toolchain: ${{ matrix.toolchain }}
54-
components: clippy
55+
components: clippy, rustfmt
56+
57+
- id: node
58+
name: Setup Node.js
59+
uses: actions/setup-node@v5
60+
with:
61+
node-version: "20"
5562

5663
- id: cache
5764
name: Enable Workflow Cache
5865
uses: Swatinem/rust-cache@v2
5966

6067
- id: tools
61-
name: Install Tools
62-
uses: taiki-e/install-action@v2
63-
with:
64-
tool: cargo-machete
65-
66-
- id: check
67-
name: Run Build Checks
68-
run: cargo check --tests --benches --examples --workspace --all-targets --all-features
68+
name: Install Internal Linter
69+
run: cargo install --locked --git https://github.com/torrust/torrust-linting --bin linter
6970

7071
- id: lint
71-
name: Run Lint Checks
72-
run: cargo clippy --tests --benches --examples --workspace --all-targets --all-features
73-
74-
- id: docs
75-
name: Lint Documentation
76-
env:
77-
RUSTDOCFLAGS: "-D warnings"
78-
run: cargo doc --no-deps --bins --examples --workspace --all-features
79-
80-
- id: clean
81-
name: Clean Build Directory
82-
run: cargo clean
83-
84-
- id: deps
85-
name: Check Unused Dependencies
86-
run: cargo machete
72+
name: Run All Linters
73+
run: linter all
8774

8875
build:
8976
name: Build on ${{ matrix.os }} (${{ matrix.toolchain }})

.github/workflows/upload_coverage_pr.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Upload Coverage Report (PR)
22

33
on:
4-
# This workflow is triggered after every successfull execution
4+
# This workflow is triggered after every successful execution
55
# of `Generate Coverage Report` workflow.
66
workflow_run:
77
workflows: ["Generate Coverage Report (PR)"]

.markdownlint.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"default": true,
3+
"MD013": false,
4+
"MD031": true,
5+
"MD032": true,
6+
"MD040": true,
7+
"MD022": true,
8+
"MD009": true,
9+
"MD007": {
10+
"indent": 2
11+
},
12+
"MD026": false,
13+
"MD041": false,
14+
"MD034": false,
15+
"MD024": false,
16+
"MD033": false,
17+
"MD060": false
18+
}

.taplo.toml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Taplo configuration file for TOML formatting
2+
# Used by the "Even Better TOML" VS Code extension
3+
4+
# Exclude generated and runtime folders from linting
5+
exclude = [ ".coverage/**", "storage/**", "target/**" ]
6+
7+
[formatting]
8+
# Preserve blank lines that exist
9+
allowed_blank_lines = 1
10+
# Don't reorder keys to maintain structure
11+
reorder_keys = false
12+
# Array formatting
13+
array_auto_collapse = false
14+
array_auto_expand = false
15+
array_trailing_comma = true
16+
# Inline table formatting
17+
compact_arrays = false
18+
compact_inline_tables = false
19+
inline_table_expand = false
20+
# Alignment
21+
align_comments = true
22+
align_entries = false
23+
# Indentation
24+
indent_entries = false
25+
indent_tables = false
26+
# Other
27+
trailing_newline = true

.yamllint-ci.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
extends: default
2+
3+
rules:
4+
line-length:
5+
max: 200 # More reasonable for infrastructure code
6+
comments:
7+
min-spaces-from-content: 1 # Allow single space before comments
8+
document-start: disable # Most project YAML files don't require ---
9+
truthy:
10+
allowed-values: ["true", "false", "yes", "no", "on", "off"] # Allow common GitHub Actions values
11+
12+
# Ignore generated/runtime directories
13+
ignore: |
14+
target/**
15+
storage/**
16+
.coverage/**

Cargo.toml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ version.workspace = true
1919
name = "torrust_tracker_lib"
2020

2121
[workspace.package]
22-
authors = ["Nautilus Cyberneering <info@nautilus-cyberneering.de>, Mick van Dijke <mick@dutchbits.nl>"]
23-
categories = ["network-programming", "web-programming"]
22+
authors = [ "Nautilus Cyberneering <info@nautilus-cyberneering.de>, Mick van Dijke <mick@dutchbits.nl>" ]
23+
categories = [ "network-programming", "web-programming" ]
2424
description = "A feature rich BitTorrent tracker."
2525
documentation = "https://docs.rs/crate/torrust-tracker/"
2626
edition = "2021"
2727
homepage = "https://torrust.com/"
28-
keywords = ["bittorrent", "file-sharing", "peer-to-peer", "torrent", "tracker"]
28+
keywords = [ "bittorrent", "file-sharing", "peer-to-peer", "torrent", "tracker" ]
2929
license = "AGPL-3.0-only"
3030
publish = true
3131
repository = "https://github.com/torrust/torrust-tracker"
@@ -34,19 +34,19 @@ version = "3.0.0-develop"
3434

3535
[dependencies]
3636
anyhow = "1"
37-
axum-server = { version = "0", features = ["tls-rustls-no-provider"] }
37+
axum-server = { version = "0", features = [ "tls-rustls-no-provider" ] }
3838
bittorrent-http-tracker-core = { version = "3.0.0-develop", path = "packages/http-tracker-core" }
3939
bittorrent-tracker-core = { version = "3.0.0-develop", path = "packages/tracker-core" }
4040
bittorrent-udp-tracker-core = { version = "3.0.0-develop", path = "packages/udp-tracker-core" }
41-
chrono = { version = "0", default-features = false, features = ["clock"] }
42-
clap = { version = "4", features = ["derive", "env"] }
41+
chrono = { version = "0", default-features = false, features = [ "clock" ] }
42+
clap = { version = "4", features = [ "derive", "env" ] }
4343
rand = "0"
4444
regex = "1"
45-
reqwest = { version = "0", features = ["json"] }
46-
serde = { version = "1", features = ["derive"] }
47-
serde_json = { version = "1", features = ["preserve_order"] }
45+
reqwest = { version = "0", features = [ "json" ] }
46+
serde = { version = "1", features = [ "derive" ] }
47+
serde_json = { version = "1", features = [ "preserve_order" ] }
4848
thiserror = "2.0.12"
49-
tokio = { version = "1", features = ["macros", "net", "rt-multi-thread", "signal", "sync"] }
49+
tokio = { version = "1", features = [ "macros", "net", "rt-multi-thread", "signal", "sync" ] }
5050
tokio-util = "0.7.15"
5151
torrust-axum-health-check-api-server = { version = "3.0.0-develop", path = "packages/axum-health-check-api-server" }
5252
torrust-axum-http-tracker-server = { version = "3.0.0-develop", path = "packages/axum-http-tracker-server" }
@@ -59,7 +59,7 @@ torrust-tracker-configuration = { version = "3.0.0-develop", path = "packages/co
5959
torrust-tracker-swarm-coordination-registry = { version = "3.0.0-develop", path = "packages/swarm-coordination-registry" }
6060
torrust-udp-tracker-server = { version = "3.0.0-develop", path = "packages/udp-tracker-server" }
6161
tracing = "0"
62-
tracing-subscriber = { version = "0", features = ["json"] }
62+
tracing-subscriber = { version = "0", features = [ "json" ] }
6363

6464
[dev-dependencies]
6565
bittorrent-primitives = "0.1.0"
@@ -70,7 +70,7 @@ torrust-rest-tracker-api-client = { version = "3.0.0-develop", path = "packages/
7070
torrust-tracker-test-helpers = { version = "3.0.0-develop", path = "packages/test-helpers" }
7171

7272
[workspace]
73-
members = ["console/tracker-client", "packages/torrent-repository-benchmarking"]
73+
members = [ "console/tracker-client", "packages/torrent-repository-benchmarking" ]
7474

7575
[profile.dev]
7676
debug = 1

0 commit comments

Comments
 (0)