Skip to content

Commit

Permalink
Auto merge of #16562 - Veykril:problem-matcher, r=Veykril
Browse files Browse the repository at this point in the history
internal: Add a clippy and rustfmt problem matcher to CI
  • Loading branch information
bors committed Feb 14, 2024
2 parents efe68e3 + f481181 commit 000ce5d
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 21 deletions.
33 changes: 33 additions & 0 deletions .github/rust.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"problemMatcher": [
{
"owner": "rustfmt",
"severity": "warning",
"pattern": [
{
"regexp": "^(Diff in (.+)) at line (\\d+):$",
"message": 1,
"file": 2,
"line": 3
}
]
},
{
"owner": "clippy",
"pattern": [
{
"regexp": "^(?:\\x1b\\[[\\d;]+m)*(warning|warn|error)(?:\\x1b\\[[\\d;]+m)*(\\[(.*)\\])?(?:\\x1b\\[[\\d;]+m)*:(?:\\x1b\\[[\\d;]+m)* ([^\\x1b]*)(?:\\x1b\\[[\\d;]+m)*$",
"severity": 1,
"message": 4,
"code": 3
},
{
"regexp": "^(?:\\x1b\\[[\\d;]+m)*\\s*(?:\\x1b\\[[\\d;]+m)*\\s*--> (?:\\x1b\\[[\\d;]+m)*(.*):(\\d*):(\\d*)(?:\\x1b\\[[\\d;]+m)*$",
"file": 1,
"line": 2,
"column": 3
}
]
}
]
}
8 changes: 8 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ jobs:
rustup update --no-self-update ${{ env.RUST_CHANNEL }}
rustup component add --toolchain ${{ env.RUST_CHANNEL }} rustfmt rust-src
rustup default ${{ env.RUST_CHANNEL }}
# https://github.com/actions-rust-lang/setup-rust-toolchain/blob/main/rust.json
- name: Install Rust Problem Matcher
if: matrix.os == 'ubuntu-latest'
run: echo "::add-matcher::.github/rust.json"

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

- name: rustfmt
if: matrix.os == 'ubuntu-latest'
run: cargo fmt -- --check

# Weird targets to catch non-portable code
rust-cross:
if: github.repository == 'rust-lang/rust-analyzer'
Expand Down
21 changes: 0 additions & 21 deletions crates/rust-analyzer/tests/slow-tests/tidy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,6 @@ use xshell::Shell;
#[cfg(not(feature = "in-rust-tree"))]
use xshell::cmd;

#[cfg(not(feature = "in-rust-tree"))]
#[test]
fn check_code_formatting() {
let sh = &Shell::new().unwrap();
sh.change_dir(sourcegen::project_root());

let out = cmd!(sh, "rustup run stable rustfmt --version").read().unwrap();
if !out.contains("stable") {
panic!(
"Failed to run rustfmt from toolchain 'stable'. \
Please run `rustup component add rustfmt --toolchain stable` to install it.",
)
}

let res = cmd!(sh, "rustup run stable cargo fmt -- --check").run();
if res.is_err() {
let _ = cmd!(sh, "rustup run stable cargo fmt").run();
}
res.unwrap()
}

#[test]
fn check_lsp_extensions_docs() {
let sh = &Shell::new().unwrap();
Expand Down

0 comments on commit 000ce5d

Please sign in to comment.