Skip to content

Commit 000ce5d

Browse files
committed
Auto merge of rust-lang#16562 - Veykril:problem-matcher, r=Veykril
internal: Add a clippy and rustfmt problem matcher to CI
2 parents efe68e3 + f481181 commit 000ce5d

File tree

3 files changed

+41
-21
lines changed

3 files changed

+41
-21
lines changed

.github/rust.json

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"problemMatcher": [
3+
{
4+
"owner": "rustfmt",
5+
"severity": "warning",
6+
"pattern": [
7+
{
8+
"regexp": "^(Diff in (.+)) at line (\\d+):$",
9+
"message": 1,
10+
"file": 2,
11+
"line": 3
12+
}
13+
]
14+
},
15+
{
16+
"owner": "clippy",
17+
"pattern": [
18+
{
19+
"regexp": "^(?:\\x1b\\[[\\d;]+m)*(warning|warn|error)(?:\\x1b\\[[\\d;]+m)*(\\[(.*)\\])?(?:\\x1b\\[[\\d;]+m)*:(?:\\x1b\\[[\\d;]+m)* ([^\\x1b]*)(?:\\x1b\\[[\\d;]+m)*$",
20+
"severity": 1,
21+
"message": 4,
22+
"code": 3
23+
},
24+
{
25+
"regexp": "^(?:\\x1b\\[[\\d;]+m)*\\s*(?:\\x1b\\[[\\d;]+m)*\\s*--> (?:\\x1b\\[[\\d;]+m)*(.*):(\\d*):(\\d*)(?:\\x1b\\[[\\d;]+m)*$",
26+
"file": 1,
27+
"line": 2,
28+
"column": 3
29+
}
30+
]
31+
}
32+
]
33+
}

.github/workflows/ci.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ jobs:
6565
rustup update --no-self-update ${{ env.RUST_CHANNEL }}
6666
rustup component add --toolchain ${{ env.RUST_CHANNEL }} rustfmt rust-src
6767
rustup default ${{ env.RUST_CHANNEL }}
68+
# https://github.com/actions-rust-lang/setup-rust-toolchain/blob/main/rust.json
69+
- name: Install Rust Problem Matcher
70+
if: matrix.os == 'ubuntu-latest'
71+
run: echo "::add-matcher::.github/rust.json"
6872

6973
- name: Cache Dependencies
7074
uses: Swatinem/rust-cache@988c164c3d0e93c4dbab36aaf5bbeb77425b2894
@@ -107,6 +111,10 @@ jobs:
107111
if: matrix.os == 'windows-latest'
108112
run: cargo clippy --all-targets -- -D clippy::disallowed_macros -D clippy::dbg_macro -D clippy::todo -D clippy::print_stdout -D clippy::print_stderr
109113

114+
- name: rustfmt
115+
if: matrix.os == 'ubuntu-latest'
116+
run: cargo fmt -- --check
117+
110118
# Weird targets to catch non-portable code
111119
rust-cross:
112120
if: github.repository == 'rust-lang/rust-analyzer'

crates/rust-analyzer/tests/slow-tests/tidy.rs

-21
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,6 @@ use xshell::Shell;
99
#[cfg(not(feature = "in-rust-tree"))]
1010
use xshell::cmd;
1111

12-
#[cfg(not(feature = "in-rust-tree"))]
13-
#[test]
14-
fn check_code_formatting() {
15-
let sh = &Shell::new().unwrap();
16-
sh.change_dir(sourcegen::project_root());
17-
18-
let out = cmd!(sh, "rustup run stable rustfmt --version").read().unwrap();
19-
if !out.contains("stable") {
20-
panic!(
21-
"Failed to run rustfmt from toolchain 'stable'. \
22-
Please run `rustup component add rustfmt --toolchain stable` to install it.",
23-
)
24-
}
25-
26-
let res = cmd!(sh, "rustup run stable cargo fmt -- --check").run();
27-
if res.is_err() {
28-
let _ = cmd!(sh, "rustup run stable cargo fmt").run();
29-
}
30-
res.unwrap()
31-
}
32-
3312
#[test]
3413
fn check_lsp_extensions_docs() {
3514
let sh = &Shell::new().unwrap();

0 commit comments

Comments
 (0)