Skip to content

Commit 07c4ae9

Browse files
authored
clippy + update ci (#137)
1 parent e83842e commit 07c4ae9

File tree

9 files changed

+31
-400
lines changed

9 files changed

+31
-400
lines changed

.github/workflows/ci.yaml

Lines changed: 17 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -12,55 +12,23 @@ on:
1212
- 'docs/**'
1313
- '**.md'
1414

15+
env:
16+
RUST_TOOLCHAIN: stable
17+
1518
jobs:
1619
check:
1720
name: Check
1821
runs-on: ubuntu-latest
1922
steps:
2023
- name: Checkout sources
2124
uses: actions/checkout@v2
22-
23-
- name: Run cargo check
24-
uses: actions-rs/cargo@v1
25+
26+
- uses: dtolnay/rust-toolchain@stable
2527
with:
26-
command: check
27-
28-
# coverage:
29-
# name: Coverage
30-
# strategy:
31-
# matrix:
32-
# os: [ubuntu-latest]
33-
# rust: [stable]
34-
# runs-on: ${{ matrix.os }}
35-
# steps:
36-
# - name: Checkout sources
37-
# uses: actions/checkout@v2
38-
39-
# - name: Install stable toolchain
40-
# uses: actions-rs/toolchain@v1
41-
# with:
42-
# toolchain: ${{ matrix.rust }}
43-
# override: true
44-
# components: llvm-tools-preview
28+
toolchain: ${{ env.RUST_TOOLCHAIN }}
4529

46-
# - uses: Swatinem/rust-cache@v1
47-
48-
# - name: Download grcov
49-
# run: |
50-
# mkdir -p "${HOME}/.local/bin"
51-
# curl -sL https://github.com/mozilla/grcov/releases/download/v0.8.10/grcov-x86_64-unknown-linux-gnu.tar.bz2 | tar jxf - -C "${HOME}/.local/bin"
52-
# echo "$HOME/.local/bin" >> $GITHUB_PATH
53-
# - name: Run xtask coverage
54-
# uses: actions-rs/cargo@v1
55-
# with:
56-
# command: xtask
57-
# args: coverage
58-
59-
60-
# - name: Upload to codecov.io
61-
# uses: codecov/codecov-action@v3
62-
# with:
63-
# files: coverage/*.lcov
30+
- name: Run cargo check
31+
run: cargo check
6432

6533
test:
6634
name: Test Suite
@@ -74,20 +42,14 @@ jobs:
7442
- name: Checkout sources
7543
uses: actions/checkout@v2
7644

77-
- name: Install stable toolchain
78-
uses: actions-rs/toolchain@v1
45+
- uses: dtolnay/rust-toolchain@stable
7946
with:
80-
profile: minimal
81-
toolchain: stable
82-
override: true
47+
toolchain: ${{ env.RUST_TOOLCHAIN }}
8348

8449
- uses: Swatinem/rust-cache@v1
8550

8651
- name: Run test
87-
uses: actions-rs/cargo@v1
88-
with:
89-
command: xtask
90-
args: test
52+
run: cargo test
9153

9254
clippy:
9355
name: clippy
@@ -96,40 +58,12 @@ jobs:
9658
- name: Checkout sources
9759
uses: actions/checkout@v2
9860

99-
- name: Install stable toolchain
100-
uses: actions-rs/toolchain@v1
61+
- uses: dtolnay/rust-toolchain@stable
10162
with:
102-
profile: minimal
103-
toolchain: stable
104-
override: true
105-
components: clippy
63+
toolchain: ${{ env.RUST_TOOLCHAIN }}
10664

10765
- name: Run clippy
108-
uses: actions-rs/cargo@v1
109-
with:
110-
command: xtask
111-
args: clippy
112-
113-
fmt:
114-
name: fmt
115-
runs-on: ubuntu-latest
116-
steps:
117-
- name: Checkout sources
118-
uses: actions/checkout@v2
119-
120-
- name: Install stable toolchain
121-
uses: actions-rs/toolchain@v1
122-
with:
123-
profile: minimal
124-
toolchain: stable
125-
override: true
126-
components: rustfmt
127-
128-
- name: Run fmt
129-
uses: actions-rs/cargo@v1
130-
with:
131-
command: xtask
132-
args: fmt
66+
run: cargo clippy --all-features -- -D warnings -W clippy::pedantic -W clippy::nursery -W rust-2018-idioms
13367

13468
docs:
13569
name: Docs
@@ -138,12 +72,10 @@ jobs:
13872
- name: Checkout repository
13973
uses: actions/checkout@v2
14074

141-
- name: Install Rust
142-
uses: actions-rs/toolchain@v1
75+
- uses: dtolnay/rust-toolchain@stable
14376
with:
144-
toolchain: stable
145-
profile: minimal
146-
override: true
77+
toolchain: ${{ env.RUST_TOOLCHAIN }}
78+
14779
- uses: Swatinem/rust-cache@v1
14880

14981
- name: Check documentation

.github/workflows/release.yml

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
- 'v[0-9]+.[0-9]+.[0-9]+'
66

77
env:
8+
RUST_TOOLCHAIN: stable
89
BIN_NAME: shellfirm
910
PROJECT_NAME: shellfirm
1011
REPO_NAME: kaplanelad/shellfirm
@@ -53,27 +54,16 @@ jobs:
5354
submodules: true
5455

5556
- name: Install ${{ matrix.rust }} toolchain
56-
uses: actions-rs/toolchain@v1
57+
uses: dtolnay/rust-toolchain@stable
5758
with:
58-
profile: minimal
59-
toolchain: ${{ matrix.rust }}
60-
target: ${{ matrix.target }}
61-
override: true
59+
toolchain: ${{ env.RUST_TOOLCHAIN }}
6260

6361
- name: Run cargo test
6462
if: matrix.build != 'aarch64-macos'
65-
uses: actions-rs/cargo@v1
66-
with:
67-
use-cross: ${{ matrix.cross }}
68-
command: test
69-
args: --release --locked --target ${{ matrix.target }}
70-
63+
run: cargo test --release --locked --target ${{ matrix.target }}
64+
7165
- name: Build release binary
72-
uses: actions-rs/cargo@v1
73-
with:
74-
use-cross: ${{ matrix.cross }}
75-
command: build
76-
args: --release --locked --target ${{ matrix.target }}
66+
run: cargo build --release --locked --target ${{ matrix.target }}
7767

7868
- name: Strip release binary (linux and macos)
7969
if: matrix.build == 'x86_64-linux' || matrix.build == 'x86_64-macos' || matrix.build == 'aarch64-macos'

Cargo.lock

Lines changed: 1 addition & 74 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[workspace]
2-
members = ["shellfirm", "xtask"]
2+
members = ["shellfirm"]

shellfirm/build.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ fn main() -> Result<()> {
1111
let dest_groups = Path::new(&out_dir).join("all_the_files.rs");
1212
let mut groups_names = File::create(dest_groups)?;
1313

14-
writeln!(&mut groups_names, r##"["##,)?;
14+
writeln!(&mut groups_names, r"[",)?;
1515

1616
let paths = fs::read_dir("./checks")?;
1717
let mut all_group_checks = String::new();
@@ -26,10 +26,10 @@ fn main() -> Result<()> {
2626
.unwrap()
2727
.to_str()
2828
.expect("could not get file name");
29-
writeln!(&mut groups_names, r##""{file_name}","##)?;
29+
writeln!(&mut groups_names, r#""{file_name}","#)?;
3030
}
3131

32-
writeln!(&mut groups_names, r##"]"##,)?;
32+
writeln!(&mut groups_names, r"]",)?;
3333

3434
let mut file = File::create(dest_checks_path)?;
3535
file.write_all(all_group_checks.as_bytes())?;

shellfirm/src/checks.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@ fn filter_is_file_or_directory_exists(file_path: &str) -> bool {
187187
};
188188

189189
log::debug!("check is {} path is exists", full_path);
190-
return std::path::Path::new(full_path.trim()).exists()
191-
|| std::path::Path::new(full_path.trim()).is_dir();
190+
std::path::Path::new(full_path.trim()).exists()
191+
|| std::path::Path::new(full_path.trim()).is_dir()
192192
}
193193

194194
fn filter_is_command_contains_string(command: &str, filter_params: &str) -> bool {

shellfirm/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ impl Settings {
317317
}
318318

319319
#[must_use]
320-
pub fn get_active_groups(&self) -> &Vec<String> {
320+
pub const fn get_active_groups(&self) -> &Vec<String> {
321321
&self.includes
322322
}
323323
}

xtask/Cargo.toml

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)