Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
name: Check
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Install toolchain
uses: dtolnay/rust-toolchain@nightly
with:
Expand All @@ -46,17 +46,17 @@ jobs:
- uses: taiki-e/install-action@v2
with:
tool: typos-cli,taplo-cli,hawkeye
- run: cargo +nightly x lint
- run: cargo x lint

test:
name: Run tests
strategy:
matrix:
os: [ ubuntu-24.04, macos-14, windows-2022 ]
rust-version: [ "stable" ]
rust-version: [ "stable", "nightly" ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: Swatinem/rust-cache@v2
- name: Delete rust-toolchain.toml
run: rm rust-toolchain.toml
Expand Down
72 changes: 69 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

[workspace]
members = ["exn", "xtask"]
members = ["examples", "exn", "xtask"]
resolver = "3"

[workspace.package]
Expand All @@ -23,6 +23,16 @@ license = "Apache-2.0"
readme = "README.md"
repository = "https://github.com/fast/exn"

[workspace.dependencies]
# Workspace dependencies
exn = { path = "exn" }

# Crates.io dependencies
clap = { version = "4.5.20", features = ["derive"] }
Comment thread
tisonkun marked this conversation as resolved.
derive_more = { version = "2.1.0", features = ["full"] }
insta = { version = "1.45.1" }
which = { version = "8.0.0" }

[workspace.lints.rust]
unexpected_cfgs = { level = "deny", check-cfg = ['cfg(windows_test)'] }
unknown_lints = "deny"
Expand Down
45 changes: 45 additions & 0 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright 2025 FastLabs Developers
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

[package]
name = "examples"
publish = false

edition.workspace = true

[[example]]
name = "anti-pattern"
path = "src/anti-pattern.rs"

[[example]]
name = "basic"
path = "src/basic.rs"

[[example]]
name = "custom-layout"
path = "src/custom-layout.rs"

[[example]]
name = "downcast"
path = "src/downcast.rs"

[package.metadata.release]
release = false

[dependencies]
derive_more = { workspace = true }
exn = { workspace = true }

[lints]
workspace = true
6 changes: 3 additions & 3 deletions exn/examples/anti_pattern.rs → examples/src/anti-pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ mod http {
// Output when running `cargo run --example anti_pattern`.
// Notice "failed to send request" appears twice with no new information!
//
// Error: fatal error occurred in application, at exn/examples/anti_pattern.rs:35:16
// Error: fatal error occurred in application, at examples/src/anti-pattern.rs:35:16
// |
// |-> failed to send request, at exn/examples/anti_pattern.rs:49:30
// |-> failed to send request, at examples/src/anti-pattern.rs:49:30
// |
// |-> failed to send request to server: https://anti-pattern.com, at exn/examples/anti_pattern.rs:67:9
// |-> failed to send request to server: https://anti-pattern.com, at examples/src/anti-pattern.rs:67:9
6 changes: 3 additions & 3 deletions exn/examples/basic.rs → examples/src/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ mod http {

// Output when running `cargo run --example basic`:
//
// Error: fatal error occurred in application, at exn/examples/basic.rs:34:16
// Error: fatal error occurred in application, at examples/src/basic.rs:34:16
// |
// |-> failed to run app, at exn/examples/basic.rs:49:14
// |-> failed to run app, at examples/src/basic.rs:49:14
// |
// |-> failed to send request to server: https://example.com, at exn/examples/basic.rs:62:9
// |-> failed to send request to server: https://example.com, at examples/src/basic.rs:62:9
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,5 @@ mod http {
// Output when running `cargo run --example custom_layout`:
//
// Error: fatal error occurred in application:
// 0: [exn/examples/custom_layout.rs:81:30] failed to run app
// 1: [exn/examples/custom_layout.rs:101:9] failed to send request to server: https://example.com
// 0: [examples/src/custom-layout.rs:81:30] failed to run app
// 1: [examples/src/custom-layout.rs:101:9] failed to send request to server: https://example.com
6 changes: 3 additions & 3 deletions exn/examples/downcast.rs → examples/src/downcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ mod http {
// Retryable error, attempting retry #3
//
// HTTP error with status code: 503
// Error: fatal error occurred in application, at exn/examples/downcast.rs:52:24
// Error: fatal error occurred in application, at examples/src/downcast.rs:52:24
// |
// |-> failed to run app, at exn/examples/downcast.rs:80:35
// |-> failed to run app, at examples/src/downcast.rs:80:35
// |
// |-> HTTP 503: service unavailable, at exn/examples/downcast.rs:93:9
// |-> HTTP 503: service unavailable, at examples/src/downcast.rs:93:9
3 changes: 1 addition & 2 deletions exn/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ rustdoc-args = ["--cfg", "docsrs"]
[dependencies]

[dev-dependencies]
derive_more = { version = "2.1.0", features = ["full"] }
insta = { version = "1.43.2" }
insta = { workspace = true }

[lints]
workspace = true
8 changes: 2 additions & 6 deletions xtask/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,13 @@ name = "x"
publish = false

edition.workspace = true
homepage.workspace = true
license.workspace = true
readme.workspace = true
repository.workspace = true

[package.metadata.release]
release = false

[dependencies]
clap = { version = "4.5.23", features = ["derive"] }
which = { version = "8.0.0" }
clap = { workspace = true }
which = { workspace = true }

[lints]
workspace = true
36 changes: 20 additions & 16 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,16 @@ impl CommandLint {

#[cfg(not(windows_test))]
fn run_example_tests() {
let examples_dir = PathBuf::from(env!("CARGO_WORKSPACE_DIR")).join("exn/examples");
let examples_dir = PathBuf::from(env!("CARGO_WORKSPACE_DIR"))
.join("examples")
.join("src");

assert!(
examples_dir.exists(),
"No examples directory found at {:?}",
examples_dir
);
let entries = fs::read_dir(&examples_dir).unwrap_or_else(|err| {
panic!("failed to read examples directory at {examples_dir:?}: {err:?}")
});

let mut total = 0;
let mut failed = Vec::new();
let entries = fs::read_dir(&examples_dir).unwrap();

let mut failed = vec![];
for entry in entries {
let entry = entry.unwrap();
let path = entry.path();
Expand All @@ -120,25 +118,30 @@ fn run_example_tests() {

let content = fs::read_to_string(&path).unwrap();

let commented_stderr = stderr
let actual = stderr
.lines()
.map(|line| format!("// {}", line).trim().to_string())
.map(|line| {
if line.is_empty() {
"//".to_string()
} else {
format!("// {}", line)
}
})
.collect::<Vec<_>>()
.join("\n");

if !content.contains(&commented_stderr) {
failed.push((path, stderr.to_string(), commented_stderr));
if !content.contains(&actual) {
failed.push((path, actual));
}

total += 1;
}

if !failed.is_empty() {
eprintln!("{}/{} example tests failed:", failed.len(), total);
for (path, actual, expected_comment) in failed {
for (path, actual) in failed {
eprintln!("\nexample: {}", path.display());
eprintln!("actual stderr:\n{}", actual);
eprintln!("expected comment in file:\n{}", expected_comment);
}
std::process::exit(1);
} else {
Expand Down Expand Up @@ -207,7 +210,7 @@ fn make_test_cmd(no_capture: bool, default_features: bool, features: &[&str]) ->

fn make_format_cmd(fix: bool) -> StdCommand {
let mut cmd = find_command("cargo");
cmd.args(["fmt", "--all"]);
cmd.args(["+nightly", "fmt", "--all"]);
if !fix {
cmd.arg("--check");
}
Expand All @@ -217,6 +220,7 @@ fn make_format_cmd(fix: bool) -> StdCommand {
fn make_clippy_cmd(fix: bool) -> StdCommand {
let mut cmd = find_command("cargo");
cmd.args([
"+nightly",
"clippy",
"--tests",
"--all-features",
Expand Down