From fa9a4524f3103888e13b578aea2a0f8e90ce3d98 Mon Sep 17 00:00:00 2001 From: Leonid Meleshin Date: Fri, 19 Apr 2024 20:15:49 +0400 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Run=20cargo-mutants=20(#5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 110 +++++++++++++++++++++++++++++---------- .gitignore | 5 +- 2 files changed, 87 insertions(+), 28 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bbe8097..f9c8661 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,12 +29,60 @@ jobs: with: command: check + fmt: + name: Rustfmt + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - uses: Swatinem/rust-cache@v2 + - run: rustup component add rustfmt + - uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check + + clippy: + name: Clippy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - uses: Swatinem/rust-cache@v2 + - run: rustup component add clippy + - uses: actions-rs/cargo@v1 + with: + command: clippy + args: -- -D warnings + + test: + name: Test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - uses: Swatinem/rust-cache@v2 + - uses: actions-rs/cargo@v1 + with: + command: test + args: --all-features + coverage: name: Test Coverage runs-on: ubuntu-latest - container: - image: xd009642/tarpaulin - options: --security-opt seccomp=unconfined + needs: [ test ] strategy: matrix: flags: @@ -47,7 +95,10 @@ jobs: toolchain: nightly override: true - uses: Swatinem/rust-cache@v2 - # - run: cargo install tarpaulin + - uses: taiki-e/install-action@v2 + name: Install cargo-tarpaulin using install-action + with: + tool: cargo-tarpaulin - uses: actions-rs/cargo@v1 with: command: tarpaulin @@ -66,36 +117,41 @@ jobs: flags: ${{ matrix.flags }} fail_ci_if_error: true - fmt: - name: Rustfmt + cargo-mutants: runs-on: ubuntu-latest + if: github.event_name == 'pull_request' + # Often you'll want to only run this after the build is known to pass its basic tests, + # to avoid wasting time, and to allow using --baseline=skip. + needs: [ test ] + strategy: + fail-fast: false # Collect all mutants even if some are missed + matrix: + shard: [ 0, 1, 2, 3, 4, 5, 6, 7 ] steps: - uses: actions/checkout@v4 - - uses: actions-rs/toolchain@v1 with: - profile: minimal - toolchain: stable - override: true - - uses: Swatinem/rust-cache@v2 - - run: rustup component add rustfmt - - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check - - clippy: - name: Clippy - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 + fetch-depth: 0 + - name: Relative diff + run: | + git branch -av + git diff origin/${{ github.base_ref }}.. | tee git.diff - uses: actions-rs/toolchain@v1 with: - profile: minimal toolchain: stable override: true - uses: Swatinem/rust-cache@v2 - - run: rustup component add clippy - - uses: actions-rs/cargo@v1 + - uses: taiki-e/install-action@v2 + name: Install cargo-mutants using install-action with: - command: clippy - args: -- -D warnings \ No newline at end of file + tool: cargo-mutants + # Set an appropriate timeout for your tree here. + # The denominator of the shard count must be the number of shards. + - name: Mutants + run: | + cargo mutants --no-shuffle -vV --shard ${{ matrix.shard }}/8 --baseline=skip --timeout 300 --in-place --in-diff git.diff + - name: Archive mutants.out + uses: actions/upload-artifact@v4 + if: always() + with: + path: mutants.out + name: mutants-shard${{matrix.shard}}.out \ No newline at end of file diff --git a/.gitignore b/.gitignore index 4fffb2f..03e9b88 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ -/target +/target/ +/mutants.out/ +/mutants.out.old/ +/.cargo/config.toml /Cargo.lock