Skip to content

Commit

Permalink
many fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Leandros committed Oct 22, 2024
1 parent 0347bde commit ee7c068
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 40 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ permissions:
contents: read

env:
RUSTFLAGS: -Dwarnings
RUSTFLAGS: -Dwarnings -A rust_2024_compatibility
CARGO_TERM_COLOR: always

jobs:
Expand Down Expand Up @@ -42,7 +42,7 @@ jobs:
- name: Enable nightly-only tests
run: echo RUSTFLAGS=${RUSTFLAGS}\ --cfg=thiserror_nightly_testing >> $GITHUB_ENV
if: matrix.rust == 'nightly'
- run: cargo xtask ci
- run: cargo xtask ci --no-extended
- uses: actions/upload-artifact@v4
if: matrix.rust == 'nightly' && always()
with:
Expand Down
2 changes: 1 addition & 1 deletion ferrunix-core/src/dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//! inner type via `.get`.
//!
//! # Examples
//! ```no_run
//! ```ignore,no_run
//! use ferrunix_core::{Registry, Singleton, Transient};
//!
//! struct Template {
Expand Down
2 changes: 1 addition & 1 deletion ferrunix-core/src/registration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ mod sync {
/// thread).
///
/// # Example
/// ```no_run
/// ```ignore,no_run
/// # use ferrunix_core::*;
/// # use ferrunix_core::registration::*;
/// #[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion ferrunix/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ ferrunix-macros = { path = "../ferrunix-macros", optional = true, version = "=0.

[dev-dependencies]
thiserror = "1"
tokio = { version = "1", features = ["full"] }
tokio = { version = "=1.21", features = ["full"] }
async-trait = "0.1"

# [package.metadata."docs.rs"]
Expand Down
16 changes: 10 additions & 6 deletions ferrunix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,18 @@ fn main() {
}
```

## Features
## Cargo Feature Flags

Ferrunix has the following features to enable further functionality.
Default features are marked with `*`.

- `multithread` (`*`): Enable support for access to the registry from multiple threads.
This adds a bound that all registered types must be `Send` and `Sync`.
- `derive` (`*`): Enable support for the `#[derive(Inject)]` macro.
Features enabled by default are marked with `*`.

- `multithread`: Enables support for accessing the registry from multiple
threads. This adds a bound that all registered types must be `Send` and
`Sync`.
- `derive` (`*`): Enables support for the `#[derive(Inject)]` macro.
- `tokio`: Enables support for `async` constructors. Bumps the MSRV up to
`1.75.0` because some of the internal traits require
[RPITIT](https://blog.rust-lang.org/2023/12/21/async-fn-rpit-in-traits.html#whats-stabilizing).

#### License

Expand Down
2 changes: 1 addition & 1 deletion xtask/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ workspace = true
[dependencies]
xshell = "0.2"
anyhow = "1"
clap = { version = "4", features = ["derive"] }
clap = { version = "=4.1.14", features = ["derive"] }
81 changes: 55 additions & 26 deletions xtask/src/ci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,60 @@
use anyhow::Result;
use xshell::{cmd, Shell};

/// How tests are run.
#[derive(Debug, Clone, clap::ValueEnum)]
pub(super) enum TestRunner {
/// Use the default cargo test runner.
Cargo,
/// Use nextest, requires installing `cargo-nextest`.
Nextest,
}

/// Arguments for `xtask ci`.
#[derive(Debug, Clone, clap::Args)]
pub(super) struct CiArgs {
/// Which test runner to use
#[arg(short, long)]
testrunner: Option<TestRunner>,

/// Whether to skip extended tests, e.g., `clippy`, `cargo outdated`, and
/// `cargo-semver-checks`. Useful in CI, when these run as a separate task.
#[arg(long, default_value_t = false)]
no_extended: bool,
}

/// Run all tests, similar to the GitHub Actions in `ci.yml`.
pub(super) fn run() -> Result<()> {
pub(super) fn run(args: &CiArgs) -> Result<()> {
let sh = Shell::new()?;
// sh.set_var("RUSTFLAGS", "-Dwarnings");
// sh.set_var("CARGO_INCREMENTAL", "0");
// sh.set_var("CARGO_TERM_COLOR", "always");

let has_cargo_outdated =
if let Err(err) = cmd!(sh, "cargo outdated --version").output() {
eprintln!("failed to find `cargo-outdated`: {err}");
eprintln!(
"try installing it with: cargo install --locked cargo-outdated"
);
false
} else {
true
};
let has_cargo_outdated = if args.no_extended {
false
} else if let Err(err) = cmd!(sh, "cargo outdated --version").output() {
eprintln!("failed to find `cargo-outdated`: {err}");
eprintln!(
"try installing it with: cargo install --locked cargo-outdated"
);
false
} else {
true
};

let has_cargo_semver =
if let Err(err) = cmd!(sh, "cargo semver-checks --version").output() {
eprintln!("failed to find `cargo-semver-checks`: {err}");
eprintln!(
"try installing it with: cargo install --locked \
let has_cargo_semver = if args.no_extended {
false
} else if let Err(err) = cmd!(sh, "cargo semver-checks --version").output()
{
eprintln!("failed to find `cargo-semver-checks`: {err}");
eprintln!(
"try installing it with: cargo install --locked \
cargo-semver-checks"
);
false
} else {
true
};
);
false
} else {
true
};

let test_matrix = [
("ferrunix", ""),
Expand All @@ -50,8 +75,10 @@ pub(super) fn run() -> Result<()> {
("ferrunix-macros", "development,multithread"),
];

let testrunner = &["nextest", "run"];
// let testrunner = &["test"];
let testrunner: &[&str] = match args.testrunner {
Some(TestRunner::Nextest) => &["nextest", "run"],
None | Some(TestRunner::Cargo) => &["test"],
};
for (proj, features) in test_matrix {
if features.is_empty() {
cmd!(sh, "cargo {testrunner...} -p {proj} --no-default-features")
Expand All @@ -67,15 +94,17 @@ pub(super) fn run() -> Result<()> {
}

// cmd!(sh, "cargo test --all").run()?;
if cmd!(sh, "cargo clippy --version").output().is_ok() {

if !args.no_extended && cmd!(sh, "cargo clippy --version").output().is_ok()
{
cmd!(sh, "cargo clippy --tests --workspace").run()?;
}

if has_cargo_outdated {
if !args.no_extended && has_cargo_outdated {
cmd!(sh, "cargo outdated --workspace --exit-code 1").run()?;
}

if has_cargo_semver {
if !args.no_extended && has_cargo_semver {
cmd!(sh, "cargo semver-checks").run()?;
}

Expand Down
4 changes: 2 additions & 2 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct Cli {
#[derive(Debug, Subcommand)]
enum CliCommands {
/// Build the workspace, similar to how the CI would build it.
CI,
CI(ci::CiArgs),
/// Publish all packages in the workspace to crates.io.
Publish(publish::PublishArgs)
}
Expand All @@ -30,7 +30,7 @@ fn main() -> anyhow::Result<()> {
let cli = Cli::parse();

match cli.command {
CliCommands::CI => ci::run()?,
CliCommands::CI(ref args) => ci::run(args)?,
CliCommands::Publish(ref args) => publish::run(args)?,
}

Expand Down

0 comments on commit ee7c068

Please sign in to comment.