Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
sourcefrog authored Nov 22, 2024
2 parents cbb3121 + 6daabb8 commit d00dc49
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 62 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/release-book.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ jobs:
with:
tool: mdbook, mdbook-linkcheck
- name: Setup Pages
uses: actions/configure-pages@v2
uses: actions/configure-pages@v5
- name: Build book
run: |
mdbook build book
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
uses: actions/upload-pages-artifact@v3
with:
path: "book/book/html"
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
uses: actions/deploy-pages@v4
134 changes: 81 additions & 53 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,53 @@ env:
CARGO_MUTANTS_MINIMUM_TEST_TIMEOUT: 60

jobs:
# Before anything else, run a quick test on just stable: this is significantly
# faster than Windows or macOS and should catch most issues, and lets us get
# started on the longer-running mutants and other tests.
#
# Also, build a Linux binary that we can use for the later mutants runs.
quick-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: dtolnay/rust-toolchain@master
with:
toolchain: beta
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- name: Show Cargo and rustc version
run: |
cargo --version
rustc --version
# TODO: Maybe also check clippy and rustfmt here.
- name: Build
run: cargo build --all-targets
- uses: taiki-e/install-action@v2
name: Install nextest using install-action
with:
tool: nextest
- name: Test
run: cargo test --workspace
- name: Check rustfmt
run: cargo fmt --all --check
- name: Check clippy
# TODO: -- -D warnings
run: cargo clippy --all-targets --all-features
- name: Check typos
uses: crate-ci/typos@master
- name: Build release binary
run: cargo build --release
- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: cargo-mutants-linux
path: |
target/release/cargo-mutants
test:
needs: [quick-test]
strategy:
matrix:
os: [macOS-latest, ubuntu-latest, windows-latest]
Expand All @@ -50,7 +96,7 @@ jobs:
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.version }}
components: rustfmt
components: rustfmt, clippy
- name: Show Cargo and rustc version
run: |
cargo --version
Expand All @@ -66,8 +112,18 @@ jobs:
run: cargo build --all-targets
- name: Test
run: cargo test --workspace
- name: Check rustfmt
run: cargo fmt --all --check
- name: Check clippy
# TODO: Deny warnings
run: cargo clippy --all-targets --all-features
- name: Install locked
run: cargo install --locked --path .
- name: Install unlocked
run: cargo install --path .

minimal-versions:
needs: [quick-test]
strategy:
matrix:
os: [macOS-latest, ubuntu-latest, windows-latest]
Expand All @@ -86,6 +142,7 @@ jobs:

# Run `cargo update` and check the tests still pass
maximal-versions:
needs: [quick-test]
strategy:
matrix:
os: [macOS-latest, ubuntu-latest, windows-latest]
Expand All @@ -102,6 +159,7 @@ jobs:
- run: cargo test

tests-from-tarball:
needs: [quick-test]
strategy:
matrix:
os: [ubuntu-latest]
Expand Down Expand Up @@ -131,52 +189,10 @@ jobs:
cd target/package/cargo-mutants-*.*.[0-9]
cargo test
# Install from a checkout of the source, to find broken dependencies etc.
# We run this on various versions because some dependencies might have changed
# their MSRV, and on every platform because there are platform-specific
# dependencies.
install:
strategy:
matrix:
os: [macOS-latest, ubuntu-latest, windows-latest]
version: [stable, nightly, "1.74"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.version }}
- name: Show Cargo and rustc version
run: |
cargo --version
rustc --version
- uses: Swatinem/rust-cache@v2
- run: cargo install --locked --path .
- run: cargo install --path .

release-binary:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: dtolnay/rust-toolchain@master
with:
toolchain: beta
- uses: Swatinem/rust-cache@v2
- name: Build
run: cargo build --release
- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: cargo-mutants-linux
path: |
target/release/cargo-mutants
pr-mutants:
runs-on: ubuntu-latest
needs: [release-binary]
if: github.event_name == 'pull_request'
needs: [quick-test]
strategy:
matrix:
test_tool: [cargo, nextest]
Expand Down Expand Up @@ -206,7 +222,8 @@ jobs:
- name: Mutants in-diff
# Normally this would have --in-place, but for the sake of exercising more cases, it does not.
run: >
cargo mutants --no-shuffle -vV --in-diff git.diff --test-tool=${{matrix.test_tool}} --timeout=500 --build-timeout=500
cargo mutants --no-shuffle -vV --in-diff git.diff
--test-tool=${{matrix.test_tool}} --timeout=500 --build-timeout=500
- name: Archive mutants.out
uses: actions/upload-artifact@v4
if: always()
Expand All @@ -216,7 +233,7 @@ jobs:

cargo-mutants:
runs-on: ubuntu-latest
needs: [test, release-binary]
needs: [quick-test]
strategy:
fail-fast: false # We want to get all the mutant failures
matrix:
Expand Down Expand Up @@ -252,12 +269,23 @@ jobs:
name: mutants-${{matrix.test_tool}}-shard${{matrix.shard}}.out
path: mutants.out

typos:
name: Spell check with Typos
overall-result:
needs:
[
quick-test,
test,
minimal-versions,
maximal-versions,
tests-from-tarball,
pr-mutants,
cargo-mutants,
]
runs-on: ubuntu-latest
if: always()
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Check spelling
uses: crate-ci/typos@master
- name: Successful workflow
if: ${{ !(contains(needs.*.result, 'failure')) }}
run: exit 0
- name: Failing workflow
if: ${{ contains(needs.*.result, 'failure') }}
run: exit 1
2 changes: 1 addition & 1 deletion src/fnvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ fn type_replacements(type_: &Type, error_exprs: &[Expr]) -> impl Iterator<Item =
}

fn path_ends_with(path: &Path, ident: &str) -> bool {
path.segments.last().map_or(false, |s| s.ident == ident)
path.segments.last().is_some_and(|s| s.ident == ident)
}

fn match_impl_iterator(TypeImplTrait { bounds, .. }: &TypeImplTrait) -> Option<&Type> {
Expand Down
4 changes: 2 additions & 2 deletions src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ impl Colors {
/// detected terminal characteristics.
pub fn forced_value(&self) -> Option<bool> {
// From https://bixense.com/clicolors/
if env::var("NO_COLOR").map_or(false, |x| x != "0") {
if env::var("NO_COLOR").is_ok_and(|x| x != "0") {
Some(false)
} else if env::var("CLICOLOR_FORCE").map_or(false, |x| x != "0") {
} else if env::var("CLICOLOR_FORCE").is_ok_and(|x| x != "0") {
Some(true)
} else {
match self {
Expand Down
2 changes: 1 addition & 1 deletion src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl OutputDir {
let log_dir = output_dir.join("log");
create_dir(&log_dir).with_context(|| format!("create log directory {:?}", &log_dir))?;
let diff_dir = output_dir.join("diff");
create_dir(&diff_dir).context("create diff dir")?;
create_dir(diff_dir).context("create diff dir")?;

// Create text list files.
let mut list_file_options = OpenOptions::new();
Expand Down
2 changes: 1 addition & 1 deletion src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl Process {
/// Check if the child process has finished; if so, return its status.
#[mutants::skip] // It's hard to avoid timeouts if this never works...
pub fn poll(&mut self) -> Result<Option<ProcessStatus>> {
if self.timeout.map_or(false, |t| self.start.elapsed() > t) {
if self.timeout.is_some_and(|t| self.start.elapsed() > t) {
debug!("timeout, terminating child process...",);
self.terminate()?;
Ok(Some(ProcessStatus::Timeout))
Expand Down
2 changes: 1 addition & 1 deletion tests/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl CommandInstaExt for assert_cmd::Command {
// Copy the source for one testdata tree.
pub fn copy_of_testdata(tree_name: &str) -> TempDir {
assert!(
!tree_name.contains("/"),
!tree_name.contains('/'),
"testdata tree name {tree_name:?} should be just the directory name"
);
let tmp = TempDir::with_prefix(format!("cargo-mutants-testdata-{tree_name}-")).unwrap();
Expand Down

0 comments on commit d00dc49

Please sign in to comment.