Skip to content

Commit

Permalink
Improved CI ⏩ (#11)
Browse files Browse the repository at this point in the history
- Added benchmarks with the library
[divan](https://crates.io/crates/divan)
- Added more steps to the required tests


## Summary

- **New Features**
- Introduced benchmarking for input/output handling and logging to
improve performance insights.

- **Chores**
  - Added `divan` dependency for benchmarking.
  - Updated build workflow to include new benchmark steps.
  • Loading branch information
Bullrich authored May 27, 2024
1 parent a591027 commit 133bcfd
Show file tree
Hide file tree
Showing 4 changed files with 337 additions and 0 deletions.
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
39 changes: 39 additions & 0 deletions benches/action_speed.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
use actions_github::core::{get_input, set_output};
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),
}
}

#[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")
}
}

#[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);
}

0 comments on commit 133bcfd

Please sign in to comment.