Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved CI ⏩ #11

Merged
merged 5 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ jobs:
- clippy -- -D warnings
- doc
- test
- build --release
- bench
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
289 changes: 289 additions & 0 deletions Cargo.lock

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

7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,10 @@ documentation = "https://docs.rs/actions-github/latest/actions_github/"
[dependencies]
json = "0.12.4"
uuid = { version = "1.8.0", features = ["v4"] }

[dev-dependencies]
divan = "0.1.14"

[[bench]]
name = "action_speed"
harness = false
40 changes: 40 additions & 0 deletions benches/action_speed.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
use actions_github::core::{get_input, set_output};
use actions_github::error::ActionsError;
use actions_github::logger::{debug_log, error_log, info, is_debug, notice_log, warn_log};

fn main() {
// Run registered benchmarks.
divan::main();
}

#[divan::bench(args = ["test", "value", "very long string"])]
fn set_output_benchmark(value: &str) {
match set_output("name", value) {
Ok(_) => {}
Err(err) => panic!("{:#?}", err),
}
Comment on lines +10 to +14
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider handling errors more gracefully in benchmarks instead of using panic!.

match set_output("name", value) {
    Ok(_) => {},
    Err(err) => eprintln!("Error: {:#?}", err),
}

}

#[divan::bench(args = ["name", "place", "owner"])]
fn get_input_benchmark(value: &str) {
match get_input(value) {
Ok(_) => panic!("{} should not be available", value),
Err(_) => {}
}
}

#[divan::bench]
fn get_debug_benchmark() {
if !is_debug() {
panic!("It should be debug")
}
Comment on lines +26 to +29
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider a less disruptive approach than panic! for handling the debug mode check in benchmarks.

if !is_debug() {
    eprintln!("Debug mode should be active.");
}

}

#[divan::bench(args = ["hi", "example", "long words here"])]
fn log_benchmark(msg: &str) {
debug_log(msg);
info(msg);
warn_log(msg);
error_log(msg);
notice_log(msg);
}