From 24af65db5a05800391a47bb07d6d607905490da4 Mon Sep 17 00:00:00 2001 From: Julien Cretin Date: Sun, 9 Apr 2023 22:18:04 +0200 Subject: [PATCH] Add semver-checks test (#60) --- .github/workflows/ci.yml | 10 ++++++++++ xtask/src/main.rs | 17 +++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bd6a3d9..b23de3f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,6 +16,7 @@ jobs: - uses: actions/checkout@v3 - run: rustup install nightly - run: rustup component add --toolchain=nightly clippy miri rustfmt + - run: cargo +nightly install cargo-semver-checks - name: cd lib && cargo +nightly fmt -- --check run: cargo +nightly fmt -- --check working-directory: lib @@ -138,6 +139,15 @@ jobs: run: cargo +nightly bench working-directory: lib - run: cd bin && ./bench.sh +nightly + - name: cd lib && cargo +nightly semver-checks check-release + run: cargo +nightly semver-checks check-release + working-directory: lib + - name: cd lib/macro/internal && cargo +nightly semver-checks check-release + run: cargo +nightly semver-checks check-release + working-directory: lib/macro/internal + - name: cd lib/macro && cargo +nightly semver-checks check-release + run: cargo +nightly semver-checks check-release + working-directory: lib/macro - name: cd lib && cargo +nightly audit --deny=warnings run: cargo +nightly audit --deny=warnings working-directory: lib diff --git a/xtask/src/main.rs b/xtask/src/main.rs index d60ed46..ae1cef5 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -93,6 +93,9 @@ enum Task { #[strum(serialize = "bench")] Bench, + #[strum(serialize = "semver-checks")] + SemverChecks, + #[strum(serialize = "audit")] Audit, } @@ -113,6 +116,7 @@ impl Action { (Task::Clippy, _) => &["--", "--deny=warnings"], (Task::Build, Dir::Nostd) => &["--release"], (Task::Miri, _) => &["test"], + (Task::SemverChecks, _) => &["check-release"], (Task::Audit, _) => &["--deny=warnings"], _ => &[], }; @@ -372,6 +376,15 @@ impl Flags { } job.steps.push(WorkflowStep { run: Some(run), ..Default::default() }); } + if actions.iter().find(|x| matches!(x.task, Task::SemverChecks)).is_some() { + job.steps.push(WorkflowStep { + run: Some(format!( + "cargo +{} install cargo-semver-checks", + actions[0].toolchain + )), + ..Default::default() + }); + } for action in actions { for instruction in action.interpret().0 { job.steps @@ -432,6 +445,10 @@ impl Actions { // Bench is only supported for lib and bin. continue; } + if task == Task::SemverChecks && (!dir.is_published() || matches!(dir, Dir::Bin)) { + // SemverChecks only makes sense for published library crates. + continue; + } let os = Os::Ubuntu; let toolchain = Toolchain::Nightly; actions.insert(Action { os, toolchain, task, dir });