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

Use @rustls-benchmarking as the app's name #24

Merged
merged 1 commit into from
Dec 11, 2023
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
17 changes: 10 additions & 7 deletions ci-bench-runner/src/job/bench_pr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static ALLOWED_AUTHOR_ASSOCIATIONS: &[&str] = &[
/// - Has just been created (edits are ignored);
/// - Has been posted to a PR (not to an issue);
/// - Has been posted by an authorized user; and
/// - Addresses the bot with the right command (`@rustls-bench bench`).
/// - Addresses the bot with the right command (`@APP_NAME bench`).
pub async fn handle_issue_comment(ctx: JobContext<'_>) -> anyhow::Result<()> {
// Ideally, we'd use WebhookEvent::try_from_header_and_body from `octocrab`, but it doesn't have
// the `author_association` field on the comment, which we need.
Expand Down Expand Up @@ -77,7 +77,7 @@ pub async fn handle_issue_comment(ctx: JobContext<'_>) -> anyhow::Result<()> {
}

let octocrab = ctx.octocrab.cached();
if body.contains("@rustls-bench bench") {
if body.contains(&format!("@{APP_NAME} bench")) {
let pr = octocrab
.pulls(&ctx.config.github_repo_owner, &ctx.config.github_repo_name)
.get(payload.issue.number)
Expand All @@ -86,17 +86,19 @@ pub async fn handle_issue_comment(ctx: JobContext<'_>) -> anyhow::Result<()> {

let branches = pr_branches(&pr).ok_or(anyhow!("unable to get PR branch details"))?;
bench_pr(ctx, pr.number, branches).await
} else if body.contains("@rustls-bench") {
trace!("the comment was addressed at rustls-bench, but it is an unknown command!");
let comment = "Unrecognized command. Available commands are:\n\
* `@rustls-bench bench`: runs the instruction count benchmarks and reports the results";
} else if body.contains(&format!("@{APP_NAME}")) {
trace!("the comment was addressed at the application, but it is an unknown command!");
let comment = format!(
"Unrecognized command. Available commands are:\n\
* `@{APP_NAME} bench`: runs the instruction count benchmarks and reports the results"
);
octocrab
.issues(&ctx.config.github_repo_owner, &ctx.config.github_repo_name)
.create_comment(payload.issue.number, comment)
.await?;
Ok(())
} else {
trace!("the comment was not addressed at rustls-bench");
trace!("the comment was not addressed at the application");
Ok(())
}
}
Expand Down Expand Up @@ -740,6 +742,7 @@ static DEFAULT_ICOUNT_NOISE_THRESHOLD: f64 = 0.002; // 0.2%
static MINIMUM_ICOUNT_NOISE_THRESHOLD: f64 = 0.002; // 0.2%
static DEFAULT_WALLTIME_NOISE_THRESHOLD: f64 = 0.05; // 5%
static MINIMUM_WALLTIME_NOISE_THRESHOLD: f64 = 0.01; // 1%
static APP_NAME: &str = "rustls-benchmarking";

/// Functions inside this module will be available as askama filters
mod filters {
Expand Down
6 changes: 3 additions & 3 deletions ci-bench-runner/src/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ async fn test_issue_comment_unauthorized_user() {

// Post the webhook event
let client = reqwest::Client::default();
let event = webhook::comment("@rustls-bench bench", "created", "NONE");
let event = webhook::comment("@rustls-benchmarking bench", "created", "NONE");
post_webhook(
&client,
&server.base_url,
Expand All @@ -211,7 +211,7 @@ async fn test_issue_comment_edited() {

// Post the webhook event
let client = reqwest::Client::default();
let event = webhook::comment("@rustls-bench bench", "edit", "OWNER");
let event = webhook::comment("@rustls-benchmarking bench", "edit", "OWNER");
post_webhook(
&client,
&server.base_url,
Expand Down Expand Up @@ -239,7 +239,7 @@ async fn test_issue_comment_happy_path() {

// Post the webhook event
let client = reqwest::Client::default();
let event = webhook::comment("@rustls-bench bench", "created", "OWNER");
let event = webhook::comment("@rustls-benchmarking bench", "created", "OWNER");
post_webhook(
&client,
&server.base_url,
Expand Down
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ The following features are supported:
For security, comparison bench runs are only triggered in the following scenarios:
- A PR is created or updated and the head branch lives in the rustls repository.
- A maintainer leaves a GitHub review approving the PR.
- A maintainer posts a comment to the PR including `@rustls-bench bench` as part of the body. This
can be used as a fallback mechanism when the triggers mentioned above are not enough.
- A maintainer posts a comment to the PR including `@rustls-benchmarking bench` as part of the
body. This can be used as a fallback mechanism when the triggers mentioned above are not enough.
- Report comparison results in a comment to the relevant PR, reusing the same comment when new
results are available.

Expand Down
Loading