From 9b81b865d33730deeb0ae53c1c01654eff2394c3 Mon Sep 17 00:00:00 2001 From: Keisuke Umeno <9renpoto@gmail.com> Date: Sun, 31 Dec 2023 13:40:49 +0900 Subject: [PATCH] chore: collect coverage --- .github/workflows/rust.yml | 24 +++++++++++++----------- .pre-commit-config.yaml | 28 ++++++++++++++++++++++++++++ Cargo.lock | 9 --------- Cargo.toml | 6 +----- 4 files changed, 42 insertions(+), 25 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index f6d1738..f9b4acb 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -2,9 +2,7 @@ name: Rust on: push: - branches: [main] pull_request: - branches: [main] env: CARGO_TERM_COLOR: always @@ -31,16 +29,20 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@v1 - with: - toolchain: stable - components: rustfmt, clippy - - name: rustup toolchain install - uses: dtolnay/rust-toolchain@v1 - with: - toolchain: stable - - uses: Swatinem/rust-cache@v2 + - name: Install Rust + run: rustup update stable + - name: Install cargo-llvm-cov + uses: taiki-e/install-action@cargo-llvm-cov + - name: Generate code coverage + run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info - name: Check run: cargo clippy --workspace --all-targets --all-features -- -D warnings - name: rustfmt run: cargo fmt --all --check + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos + files: lcov.info + fail_ci_if_error: true + diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..89c08bb --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,28 @@ +repos: +- repo: https://github.com/DevinR528/cargo-sort + rev: v1.0.7 + hooks: + - id: cargo-sort +- repo: local + hooks: + - id: fmt + name: fmt + language: system + types: [file, rust] + entry: cargo fmt -- --check + pass_filenames: false + + - id: clippy + name: clippy + language: system + types: [file, rust] + entry: cargo clippy --bins --tests --examples --all -- -D rust_2018_idioms -D warnings # Use -D warnings option to ensure the job fails when encountering warnings + pass_filenames: false + + - id: test + name: test + language: system + types: [file, rust] + entry: cargo test --lib + pass_filenames: false + diff --git a/Cargo.lock b/Cargo.lock index 41b2ccd..0cdb822 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,12 +5,3 @@ version = 3 [[package]] name = "app" version = "0.1.0" -dependencies = [ - "cargo-husky", -] - -[[package]] -name = "cargo-husky" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b02b629252fe8ef6460461409564e2c21d0c8e77e0944f3d189ff06c4e932ad" diff --git a/Cargo.toml b/Cargo.toml index 8dbcb0a..19b1f75 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,8 @@ [package] name = "app" version = "0.1.0" -authors = ["Keisuke Kan <9renpoto+g59@gmail.com>"] +authors = ["Keisuke Umeno <9renpoto+g59@gmail.com>"] edition = "2021" [dependencies] -[dev-dependencies.cargo-husky] -version = "1" -default-features = false -features = ["run-cargo-fmt"]