Skip to content

Commit

Permalink
ci: only post perfomance to slack on dev merge (#1431)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattstam authored and ctian1 committed Aug 29, 2024
1 parent 61c9594 commit 52b37d3
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 19 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: PR

on:
push:
branches: [main]
branches: [main, dev]
pull_request:
branches:
- "**"
Expand Down Expand Up @@ -158,7 +158,7 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: check
args: -p sp1-sdk --target wasm32-unknown-unknown --no-default-features
args: -p sp1-sdk --target wasm32-unknown-unknown --no-default-features

examples:
name: Examples
Expand Down Expand Up @@ -252,8 +252,10 @@ jobs:
cd crates/eval
RUSTFLAGS='-C target-cpu=native' cargo run --release -- \
--programs fibonacci,ssz-withdrawals,tendermint \
--slack-channel-id ${{ secrets.SLACK_CHANNEL_ID }} \
--slack-token ${{ secrets.SLACK_TOKEN }} \
--post-to-slack ${{ github.ref == 'refs/heads/dev' }} \
--slack-channel-id "${{ secrets.SLACK_CHANNEL_ID }}" \
--slack-token "${{ secrets.SLACK_TOKEN }}" \
--post-to-github ${{ github.event_name == 'pull_request' }} \
--github-token "${{ secrets.GITHUB_TOKEN }}" \
--repo-owner "${{ github.repository_owner }}" \
--repo-name "${{ github.event.repository.name }}" \
Expand Down
50 changes: 35 additions & 15 deletions crates/eval/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,23 @@ struct EvalArgs {
#[arg(long)]
pub shard_size: Option<usize>,

/// The Slack channel ID to post results to, only required if you want to post to Slack.
/// Whether to post results to Slack.
#[arg(long, default_missing_value="true", num_args=0..=1)]
pub post_to_slack: Option<bool>,

/// The Slack channel ID to post results to, only used if post_to_slack is true.
#[arg(long)]
pub slack_channel_id: Option<String>,

/// The Slack bot token to post results to, only used if slack_channel_id is set.
/// The Slack bot token to post results to, only used if post_to_slack is true.
#[arg(long)]
pub slack_token: Option<String>,

/// The GitHub token for authentication, only required if you want to post to GitHub.
/// Whether to post results to GitHub PR.
#[arg(long, default_missing_value="true", num_args=0..=1)]
pub post_to_github: Option<bool>,

/// The GitHub token for authentication, only used if post_to_github is true.
#[arg(long)]
pub github_token: Option<String>,

Expand Down Expand Up @@ -105,18 +113,28 @@ pub async fn evaluate_performance<C: SP1ProverComponents>() -> Result<(), Box<dy
println!("{}", results_text.join("\n"));

// Post to Slack if applicable
for message in &results_text {
if let (Some(token), Some(channel)) = (&args.slack_token, &args.slack_channel_id) {
post_to_slack(token, channel, message).await?;
if args.post_to_slack.unwrap_or(false) {
match (&args.slack_token, &args.slack_channel_id) {
(Some(token), Some(channel)) => {
for message in &results_text {
post_to_slack(token, channel, message).await?;
}
}
_ => println!("Warning: post_to_slack is true, required Slack arguments are missing."),
}
}

// Post to GitHub PR if applicable
if let (Some(owner), Some(repo), Some(pr_number), Some(token)) =
(&args.repo_owner, &args.repo_name, &args.pr_number, &args.github_token)
{
let message = format_github_message(&results_text);
post_to_github_pr(owner, repo, pr_number, token, &message).await?;
if args.post_to_github.unwrap_or(false) {
match (&args.repo_owner, &args.repo_name, &args.pr_number, &args.github_token) {
(Some(owner), Some(repo), Some(pr_number), Some(token)) => {
let message = format_github_message(&results_text);
post_to_github_pr(owner, repo, pr_number, token, &message).await?;
}
_ => {
println!("Warning: post_to_github is true, required GitHub arguments are missing.")
}
}
}

// Exit with an error if any programs failed.
Expand Down Expand Up @@ -374,16 +392,18 @@ mod tests {
let args = EvalArgs {
programs: vec!["fibonacci".to_string(), "super-program".to_string()],
shard_size: None,
post_to_slack: Some(false),
slack_channel_id: None,
slack_token: None,
post_to_github: Some(true),
github_token: Some("abcdef1234567890".to_string()),
repo_owner: Some("succinctlabs".to_string()),
repo_name: Some("sp1".to_string()),
pr_number: Some("123456".to_string()),
pr_name: Some("Test PR".to_string()),
branch_name: Some("feature-branch".to_string()),
commit_hash: Some("abcdef1234567890".to_string()),
author: Some("John Doe".to_string()),
repo_owner: Some("succinctlabs".to_string()),
repo_name: Some("sp1".to_string()),
pr_number: Some("123456".to_string()),
github_token: Some("abcdef1234567890".to_string()),
};

let formatted_results = format_results(&args, &dummy_reports);
Expand Down

0 comments on commit 52b37d3

Please sign in to comment.