From ad85f985aeed7bd78fb83bc19fe78a47bc558fc8 Mon Sep 17 00:00:00 2001 From: vohoanglong0107 Date: Thu, 7 Mar 2024 08:19:49 +0000 Subject: [PATCH 01/57] chore: bump rust version in Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 03dda774..771bdc9c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM rust:1.70 as base +FROM rust:1.76 as base ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse From 2ffe9c54c264074e225fef1286c6f3e1eafd9d83 Mon Sep 17 00:00:00 2001 From: vohoanglong0107 Date: Wed, 6 Mar 2024 10:59:23 +0000 Subject: [PATCH 02/57] feat: help command --- src/bors/command/mod.rs | 2 ++ src/bors/command/parser.rs | 25 ++++++++++++++++++++++++- src/bors/handlers/help.rs | 34 ++++++++++++++++++++++++++++++++++ src/bors/handlers/mod.rs | 6 ++++++ 4 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 src/bors/handlers/help.rs diff --git a/src/bors/command/mod.rs b/src/bors/command/mod.rs index 8f58639c..c7d732cf 100644 --- a/src/bors/command/mod.rs +++ b/src/bors/command/mod.rs @@ -5,6 +5,8 @@ pub use parser::{CommandParseError, CommandParser}; /// Bors command specified by a user. #[derive(Debug, PartialEq)] pub enum BorsCommand { + /// Print help + Help, /// Ping the bot. Ping, /// Perform a try build. diff --git a/src/bors/command/parser.rs b/src/bors/command/parser.rs index 598bc9fc..f3c464bb 100644 --- a/src/bors/command/parser.rs +++ b/src/bors/command/parser.rs @@ -41,7 +41,7 @@ impl CommandParser { ) -> Vec>> { // The order of the parsers in the vector is important let parsers: Vec fn(&'b str, &[CommandPart<'b>]) -> ParseResult<'b>> = - vec![parser_ping, parser_try_cancel, parser_try]; + vec![parser_help, parser_ping, parser_try_cancel, parser_try]; text.lines() .filter_map(|line| match line.find(&self.prefix) { @@ -108,6 +108,15 @@ fn parse_parts(input: &str) -> Result, CommandParseError> { /// Parsers +/// Parses "@bors help". +fn parser_help<'a>(command: &'a str, _parts: &[CommandPart<'a>]) -> ParseResult<'a> { + if command == "help" { + Some(Ok(BorsCommand::Help)) + } else { + None + } +} + /// Parses "@bors ping". fn parser_ping<'a>(command: &'a str, _parts: &[CommandPart<'a>]) -> ParseResult<'a> { if command == "ping" { @@ -211,6 +220,20 @@ mod tests { assert!(matches!(cmds[0], Err(CommandParseError::DuplicateArg("a")))); } + #[test] + fn parse_help() { + let cmds = parse_commands("@bors help"); + assert_eq!(cmds.len(), 1); + assert!(matches!(cmds[0], Ok(BorsCommand::Help))); + } + + #[test] + fn parse_help_unknown_arg() { + let cmds = parse_commands("@bors help a"); + assert_eq!(cmds.len(), 1); + assert!(matches!(cmds[0], Ok(BorsCommand::Help))); + } + #[test] fn parse_ping() { let cmds = parse_commands("@bors ping"); diff --git a/src/bors/handlers/help.rs b/src/bors/handlers/help.rs new file mode 100644 index 00000000..2a28b5bd --- /dev/null +++ b/src/bors/handlers/help.rs @@ -0,0 +1,34 @@ +use crate::bors::RepositoryClient; +use crate::bors::RepositoryState; +use crate::github::PullRequest; + +const HELP_MESSAGE: &str = r#" +- try: Execute the `try` CI workflow on this PR (without approving it for a merge). +- try cancel: Stop try builds on current PR. +- ping: pong +- help: Print this help message +"#; + +pub(super) async fn command_help( + repo: &mut RepositoryState, + pr: &PullRequest, +) -> anyhow::Result<()> { + repo.client.post_comment(pr.number, HELP_MESSAGE).await?; + Ok(()) +} + +#[cfg(test)] +mod tests { + use crate::bors::handlers::help::HELP_MESSAGE; + use crate::tests::event::default_pr_number; + use crate::tests::state::ClientBuilder; + + #[tokio::test] + async fn test_help() { + let mut state = ClientBuilder::default().create_state().await; + state.comment("@bors help").await; + state + .client() + .check_comments(default_pr_number(), &[HELP_MESSAGE]); + } +} diff --git a/src/bors/handlers/mod.rs b/src/bors/handlers/mod.rs index 2d0d83f0..e1f38e7a 100644 --- a/src/bors/handlers/mod.rs +++ b/src/bors/handlers/mod.rs @@ -4,6 +4,7 @@ use tracing::Instrument; use crate::bors::command::BorsCommand; use crate::bors::command::CommandParseError; use crate::bors::event::{BorsEvent, PullRequestComment}; +use crate::bors::handlers::help::command_help; use crate::bors::handlers::ping::command_ping; use crate::bors::handlers::refresh::refresh_repository; use crate::bors::handlers::trybuild::{command_try_build, command_try_cancel, TRY_BRANCH_NAME}; @@ -15,6 +16,7 @@ use crate::database::DbClient; use crate::github::GithubRepoName; use crate::utils::logging::LogError; +mod help; mod labels; mod ping; mod refresh; @@ -162,6 +164,10 @@ async fn handle_comment( match command { Ok(command) => { let result = match command { + BorsCommand::Help => { + let span = tracing::info_span!("Help"); + command_help(repo, &pull_request).instrument(span).await + } BorsCommand::Ping => { let span = tracing::info_span!("Ping"); command_ping(repo, &pull_request).instrument(span).await From e22c6e66eb9d4cb87b48da501fc5c50b552ead7a Mon Sep 17 00:00:00 2001 From: vohoanglong0107 Date: Thu, 14 Mar 2024 02:29:46 +0000 Subject: [PATCH 03/57] feat: try last parent --- database/entity/src/build.rs | 1 + database/migration/src/lib.rs | 2 + .../m20240312_053916_add_parent_to_build.rs | 37 ++++++++ src/bors/command/mod.rs | 8 +- src/bors/command/parser.rs | 38 +++++--- src/bors/handlers/trybuild.rs | 88 ++++++++++++++++--- src/database/mod.rs | 3 + src/database/sea_orm_client.rs | 3 + src/tests/state.rs | 11 ++- 9 files changed, 164 insertions(+), 27 deletions(-) create mode 100644 database/migration/src/m20240312_053916_add_parent_to_build.rs diff --git a/database/entity/src/build.rs b/database/entity/src/build.rs index 2ab9e427..713e2f20 100644 --- a/database/entity/src/build.rs +++ b/database/entity/src/build.rs @@ -12,6 +12,7 @@ pub struct Model { pub commit_sha: String, pub status: String, pub created_at: DateTime, + pub parent: String, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] diff --git a/database/migration/src/lib.rs b/database/migration/src/lib.rs index ea37adc9..44cc6fb6 100644 --- a/database/migration/src/lib.rs +++ b/database/migration/src/lib.rs @@ -3,6 +3,7 @@ pub use sea_orm_migration::prelude::*; mod m20230505_165859_create_build; mod m20230506_075859_create_pr; mod m20230506_102008_create_workflow; +mod m20240312_053916_add_parent_to_build; pub struct Migrator; @@ -13,6 +14,7 @@ impl MigratorTrait for Migrator { Box::new(m20230505_165859_create_build::Migration), Box::new(m20230506_075859_create_pr::Migration), Box::new(m20230506_102008_create_workflow::Migration), + Box::new(m20240312_053916_add_parent_to_build::Migration), ] } } diff --git a/database/migration/src/m20240312_053916_add_parent_to_build.rs b/database/migration/src/m20240312_053916_add_parent_to_build.rs new file mode 100644 index 00000000..73c6be6f --- /dev/null +++ b/database/migration/src/m20240312_053916_add_parent_to_build.rs @@ -0,0 +1,37 @@ +use sea_orm_migration::prelude::*; + +#[derive(DeriveMigrationName)] +pub struct Migration; + +#[async_trait::async_trait] +impl MigrationTrait for Migration { + async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { + manager + .alter_table( + Table::alter() + .table(Build::Table) + .add_column(ColumnDef::new(Build::Parent).string().not_null()) + .to_owned(), + ) + .await + } + + async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { + // Replace the sample below with your own migration scripts + manager + .alter_table( + Table::alter() + .table(Build::Table) + .drop_column(Build::Parent) + .to_owned(), + ) + .await + } +} + +/// Learn more at https://docs.rs/sea-query#iden +#[derive(Iden)] +pub enum Build { + Table, + Parent, +} diff --git a/src/bors/command/mod.rs b/src/bors/command/mod.rs index c7d732cf..6fd54e5c 100644 --- a/src/bors/command/mod.rs +++ b/src/bors/command/mod.rs @@ -2,6 +2,12 @@ mod parser; use crate::github::CommitSha; pub use parser::{CommandParseError, CommandParser}; +#[derive(Clone, Debug, PartialEq)] +pub enum Parent { + CommitSha(CommitSha), + Last, +} + /// Bors command specified by a user. #[derive(Debug, PartialEq)] pub enum BorsCommand { @@ -12,7 +18,7 @@ pub enum BorsCommand { /// Perform a try build. Try { /// Parent commit which should be used as the merge base. - parent: Option, + parent: Option, }, /// Cancel a try build. TryCancel, diff --git a/src/bors/command/parser.rs b/src/bors/command/parser.rs index f3c464bb..d6c47a0b 100644 --- a/src/bors/command/parser.rs +++ b/src/bors/command/parser.rs @@ -2,7 +2,7 @@ use std::collections::HashSet; -use crate::bors::command::BorsCommand; +use crate::bors::command::{BorsCommand, Parent}; use crate::github::CommitSha; #[derive(Debug, PartialEq)] @@ -148,14 +148,18 @@ fn parser_try<'a>(command: &'a str, parts: &[CommandPart<'a>]) -> ParseResult<'a } CommandPart::KeyValue { key, value } => { if *key == "parent" { - parent = match parse_sha(value) { - Ok(sha) => Some(sha), - Err(error) => { - return Some(Err(CommandParseError::ValidationError(format!( - "Try parent has to be a valid commit SHA: {error}" - )))); + parent = if *value == "last" { + Some(Parent::Last) + } else { + match parse_sha(value) { + Ok(sha) => Some(Parent::CommitSha(sha)), + Err(error) => { + return Some(Err(CommandParseError::ValidationError(format!( + "Try parent has to be a valid commit SHA: {error}" + )))); + } } - }; + } } else { return Some(Err(CommandParseError::UnknownArg(key))); } @@ -177,7 +181,7 @@ fn parser_try_cancel<'a>(command: &'a str, parts: &[CommandPart<'a>]) -> ParseRe #[cfg(test)] mod tests { use crate::bors::command::parser::{CommandParseError, CommandParser}; - use crate::bors::command::BorsCommand; + use crate::bors::command::{BorsCommand, Parent}; use crate::github::CommitSha; #[test] @@ -275,9 +279,21 @@ line two assert_eq!( cmds[0], Ok(BorsCommand::Try { - parent: Some(CommitSha( + parent: Some(Parent::CommitSha(CommitSha( "ea9c1b050cc8b420c2c211d2177811e564a4dc60".to_string() - )) + ))) + }) + ); + } + + #[test] + fn parse_try_parent_last() { + let cmds = parse_commands("@bors try parent=last"); + assert_eq!(cmds.len(), 1); + assert_eq!( + cmds[0], + Ok(BorsCommand::Try { + parent: Some(Parent::Last) }) ); } diff --git a/src/bors/handlers/trybuild.rs b/src/bors/handlers/trybuild.rs index 53ad8a6a..6c621300 100644 --- a/src/bors/handlers/trybuild.rs +++ b/src/bors/handlers/trybuild.rs @@ -1,5 +1,6 @@ use anyhow::{anyhow, Context}; +use crate::bors::command::Parent; use crate::bors::handlers::labels::handle_label_trigger; use crate::bors::RepositoryClient; use crate::bors::RepositoryState; @@ -30,7 +31,7 @@ pub(super) async fn command_try_build( db: &mut dyn DbClient, pr: &PullRequest, author: &GithubUser, - parent: Option, + parent: Option, ) -> anyhow::Result<()> { if !check_try_permissions(repo, pr, author).await? { return Ok(()); @@ -41,7 +42,7 @@ pub(super) async fn command_try_build( .await .context("Cannot find or create PR")?; - if let Some(ref build) = pr_model.try_build { + let last_parent = if let Some(ref build) = pr_model.try_build { if build.status == BuildStatus::Pending { tracing::warn!("Try build already in progress"); repo.client @@ -52,10 +53,27 @@ pub(super) async fn command_try_build( .await?; return Ok(()); } - } + Some(CommitSha(build.parent.clone())) + } else { + None + }; let base_sha = match parent.clone() { - Some(parent) => parent, + Some(parent) => match parent { + Parent::Last => match last_parent { + None => { + repo.client + .post_comment( + pr.number, + ":exclamation: There was no previous build. Please set an explicit parent or remove the parent option to use a default value.", + ) + .await?; + return Ok(()); + } + Some(last_parent) => last_parent, + }, + Parent::CommitSha(parent) => parent, + }, None => repo .client .get_branch_sha(&pr.base.name) @@ -69,14 +87,7 @@ pub(super) async fn command_try_build( repo.client .set_branch_to_sha(TRY_MERGE_BRANCH_NAME, &base_sha) .await - .map_err(|error| { - let base = if let Some(ref parent) = parent { - parent.0.as_str() - } else { - &pr.base.name - }; - anyhow!("Cannot set try merge branch to {base}: {error:?}") - })?; + .map_err(|error| anyhow!("Cannot set try merge branch to {}: {error:?}", base_sha.0))?; // Then merge the PR commit into the try branch match repo @@ -97,8 +108,13 @@ pub(super) async fn command_try_build( .await .map_err(|error| anyhow!("Cannot set try branch to main branch: {error:?}"))?; - db.attach_try_build(pr_model, TRY_BRANCH_NAME.to_string(), merge_sha.clone()) - .await?; + db.attach_try_build( + pr_model, + TRY_BRANCH_NAME.to_string(), + merge_sha.clone(), + base_sha.clone(), + ) + .await?; tracing::info!("Try build started"); handle_label_trigger(repo, pr.number, LabelTrigger::TryBuildStarted).await?; @@ -382,6 +398,50 @@ mod tests { ); } + #[tokio::test] + async fn test_try_merge_last_parent() { + let mut state = ClientBuilder::default().create_state().await; + + state + .comment("@bors try parent=ea9c1b050cc8b420c2c211d2177811e564a4dc60") + .await; + state.client().check_branch_history( + TRY_MERGE_BRANCH_NAME, + &[ + "ea9c1b050cc8b420c2c211d2177811e564a4dc60", + &default_merge_sha(), + ], + ); + state + .perform_workflow_events( + 1, + TRY_BRANCH_NAME, + &default_merge_sha(), + WorkflowStatus::Success, + ) + .await; + state.client().check_comment_count(default_pr_number(), 2); + state.comment("@bors try parent=last").await; + state.client().check_branch_history( + TRY_MERGE_BRANCH_NAME, + &[ + "ea9c1b050cc8b420c2c211d2177811e564a4dc60", + &default_merge_sha(), + ], + ); + } + + #[tokio::test] + async fn test_try_merge_last_parent_unknown() { + let mut state = ClientBuilder::default().create_state().await; + + state.comment("@bors try parent=last").await; + state.client().check_comments( + default_pr_number(), + &[":exclamation: There was no previous build. Please set an explicit parent or remove the parent option to use a default value."], + ); + } + #[tokio::test] async fn test_try_merge_conflict() { let mut state = ClientBuilder::default().create_state().await; diff --git a/src/database/mod.rs b/src/database/mod.rs index ff7cf4ba..e3762be6 100644 --- a/src/database/mod.rs +++ b/src/database/mod.rs @@ -33,11 +33,13 @@ pub enum BuildStatus { } /// Represents a single (merged) commit. +#[derive(Debug)] pub struct BuildModel { pub id: PrimaryKey, pub repository: String, pub branch: String, pub commit_sha: String, + pub parent: String, pub status: BuildStatus, pub created_at: DateTime, } @@ -105,6 +107,7 @@ pub trait DbClient { pr: PullRequestModel, branch: String, commit_sha: CommitSha, + parent: CommitSha, ) -> anyhow::Result<()>; /// Finds a build row by its repository, commit SHA and branch. diff --git a/src/database/sea_orm_client.rs b/src/database/sea_orm_client.rs index 3ee5937d..c63b22d6 100644 --- a/src/database/sea_orm_client.rs +++ b/src/database/sea_orm_client.rs @@ -89,11 +89,13 @@ impl DbClient for SeaORMClient { pr: PullRequestModel, branch: String, commit_sha: CommitSha, + parent: CommitSha, ) -> anyhow::Result<()> { let build = build::ActiveModel { repository: Set(pr.repository.clone()), branch: Set(branch), commit_sha: Set(commit_sha.0), + parent: Set(parent.0), status: Set(build_status_to_db(BuildStatus::Pending).to_string()), ..Default::default() }; @@ -291,6 +293,7 @@ fn build_from_db(model: build::Model) -> BuildModel { repository: model.repository, branch: model.branch, commit_sha: model.commit_sha, + parent: model.parent, status: build_status_from_db(model.status), created_at: datetime_from_db(model.created_at), } diff --git a/src/tests/state.rs b/src/tests/state.rs index 7b360211..d565bfbb 100644 --- a/src/tests/state.rs +++ b/src/tests/state.rs @@ -359,7 +359,16 @@ impl RepositoryClient for TestRepositoryClient { } async fn set_branch_to_sha(&mut self, branch: &str, sha: &CommitSha) -> anyhow::Result<()> { - self.add_branch_sha(branch, &sha.0); + let branch_history = self.branch_history.entry(branch.to_string()).or_default(); + let position = branch_history.iter().position(|s| s == sha); + match position { + None => branch_history.push(sha.clone()), + Some(p) => { + let (his, _) = branch_history.split_at(p + 1); + let his = his.to_vec(); + self.branch_history.insert(branch.to_string(), his); + } + } Ok(()) } From 8b2d27a6fb29cf9b496bc4ca7671e279cdd1b0e3 Mon Sep 17 00:00:00 2001 From: vohoanglong0107 Date: Fri, 15 Mar 2024 06:44:07 +0000 Subject: [PATCH 04/57] docs: document parent options --- src/bors/command/mod.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/bors/command/mod.rs b/src/bors/command/mod.rs index 6fd54e5c..0b77499e 100644 --- a/src/bors/command/mod.rs +++ b/src/bors/command/mod.rs @@ -2,9 +2,12 @@ mod parser; use crate::github::CommitSha; pub use parser::{CommandParseError, CommandParser}; +/// Type of parent allowed in a try build #[derive(Clone, Debug, PartialEq)] pub enum Parent { + /// Regular commit sha: parent="" CommitSha(CommitSha), + /// Use last build's parent: parent="last" Last, } From 2366d036081746657ecd27c8ee15c8f88c2fde30 Mon Sep 17 00:00:00 2001 From: vohoanglong0107 Date: Fri, 15 Mar 2024 06:44:50 +0000 Subject: [PATCH 05/57] fix: update error comment --- src/bors/handlers/trybuild.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bors/handlers/trybuild.rs b/src/bors/handlers/trybuild.rs index 6c621300..4d5a2590 100644 --- a/src/bors/handlers/trybuild.rs +++ b/src/bors/handlers/trybuild.rs @@ -65,7 +65,7 @@ pub(super) async fn command_try_build( repo.client .post_comment( pr.number, - ":exclamation: There was no previous build. Please set an explicit parent or remove the parent option to use a default value.", + ":exclamation: There was no previous build. Please set an explicit parent or remove the `parent=last` argument to use the default parent.", ) .await?; return Ok(()); @@ -438,7 +438,7 @@ mod tests { state.comment("@bors try parent=last").await; state.client().check_comments( default_pr_number(), - &[":exclamation: There was no previous build. Please set an explicit parent or remove the parent option to use a default value."], + &[":exclamation: There was no previous build. Please set an explicit parent or remove the `parent=last` argument to use the default parent."], ); } From ef0952ff37e30c6eab23dde02c1b4a7bfed178d8 Mon Sep 17 00:00:00 2001 From: vohoanglong0107 Date: Fri, 15 Mar 2024 06:45:17 +0000 Subject: [PATCH 06/57] test: remove unneeded test logic --- src/bors/handlers/trybuild.rs | 2 ++ src/tests/state.rs | 11 +---------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/bors/handlers/trybuild.rs b/src/bors/handlers/trybuild.rs index 4d5a2590..08866e57 100644 --- a/src/bors/handlers/trybuild.rs +++ b/src/bors/handlers/trybuild.rs @@ -427,6 +427,8 @@ mod tests { &[ "ea9c1b050cc8b420c2c211d2177811e564a4dc60", &default_merge_sha(), + "ea9c1b050cc8b420c2c211d2177811e564a4dc60", + &default_merge_sha(), ], ); } diff --git a/src/tests/state.rs b/src/tests/state.rs index d565bfbb..7b360211 100644 --- a/src/tests/state.rs +++ b/src/tests/state.rs @@ -359,16 +359,7 @@ impl RepositoryClient for TestRepositoryClient { } async fn set_branch_to_sha(&mut self, branch: &str, sha: &CommitSha) -> anyhow::Result<()> { - let branch_history = self.branch_history.entry(branch.to_string()).or_default(); - let position = branch_history.iter().position(|s| s == sha); - match position { - None => branch_history.push(sha.clone()), - Some(p) => { - let (his, _) = branch_history.split_at(p + 1); - let his = his.to_vec(); - self.branch_history.insert(branch.to_string(), his); - } - } + self.add_branch_sha(branch, &sha.0); Ok(()) } From cb79802c77d18352f91a017aafc851fbebed7b52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Fri, 15 Mar 2024 20:59:38 +0100 Subject: [PATCH 07/57] Update lockfile --- Cargo.lock | 1547 ++++++++++++++++++++++++++++------------------------ 1 file changed, 829 insertions(+), 718 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d96e82f7..d90e3e3a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,9 +10,9 @@ checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" [[package]] name = "addr2line" -version = "0.19.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" dependencies = [ "gimli", ] @@ -25,21 +25,54 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "ahash" -version = "0.7.6" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" dependencies = [ "getrandom", "once_cell", "version_check", ] +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "aho-corasick" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +dependencies = [ + "memchr", +] + [[package]] name = "aliasable" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "250f629c0161ad8107cf89319e990051fae62832fd343083bea452d93e2205fd" +[[package]] +name = "allocator-api2" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + [[package]] name = "android_system_properties" version = "0.1.5" @@ -49,23 +82,71 @@ dependencies = [ "libc", ] +[[package]] +name = "anstream" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" + +[[package]] +name = "anstyle-parse" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +dependencies = [ + "anstyle", + "windows-sys 0.52.0", +] + [[package]] name = "anyhow" -version = "1.0.69" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "224afbd727c3d6e4b90103ece64b8d1b67fbb1973b1046c2281eed3f3803f800" +checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" [[package]] name = "arc-swap" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6" +checksum = "7b3d0060af21e8d11a926981cc00c6c1541aa91dd64b9f881985c3da1094425f" [[package]] name = "arrayvec" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "async-stream" @@ -86,18 +167,18 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.52", ] [[package]] name = "async-trait" -version = "0.1.64" +version = "0.1.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd7fce9ba8c3c042128ce72d8b2ddbf3a05747efb67ea0313c635e10bda47a2" +checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.52", ] [[package]] @@ -117,13 +198,13 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "axum" -version = "0.6.4" +version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5694b64066a2459918d8074c2ce0d5a88f409431994c2356617c8ae0c4721fc" +checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" dependencies = [ "async-trait", "axum-core", - "bitflags", + "bitflags 1.3.2", "bytes", "futures-util", "http", @@ -143,16 +224,15 @@ dependencies = [ "sync_wrapper", "tokio", "tower", - "tower-http", "tower-layer", "tower-service", ] [[package]] name = "axum-core" -version = "0.3.2" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cae3e661676ffbacb30f1a824089a8c9150e71017f7e1e38f2aa32009188d34" +checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" dependencies = [ "async-trait", "bytes", @@ -167,9 +247,9 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.67" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" dependencies = [ "addr2line", "cc", @@ -207,15 +287,15 @@ checksum = "0ea22880d78093b0cbe17c89f64a7d457941e65759157ec6cb31a31d652b05e5" [[package]] name = "base64" -version = "0.21.0" +version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] name = "bigdecimal" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6aaf33151a6429fe9211d1b276eafdf70cdff28b071e76c0b0e1503221ea3744" +checksum = "a6773ddc0eafc0e509fb60e48dff7f450f8e674a0686ae8605e8d9901bd5eefa" dependencies = [ "num-bigint", "num-integer", @@ -228,11 +308,29 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + [[package]] name = "block-buffer" -version = "0.10.3" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ "generic-array", ] @@ -243,9 +341,9 @@ version = "0.1.0" dependencies = [ "anyhow", "axum", - "base64 0.21.0", + "base64 0.21.7", "chrono", - "clap 4.1.4", + "clap 4.5.3", "derive_builder", "entity", "futures", @@ -253,7 +351,7 @@ dependencies = [ "hmac", "hyper", "insta", - "itertools", + "itertools 0.10.5", "jsonwebtoken", "migration", "octocrab", @@ -266,7 +364,7 @@ dependencies = [ "sqlx", "thiserror", "tokio", - "toml 0.7.1", + "toml", "tower", "tracing", "tracing-subscriber", @@ -275,60 +373,39 @@ dependencies = [ [[package]] name = "borsh" -version = "0.10.3" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4114279215a005bc675e386011e594e1d9b800918cea18fcadadcce864a2046b" +checksum = "f58b559fd6448c6e2fd0adb5720cd98a2506594cafa4737ff98c396f3e82f667" dependencies = [ "borsh-derive", - "hashbrown", + "cfg_aliases", ] [[package]] name = "borsh-derive" -version = "0.10.3" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0754613691538d51f329cce9af41d7b7ca150bc973056f1156611489475f54f7" +checksum = "7aadb5b6ccbd078890f6d7003694e33816e6b784358f18e15e7e6d9f065a57cd" dependencies = [ - "borsh-derive-internal", - "borsh-schema-derive-internal", + "once_cell", "proc-macro-crate", - "proc-macro2", - "syn 1.0.109", -] - -[[package]] -name = "borsh-derive-internal" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afb438156919598d2c7bad7e1c0adf3d26ed3840dbc010db1a882a65583ca2fb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "borsh-schema-derive-internal" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634205cc43f74a1b9046ef87c4540ebda95696ec0f315024860cad7c5b0f5ccd" -dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.52", + "syn_derive", ] [[package]] name = "bumpalo" -version = "3.12.0" +version = "3.15.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" +checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" [[package]] name = "bytecheck" -version = "0.6.10" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13fe11640a23eb24562225322cd3e452b93a3d4091d62fab69c70542fcd17d1f" +checksum = "8b6372023ac861f6e6dc89c8344a8f398fb42aaba2b5dbc649ca0c0e9dbcb627" dependencies = [ "bytecheck_derive", "ptr_meta", @@ -337,9 +414,9 @@ dependencies = [ [[package]] name = "bytecheck_derive" -version = "0.6.10" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e31225543cb46f81a7e224762764f4a6a0f097b1db0b175f69e8065efaa42de5" +checksum = "3db406d29fbcd95542e92559bed4d8ad92636d1ca8b3b72ede10b4bcc010e659" dependencies = [ "proc-macro2", "quote", @@ -348,9 +425,9 @@ dependencies = [ [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" @@ -360,9 +437,9 @@ checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" [[package]] name = "cc" -version = "1.0.79" +version = "1.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" [[package]] name = "cfg-if" @@ -370,20 +447,25 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "cfg_aliases" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" + [[package]] name = "chrono" -version = "0.4.23" +version = "0.4.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" +checksum = "8eaf5903dcbc0a39312feb77df2ff4c76387d591b9fc7b04a238dcf8bb62639a" dependencies = [ + "android-tzdata", "iana-time-zone", "js-sys", - "num-integer", "num-traits", "serde", - "time 0.1.45", "wasm-bindgen", - "winapi", + "windows-targets 0.52.4", ] [[package]] @@ -392,27 +474,34 @@ version = "3.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" dependencies = [ - "bitflags", + "bitflags 1.3.2", "clap_derive 3.2.25", "clap_lex 0.2.4", - "indexmap", + "indexmap 1.9.3", "once_cell", "textwrap", ] [[package]] name = "clap" -version = "4.1.4" +version = "4.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f13b9c79b5d1dd500d20ef541215a6423c75829ef43117e1b4d17fd8af0b5d76" +checksum = "949626d00e063efc93b6dca932419ceb5432f99769911c0b995f7e884c778813" dependencies = [ - "bitflags", - "clap_derive 4.1.0", - "clap_lex 0.3.1", - "is-terminal", - "once_cell", - "strsim", - "termcolor", + "clap_builder", + "clap_derive 4.5.3", +] + +[[package]] +name = "clap_builder" +version = "4.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" +dependencies = [ + "anstream", + "anstyle", + "clap_lex 0.7.0", + "strsim 0.11.0", ] [[package]] @@ -430,15 +519,14 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.1.0" +version = "4.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "684a277d672e91966334af371f1a7b5833f9aa00b07c84e92fbce95e00208ce8" +checksum = "90239a040c80f5e14809ca132ddc4176ab33d5e17e49691793296e3fcb34d72f" dependencies = [ - "heck 0.4.1", - "proc-macro-error", + "heck 0.5.0", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.52", ] [[package]] @@ -452,40 +540,33 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.3.1" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "783fe232adfca04f90f56201b26d79682d4cd2625e0bc7290b95123afe558ade" -dependencies = [ - "os_str_bytes", -] +checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" [[package]] -name = "codespan-reporting" -version = "0.11.1" +name = "colorchoice" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" -dependencies = [ - "termcolor", - "unicode-width", -] +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "console" -version = "0.15.5" +version = "0.15.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d79fbe8970a77e3e34151cc13d3b3e248aa0faaecb9f6091fa07ebefe5ad60" +checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" dependencies = [ "encode_unicode", "lazy_static", "libc", - "windows-sys 0.42.0", + "windows-sys 0.52.0", ] [[package]] name = "core-foundation" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" dependencies = [ "core-foundation-sys", "libc", @@ -493,15 +574,15 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.3" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "cpufeatures" -version = "0.2.5" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" dependencies = [ "libc", ] @@ -517,28 +598,24 @@ dependencies = [ [[package]] name = "crc-catalog" -version = "2.2.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cace84e55f07e7301bae1c519df89cdad8cc3cd868413d3fdbdeca9ff3db484" +checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" [[package]] name = "crossbeam-queue" -version = "0.3.8" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add" +checksum = "df0346b5d5e76ac2fe4e327c5fd1118d6be7c51dfb18f9b7922923f287471e35" dependencies = [ - "cfg-if", "crossbeam-utils", ] [[package]] name = "crossbeam-utils" -version = "0.8.15" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" -dependencies = [ - "cfg-if", -] +checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" [[package]] name = "crypto-common" @@ -550,50 +627,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "cxx" -version = "1.0.89" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc831ee6a32dd495436e317595e639a587aa9907bef96fe6e6abc290ab6204e9" -dependencies = [ - "cc", - "cxxbridge-flags", - "cxxbridge-macro", - "link-cplusplus", -] - -[[package]] -name = "cxx-build" -version = "1.0.89" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94331d54f1b1a8895cd81049f7eaaaef9d05a7dcb4d1fd08bf3ff0806246789d" -dependencies = [ - "cc", - "codespan-reporting", - "once_cell", - "proc-macro2", - "quote", - "scratch", - "syn 1.0.109", -] - -[[package]] -name = "cxxbridge-flags" -version = "1.0.89" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48dcd35ba14ca9b40d6e4b4b39961f23d835dbb8eed74565ded361d93e1feb8a" - -[[package]] -name = "cxxbridge-macro" -version = "1.0.89" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81bbeb29798b407ccd82a3324ade1a7286e0d29851475990b612670f6f5124d2" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "darling" version = "0.14.4" @@ -614,7 +647,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim", + "strsim 0.10.0", "syn 1.0.109", ] @@ -629,6 +662,16 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", + "serde", +] + [[package]] name = "derive_builder" version = "0.12.0" @@ -662,9 +705,9 @@ dependencies = [ [[package]] name = "digest" -version = "0.10.6" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", "crypto-common", @@ -705,9 +748,9 @@ checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" [[package]] name = "either" -version = "1.8.1" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" +checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" [[package]] name = "encode_unicode" @@ -717,9 +760,9 @@ checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "encoding_rs" -version = "0.8.32" +version = "0.8.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394" +checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" dependencies = [ "cfg-if", ] @@ -732,24 +775,19 @@ dependencies = [ ] [[package]] -name = "errno" -version = "0.2.8" +name = "equivalent" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" -dependencies = [ - "errno-dragonfly", - "libc", - "winapi", -] +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] -name = "errno-dragonfly" -version = "0.1.2" +name = "errno" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ - "cc", "libc", + "windows-sys 0.52.0", ] [[package]] @@ -760,12 +798,15 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "fastrand" -version = "1.8.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" -dependencies = [ - "instant", -] +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" + +[[package]] +name = "finl_unicode" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fcfdc7a0362c9f4444381a9e697c79d435fe65b52a37466fc2c1184cee9edc6" [[package]] name = "flume" @@ -810,11 +851,17 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + [[package]] name = "futures" -version = "0.3.26" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e2792b0ff0340399d58445b88fd9770e3489eff258a4cbc1523418f12abf84" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" dependencies = [ "futures-channel", "futures-core", @@ -827,9 +874,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.26" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e5317663a9089767a1ec00a487df42e0ca174b61b4483213ac24448e4664df5" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ "futures-core", "futures-sink", @@ -837,15 +884,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.26" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec90ff4d0fe1f57d600049061dc6bb68ed03c7d2fbd697274c41805dcb3f8608" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" [[package]] name = "futures-executor" -version = "0.3.26" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8de0a35a6ab97ec8869e32a2473f4b1324459e14c29275d14b10cb1fd19b50e" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" dependencies = [ "futures-core", "futures-task", @@ -865,38 +912,38 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" [[package]] name = "futures-macro" -version = "0.3.26" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95a73af87da33b5acf53acfebdc339fe592ecf5357ac7c0a7734ab9d8c876a70" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.52", ] [[package]] name = "futures-sink" -version = "0.3.26" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f310820bb3e8cfd46c80db4d7fb8353e15dfff853a127158425f31e0be6c8364" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" [[package]] name = "futures-task" -version = "0.3.26" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf79a1bf610b10f42aea489289c5a2c478a786509693b80cd39c44ccd936366" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" [[package]] name = "futures-util" -version = "0.3.26" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c1d6de3acfef38d2be4b1f543f553131788603495be83da675e180c8d6b7bd1" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-channel", "futures-core", @@ -912,9 +959,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.6" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", @@ -922,26 +969,26 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.9" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" dependencies = [ "cfg-if", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", ] [[package]] name = "gimli" -version = "0.27.1" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "221996f774192f0f718773def8201c4ae31f02616a54ccfc2d358bb0e5cefdec" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "h2" -version = "0.3.15" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f9f29bc9dda355256b2916cf526ab02ce0aeaaaf2bad60d65ef3f12f11dd0f4" +checksum = "4fbd2820c5e49886948654ab546d0688ff24530286bdcf8fca3cefb16d4618eb" dependencies = [ "bytes", "fnv", @@ -949,7 +996,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap", + "indexmap 2.2.5", "slab", "tokio", "tokio-util", @@ -962,16 +1009,26 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash", + "ahash 0.7.8", +] + +[[package]] +name = "hashbrown" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +dependencies = [ + "ahash 0.8.11", + "allocator-api2", ] [[package]] name = "hashlink" -version = "0.8.1" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69fe1fcf8b4278d860ad0548329f892a3631fb63f82574df68275f34cdbe0ffa" +checksum = "e8094feaf31ff591f651a2664fb9cfd92bba7a60ce3197265e9482ebe753c8f7" dependencies = [ - "hashbrown", + "hashbrown 0.14.3", ] [[package]] @@ -993,19 +1050,16 @@ dependencies = [ ] [[package]] -name = "hermit-abi" -version = "0.2.6" +name = "heck" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" -dependencies = [ - "libc", -] +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hermit-abi" -version = "0.3.0" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "856b5cb0902c2b6d65d5fd97dfa30f9b70c7538e770b98eab5ed52d8db923e01" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "hex" @@ -1015,9 +1069,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hkdf" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "791a029f6b9fc27657f6f188ec6e5e43f6911f6f878e0dc5501396e09809d437" +checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" dependencies = [ "hmac", ] @@ -1033,9 +1087,9 @@ dependencies = [ [[package]] name = "http" -version = "0.2.8" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" dependencies = [ "bytes", "fnv", @@ -1044,21 +1098,15 @@ dependencies = [ [[package]] name = "http-body" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", "http", "pin-project-lite", ] -[[package]] -name = "http-range-header" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bfe8eed0a9285ef776bb792479ea3834e8b94e13d615c2f66d03dd50a435a29" - [[package]] name = "httparse" version = "1.8.0" @@ -1067,15 +1115,15 @@ checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" [[package]] name = "httpdate" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "0.14.24" +version = "0.14.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e011372fa0b68db8350aa7a248930ecc7839bf46d8485577d69f117a75f164c" +checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" dependencies = [ "bytes", "futures-channel", @@ -1126,26 +1174,25 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.53" +version = "0.1.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "winapi", + "windows-core", ] [[package]] name = "iana-time-zone-haiku" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" dependencies = [ - "cxx", - "cxx-build", + "cc", ] [[package]] @@ -1167,19 +1214,29 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.9.2" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.12.3", +] + +[[package]] +name = "indexmap" +version = "2.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" +dependencies = [ + "equivalent", + "hashbrown 0.14.3", ] [[package]] name = "insta" -version = "1.26.0" +version = "1.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f0f08b46e4379744de2ab67aa8f7de3ffd1da3e275adc41fcc82053ede46ff" +checksum = "0a7c22c4d34ef4788c351e971c52bfdfe7ea2766f8c5466bc175dd46e52ac22e" dependencies = [ "console", "lazy_static", @@ -1197,65 +1254,52 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "io-lifetimes" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1abeb7a0dd0f8181267ff8adc397075586500b81b28a73e8a0208b00fc170fb3" -dependencies = [ - "libc", - "windows-sys 0.45.0", -] - [[package]] name = "ipnet" -version = "2.7.1" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30e22bd8629359895450b59ea7a776c850561b96a3b1d31321c1949d9e6c9146" +checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] -name = "is-terminal" -version = "0.4.3" +name = "itertools" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22e18b0a45d56fe973d6db23972bf5bc46f988a4a2385deac9cc29572f09daef" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" dependencies = [ - "hermit-abi 0.3.0", - "io-lifetimes", - "rustix", - "windows-sys 0.45.0", + "either", ] [[package]] name = "itertools" -version = "0.10.5" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" dependencies = [ "either", ] [[package]] name = "itoa" -version = "1.0.5" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "js-sys" -version = "0.3.61" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" dependencies = [ "wasm-bindgen", ] [[package]] name = "jsonwebtoken" -version = "8.2.0" +version = "8.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09f4f04699947111ec1733e71778d763555737579e44b85844cae8e1940a1828" +checksum = "6971da4d9c3aa03c3d8f3ff0f4155b534aad021292003895a469716b2a230378" dependencies = [ - "base64 0.13.1", + "base64 0.21.7", "pem", "ring", "serde", @@ -1277,28 +1321,30 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.139" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] -name = "libsqlite3-sys" -version = "0.24.2" +name = "libredox" +version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "898745e570c7d0453cc1fbc4a701eb6c662ed54e8fec8b7d14be137ebeeb9d14" +checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" dependencies = [ - "cc", - "pkg-config", - "vcpkg", + "bitflags 2.4.2", + "libc", + "redox_syscall 0.4.1", ] [[package]] -name = "link-cplusplus" -version = "1.0.8" +name = "libsqlite3-sys" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" +checksum = "898745e570c7d0453cc1fbc4a701eb6c662ed54e8fec8b7d14be137ebeeb9d14" dependencies = [ "cc", + "pkg-config", + "vcpkg", ] [[package]] @@ -1309,15 +1355,15 @@ checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" [[package]] name = "linux-raw-sys" -version = "0.1.4" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" [[package]] name = "lock_api" -version = "0.4.9" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" dependencies = [ "autocfg", "scopeguard", @@ -1325,12 +1371,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.17" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "matchers" @@ -1338,7 +1381,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" dependencies = [ - "regex-automata", + "regex-automata 0.1.10", ] [[package]] @@ -1349,24 +1392,25 @@ checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" [[package]] name = "matchit" -version = "0.7.0" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b87248edafb776e59e6ee64a79086f65890d3510f2c656c000bf2a7e8a0aea40" +checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" [[package]] name = "md-5" -version = "0.10.5" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6365506850d44bff6e2fbcb5176cf63650e48bd45ef2fe2665ae1570e0f4b9ca" +checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" dependencies = [ + "cfg-if", "digest", ] [[package]] name = "memchr" -version = "2.5.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "migration" @@ -1378,9 +1422,9 @@ dependencies = [ [[package]] name = "mime" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "minimal-lexical" @@ -1390,23 +1434,22 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.6.2" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" +checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" dependencies = [ "adler", ] [[package]] name = "mio" -version = "0.8.5" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ "libc", - "log", - "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.42.0", + "wasi", + "windows-sys 0.48.0", ] [[package]] @@ -1428,22 +1471,13 @@ dependencies = [ ] [[package]] -name = "nom" -version = "7.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" -dependencies = [ - "memchr", - "minimal-lexical", -] - -[[package]] -name = "nom8" -version = "0.2.0" +name = "nom" +version = "7.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae01545c9c7fc4486ab7debaf2aad7003ac19431791868fb2e8066df97fad2f8" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" dependencies = [ "memchr", + "minimal-lexical", ] [[package]] @@ -1458,49 +1492,54 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" dependencies = [ "autocfg", "num-integer", "num-traits", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num-integer" -version = "0.1.45" +version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ - "autocfg", "num-traits", ] [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" dependencies = [ "autocfg", ] [[package]] name = "num_cpus" -version = "1.15.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.2.6", + "hermit-abi", "libc", ] [[package]] name = "object" -version = "0.30.3" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea86265d3d3dcb6a27fc51bd29a4bf387fae9d2986b823079d4986af253eb439" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" dependencies = [ "memchr", ] @@ -1532,17 +1571,17 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.17.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "openssl" -version = "0.10.45" +version = "0.10.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b102428fd03bc5edf97f62620f7298614c45cedf287c271e7ed450bbaf83f2e1" +checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" dependencies = [ - "bitflags", + "bitflags 2.4.2", "cfg-if", "foreign-types", "libc", @@ -1553,13 +1592,13 @@ dependencies = [ [[package]] name = "openssl-macros" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.52", ] [[package]] @@ -1570,11 +1609,10 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.80" +version = "0.9.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23bbbf7854cd45b83958ebe919f0e8e516793727652e27fda10a8384cfc790b7" +checksum = "dda2b0f344e78efc2facf7d195d098df0dd72151b26ab98da807afc26c198dff" dependencies = [ - "autocfg", "cc", "libc", "pkg-config", @@ -1583,9 +1621,9 @@ dependencies = [ [[package]] name = "os_str_bytes" -version = "6.4.1" +version = "6.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" +checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1" [[package]] name = "ouroboros" @@ -1634,7 +1672,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ "lock_api", - "parking_lot_core 0.9.7", + "parking_lot_core 0.9.9", ] [[package]] @@ -1646,29 +1684,29 @@ dependencies = [ "cfg-if", "instant", "libc", - "redox_syscall", + "redox_syscall 0.2.16", "smallvec", "winapi", ] [[package]] name = "parking_lot_core" -version = "0.9.7" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" +checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ "cfg-if", "libc", - "redox_syscall", + "redox_syscall 0.4.1", "smallvec", - "windows-sys 0.45.0", + "windows-targets 0.48.5", ] [[package]] name = "paste" -version = "1.0.12" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" [[package]] name = "pem" @@ -1687,29 +1725,29 @@ checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" [[package]] name = "pin-project" -version = "1.0.12" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad29a609b6bcd67fee905812e544992d216af9d755757c05ed2d0e15a74c6ecc" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.0.12" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.52", ] [[package]] name = "pin-project-lite" -version = "0.2.9" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" [[package]] name = "pin-utils" @@ -1719,9 +1757,15 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.26" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" + +[[package]] +name = "powerfmt" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" @@ -1731,11 +1775,11 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro-crate" -version = "0.1.5" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" dependencies = [ - "toml 0.5.11", + "toml_edit 0.21.1", ] [[package]] @@ -1764,9 +1808,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.56" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" dependencies = [ "unicode-ident", ] @@ -1793,13 +1837,19 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.26" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + [[package]] name = "rand" version = "0.8.5" @@ -1836,27 +1886,39 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags", + "bitflags 1.3.2", +] + +[[package]] +name = "redox_syscall" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +dependencies = [ + "bitflags 1.3.2", ] [[package]] name = "redox_users" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" dependencies = [ "getrandom", - "redox_syscall", + "libredox", "thiserror", ] [[package]] name = "regex" -version = "1.7.1" +version = "1.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" +checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" dependencies = [ - "regex-syntax", + "aho-corasick", + "memchr", + "regex-automata 0.4.6", + "regex-syntax 0.8.2", ] [[package]] @@ -1865,40 +1927,48 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" dependencies = [ - "regex-syntax", + "regex-syntax 0.6.29", +] + +[[package]] +name = "regex-automata" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.8.2", ] [[package]] name = "regex-syntax" -version = "0.6.28" +version = "0.6.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] -name = "remove_dir_all" -version = "0.5.3" +name = "regex-syntax" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi", -] +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "rend" -version = "0.4.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "581008d2099240d37fb08d77ad713bcaec2c4d89d50b5b21a8bb1996bbab68ab" +checksum = "71fe3824f5629716b1589be05dacd749f6aa084c87e00e016714a8cdfccc997c" dependencies = [ "bytecheck", ] [[package]] name = "reqwest" -version = "0.11.14" +version = "0.11.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21eed90ec8570952d53b772ecf8f206aa1ec9a3d76b2521c56c42973f2d91ee9" +checksum = "78bf93c4af7a8bb7d879d51cebe797356ff10ae8516ace542b5182d9dcac10b2" dependencies = [ - "base64 0.21.0", + "base64 0.21.7", "bytes", "encoding_rs", "futures-core", @@ -1916,9 +1986,12 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", + "rustls-pemfile", "serde", "serde_json", "serde_urlencoded", + "sync_wrapper", + "system-configuration", "tokio", "tokio-native-tls", "tower-service", @@ -1946,23 +2019,26 @@ dependencies = [ [[package]] name = "rkyv" -version = "0.7.41" +version = "0.7.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21499ed91807f07ae081880aabb2ccc0235e9d88011867d984525e9a4c3cfa3e" +checksum = "0200c8230b013893c0b2d6213d6ec64ed2b9be2e0e016682b7224ff82cff5c58" dependencies = [ + "bitvec", "bytecheck", - "hashbrown", + "hashbrown 0.12.3", "ptr_meta", "rend", "rkyv_derive", "seahash", + "tinyvec", + "uuid", ] [[package]] name = "rkyv_derive" -version = "0.7.41" +version = "0.7.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac1c672430eb41556291981f45ca900a0239ad007242d1cb4b4167af842db666" +checksum = "a7dddfff8de25e6f62b9d64e6e432bf1c6736c57d20323e15ee10435fbda7c65" dependencies = [ "proc-macro2", "quote", @@ -1971,14 +2047,12 @@ dependencies = [ [[package]] name = "rust_decimal" -version = "1.29.1" +version = "1.34.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26bd36b60561ee1fb5ec2817f198b6fd09fa571c897a5e86d1487cfc2b096dfc" +checksum = "b39449a79f45e8da28c57c341891b69a183044b29518bb8f86dbac9df60bb7df" dependencies = [ "arrayvec", "borsh", - "bytecheck", - "byteorder", "bytes", "num-traits", "rand", @@ -1989,56 +2063,58 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.21" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] name = "rustix" -version = "0.36.8" +version = "0.38.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43abb88211988493c1abb44a70efa56ff0ce98f233b7b276146f1f3f7ba9644" +checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" dependencies = [ - "bitflags", + "bitflags 2.4.2", "errno", - "io-lifetimes", "libc", "linux-raw-sys", - "windows-sys 0.45.0", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustls-pemfile" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +dependencies = [ + "base64 0.21.7", ] [[package]] name = "rustversion" -version = "1.0.11" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5583e89e108996506031660fe09baa5011b9dd0341b89029313006d1fb508d70" +checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" [[package]] name = "ryu" -version = "1.0.12" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" [[package]] name = "schannel" -version = "0.1.21" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3" +checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" dependencies = [ - "windows-sys 0.42.0", + "windows-sys 0.52.0", ] [[package]] name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - -[[package]] -name = "scratch" -version = "1.0.3" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddccb15bcce173023b3fedd9436f882a0739b8dfb45e4f6b6002bee5929f61b2" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "sea-orm" @@ -2062,7 +2138,7 @@ dependencies = [ "serde_json", "sqlx", "thiserror", - "time 0.3.17", + "time", "tracing", "url", "uuid", @@ -2116,24 +2192,24 @@ dependencies = [ [[package]] name = "sea-query" -version = "0.28.4" +version = "0.28.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dd34be05fdde9ec79231414bdd44ba1aa9c57349190076699e90721cb5eb59b" +checksum = "bbab99b8cd878ab7786157b7eb8df96333a6807cc6e45e8888c85b51534b401a" dependencies = [ "bigdecimal", "chrono", "rust_decimal", "sea-query-derive", "serde_json", - "time 0.3.17", + "time", "uuid", ] [[package]] name = "sea-query-binder" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03548c63aec07afd4fd190923e0160d2f2fc92def27470b54154cf232da6203b" +checksum = "4cea85029985b40dfbf18318d85fe985c04db7c1b4e5e8e0a0a0cdff5f1e30f9" dependencies = [ "bigdecimal", "chrono", @@ -2141,7 +2217,7 @@ dependencies = [ "sea-query", "serde_json", "sqlx", - "time 0.3.17", + "time", "uuid", ] @@ -2220,11 +2296,11 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.8.2" +version = "2.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a332be01508d814fed64bf28f798a146d73792121129962fdf335bb3c49a4254" +checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "core-foundation-sys", "libc", @@ -2233,9 +2309,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.8.0" +version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31c9bb296072e961fcbd8853511dd39c2d8be2deb1e17c6860b1d30732b323b4" +checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" dependencies = [ "core-foundation-sys", "libc", @@ -2243,29 +2319,29 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.152" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.152" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.52", ] [[package]] name = "serde_json" -version = "1.0.92" +version = "1.0.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7434af0dc1cbd59268aa98b4c22c131c0584d2232f6fb166efb993e2832e896a" +checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" dependencies = [ "itoa", "ryu", @@ -2274,18 +2350,19 @@ dependencies = [ [[package]] name = "serde_path_to_error" -version = "0.1.9" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b04f22b563c91331a10074bda3dd5492e3cc39d56bd557e91c0af42b6c7341" +checksum = "af99884400da37c88f5e9146b7f1fd0fbcae8f6eec4e9da38b67d05486f814a6" dependencies = [ + "itoa", "serde", ] [[package]] name = "serde_spanned" -version = "0.6.1" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0efd8caf556a6cebd3b285caf480045fcc1ac04f6bd786b09a6f11af30c4fcf4" +checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" dependencies = [ "serde", ] @@ -2304,9 +2381,9 @@ dependencies = [ [[package]] name = "sha1" -version = "0.10.5" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" dependencies = [ "cfg-if", "cpufeatures", @@ -2315,9 +2392,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.6" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", @@ -2326,18 +2403,18 @@ dependencies = [ [[package]] name = "sharded-slab" -version = "0.1.4" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" dependencies = [ "lazy_static", ] [[package]] name = "signal-hook-registry" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" dependencies = [ "libc", ] @@ -2350,9 +2427,9 @@ checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" [[package]] name = "similar" -version = "2.2.1" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "420acb44afdae038210c99e69aae24109f32f15500aa708e81d46c9f29d55fcf" +checksum = "32fea41aca09ee824cc9724996433064c89f7777e60762749a4170a14abbfa21" [[package]] name = "simple_asn1" @@ -2363,29 +2440,29 @@ dependencies = [ "num-bigint", "num-traits", "thiserror", - "time 0.3.17", + "time", ] [[package]] name = "slab" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" dependencies = [ "autocfg", ] [[package]] name = "smallvec" -version = "1.10.0" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" [[package]] name = "snafu" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0656e7e3ffb70f6c39b3c2a86332bb74aa3c679da781642590f3c1118c5045" +checksum = "e4de37ad025c587a29e8f3f5605c00f70b98715ef90b9061a815b9e59e9042d6" dependencies = [ "backtrace", "doc-comment", @@ -2394,9 +2471,9 @@ dependencies = [ [[package]] name = "snafu-derive" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "475b3bbe5245c26f2d8a6f62d67c1f30eb9fffeccee721c45d162c3ebbdf81b2" +checksum = "990079665f075b699031e9c08fd3ab99be5029b96f3b78dc0709e8f77e4efebf" dependencies = [ "heck 0.4.1", "proc-macro2", @@ -2406,12 +2483,12 @@ dependencies = [ [[package]] name = "socket2" -version = "0.4.9" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" +checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871" dependencies = [ "libc", - "winapi", + "windows-sys 0.52.0", ] [[package]] @@ -2431,11 +2508,11 @@ dependencies = [ [[package]] name = "sqlformat" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c12bc9199d1db8234678b7051747c07f517cdcf019262d1847b94ec8b1aee3e" +checksum = "ce81b7bd7c4493975347ef60d8c7e8b742d4694f4c49f93e0a12ea263938176c" dependencies = [ - "itertools", + "itertools 0.12.1", "nom", "unicode_categories", ] @@ -2456,11 +2533,11 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa8241483a83a3f33aa5fff7e7d9def398ff9990b2752b6c6112b83c6d246029" dependencies = [ - "ahash", + "ahash 0.7.8", "atoi", "base64 0.13.1", "bigdecimal", - "bitflags", + "bitflags 1.3.2", "byteorder", "bytes", "chrono", @@ -2480,7 +2557,7 @@ dependencies = [ "hex", "hkdf", "hmac", - "indexmap", + "indexmap 1.9.3", "itoa", "libc", "libsqlite3-sys", @@ -2502,7 +2579,7 @@ dependencies = [ "sqlx-rt", "stringprep", "thiserror", - "time 0.3.17", + "time", "tokio-stream", "url", "uuid", @@ -2543,10 +2620,11 @@ dependencies = [ [[package]] name = "stringprep" -version = "0.1.2" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ee348cb74b87454fff4b551cbf727025810a004f88aeacae7f85b87f4e9a1c1" +checksum = "bb41d74e231a107a1b4ee36bd1214b11285b77768d2e3824aedafa988fd36ee6" dependencies = [ + "finl_unicode", "unicode-bidi", "unicode-normalization", ] @@ -2557,11 +2635,17 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "strsim" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" + [[package]] name = "subtle" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "syn" @@ -2576,15 +2660,27 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.15" +version = "2.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" +checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] +[[package]] +name = "syn_derive" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1329189c02ff984e9736652b1631330da25eaa6bc639089ed4915d25446cbe7b" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.52", +] + [[package]] name = "sync_wrapper" version = "0.1.2" @@ -2592,59 +2688,75 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" [[package]] -name = "tempfile" -version = "3.3.0" +name = "system-configuration" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ - "cfg-if", - "fastrand", + "bitflags 1.3.2", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", "libc", - "redox_syscall", - "remove_dir_all", - "winapi", ] [[package]] -name = "termcolor" -version = "1.2.0" +name = "tap" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "tempfile" +version = "3.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" dependencies = [ - "winapi-util", + "cfg-if", + "fastrand", + "rustix", + "windows-sys 0.52.0", ] [[package]] name = "textwrap" -version = "0.16.0" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" +checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" [[package]] name = "thiserror" -version = "1.0.38" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" +checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.38" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" +checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.52", ] [[package]] name = "thread_local" -version = "1.1.7" +version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" dependencies = [ "cfg-if", "once_cell", @@ -2652,22 +2764,14 @@ dependencies = [ [[package]] name = "time" -version = "0.1.45" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" -dependencies = [ - "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi", -] - -[[package]] -name = "time" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a561bf4617eebd33bca6434b988f39ed798e527f51a1e797d0ee4f61c0a38376" +checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" dependencies = [ + "deranged", "itoa", + "num-conv", + "powerfmt", "serde", "time-core", "time-macros", @@ -2675,16 +2779,17 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.0" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.6" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d967f99f534ca7e495c575c62638eebc2898a8c84c119b89e250477bc4ba16b2" +checksum = "7ba3a3ef41e6672a2f0f001392bb5dcd3ff0a9992d618ca761a11c3121547774" dependencies = [ + "num-conv", "time-core", ] @@ -2705,11 +2810,11 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.28.0" +version = "1.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c786bf8134e5a3a166db9b29ab8f48134739014a3eca7bc6bfa95d673b136f" +checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" dependencies = [ - "autocfg", + "backtrace", "bytes", "libc", "mio", @@ -2724,20 +2829,20 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" +checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.52", ] [[package]] name = "tokio-native-tls" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" dependencies = [ "native-tls", "tokio", @@ -2745,9 +2850,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.14" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" +checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" dependencies = [ "futures-core", "pin-project-lite", @@ -2756,9 +2861,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.4" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bb2e075f03b3d66d8d8785356224ba688d2906a371015e225beeb65ca92c740" +checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" dependencies = [ "bytes", "futures-core", @@ -2770,45 +2875,47 @@ dependencies = [ [[package]] name = "toml" -version = "0.5.11" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257" dependencies = [ "serde", + "serde_spanned", + "toml_datetime", + "toml_edit 0.19.15", ] [[package]] -name = "toml" -version = "0.7.1" +name = "toml_datetime" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "772c1426ab886e7362aedf4abc9c0d1348a979517efedfc25862944d10137af0" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" dependencies = [ "serde", - "serde_spanned", - "toml_datetime", - "toml_edit", ] [[package]] -name = "toml_datetime" -version = "0.6.1" +name = "toml_edit" +version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ + "indexmap 2.2.5", "serde", + "serde_spanned", + "toml_datetime", + "winnow", ] [[package]] name = "toml_edit" -version = "0.19.1" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90a238ee2e6ede22fb95350acc78e21dc40da00bb66c0334bde83de4ed89424e" +checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ - "indexmap", - "nom8", - "serde", - "serde_spanned", + "indexmap 2.2.5", "toml_datetime", + "winnow", ] [[package]] @@ -2828,25 +2935,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "tower-http" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f873044bf02dd1e8239e9c1293ea39dad76dc594ec16185d0a1bf31d8dc8d858" -dependencies = [ - "bitflags", - "bytes", - "futures-core", - "futures-util", - "http", - "http-body", - "http-range-header", - "pin-project-lite", - "tower", - "tower-layer", - "tower-service", -] - [[package]] name = "tower-layer" version = "0.3.2" @@ -2861,11 +2949,10 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" -version = "0.1.37" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ - "cfg-if", "log", "pin-project-lite", "tracing-attributes", @@ -2874,20 +2961,20 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.24" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.52", ] [[package]] name = "tracing-core" -version = "0.1.30" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", "valuable", @@ -2895,20 +2982,20 @@ dependencies = [ [[package]] name = "tracing-log" -version = "0.1.3" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" dependencies = [ - "lazy_static", "log", + "once_cell", "tracing-core", ] [[package]] name = "tracing-subscriber" -version = "0.3.17" +version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" dependencies = [ "matchers", "nu-ansi-term", @@ -2924,15 +3011,15 @@ dependencies = [ [[package]] name = "try-lock" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "typenum" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unicase" @@ -2945,36 +3032,30 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.10" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54675592c1dbefd78cbd98db9bacd89886e1ca50692a0692baefffdeb92dd58" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-ident" -version = "1.0.6" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" dependencies = [ "tinyvec", ] [[package]] name = "unicode-segmentation" -version = "1.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" - -[[package]] -name = "unicode-width" -version = "0.1.10" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode_categories" @@ -3000,11 +3081,17 @@ dependencies = [ "serde", ] +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + [[package]] name = "uuid" -version = "1.3.2" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dad5567ad0cf5b760e5665964bec1b47dfd077ba8a2544b513f3556d3d239a2" +checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a" dependencies = [ "serde", ] @@ -3029,31 +3116,30 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "want" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" dependencies = [ - "log", "try-lock", ] [[package]] name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" +version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" +name = "wasite" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" [[package]] name = "wasm-bindgen" -version = "0.2.84" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -3061,24 +3147,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.84" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.52", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.34" +version = "0.4.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f219e0d211ba40266969f6dbdd90636da12f75bee4fc9d6c23d1260dadb51454" +checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" dependencies = [ "cfg-if", "js-sys", @@ -3088,9 +3174,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.84" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3098,28 +3184,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.84" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.52", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.84" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "web-sys" -version = "0.3.61" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97" +checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" dependencies = [ "js-sys", "wasm-bindgen", @@ -3127,11 +3213,12 @@ dependencies = [ [[package]] name = "whoami" -version = "1.4.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c70234412ca409cc04e864e89523cb0fc37f5e1344ebed5a3ebf4192b6b9f68" +checksum = "a44ab49fad634e88f55bf8f9bb3abd2f27d7204172a112c7c9987e01c1c94ea9" dependencies = [ - "wasm-bindgen", + "redox_syscall 0.4.1", + "wasite", "web-sys", ] @@ -3151,15 +3238,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -[[package]] -name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi", -] - [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" @@ -3167,159 +3245,172 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] -name = "windows-sys" -version = "0.42.0" +name = "windows-core" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows_aarch64_gnullvm 0.42.1", - "windows_aarch64_msvc 0.42.1", - "windows_i686_gnu 0.42.1", - "windows_i686_msvc 0.42.1", - "windows_x86_64_gnu 0.42.1", - "windows_x86_64_gnullvm 0.42.1", - "windows_x86_64_msvc 0.42.1", + "windows-targets 0.52.4", ] [[package]] name = "windows-sys" -version = "0.45.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets 0.42.1", + "windows-targets 0.48.5", ] [[package]] name = "windows-sys" -version = "0.48.0" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.48.0", + "windows-targets 0.52.4", ] [[package]] name = "windows-targets" -version = "0.42.1" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm 0.42.1", - "windows_aarch64_msvc 0.42.1", - "windows_i686_gnu 0.42.1", - "windows_i686_msvc 0.42.1", - "windows_x86_64_gnu 0.42.1", - "windows_x86_64_gnullvm 0.42.1", - "windows_x86_64_msvc 0.42.1", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] name = "windows-targets" -version = "0.48.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" dependencies = [ - "windows_aarch64_gnullvm 0.48.0", - "windows_aarch64_msvc 0.48.0", - "windows_i686_gnu 0.48.0", - "windows_i686_msvc 0.48.0", - "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm 0.48.0", - "windows_x86_64_msvc 0.48.0", + "windows_aarch64_gnullvm 0.52.4", + "windows_aarch64_msvc 0.52.4", + "windows_i686_gnu 0.52.4", + "windows_i686_msvc 0.52.4", + "windows_x86_64_gnu 0.52.4", + "windows_x86_64_gnullvm 0.52.4", + "windows_x86_64_msvc 0.52.4", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.1" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" [[package]] name = "windows_aarch64_msvc" -version = "0.42.1" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.48.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" [[package]] name = "windows_i686_gnu" -version = "0.42.1" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.48.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" [[package]] name = "windows_i686_msvc" -version = "0.42.1" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.48.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" [[package]] name = "windows_x86_64_gnu" -version = "0.42.1" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.48.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.1" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" [[package]] name = "windows_x86_64_msvc" -version = "0.42.1" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.48.0" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" + +[[package]] +name = "winnow" +version = "0.5.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" +dependencies = [ + "memchr", +] [[package]] name = "winreg" -version = "0.10.1" +version = "0.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" dependencies = [ - "winapi", + "cfg-if", + "windows-sys 0.48.0", +] + +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", ] [[package]] @@ -3331,8 +3422,28 @@ dependencies = [ "linked-hash-map", ] +[[package]] +name = "zerocopy" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", +] + [[package]] name = "zeroize" -version = "1.5.7" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c394b5bd0c6f669e7275d9c20aa90ae064cb22e75a1cad54e1b34088034b149f" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" From e34fe3b2f1c33b784570f97e11aed33c7b8e138a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Fri, 15 Mar 2024 21:02:18 +0100 Subject: [PATCH 08/57] Update `derive_builder` --- Cargo.lock | 32 ++++++++++++++++---------------- Cargo.toml | 4 ++-- src/tests/state.rs | 2 +- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d90e3e3a..0dc91111 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -629,9 +629,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.14.4" +version = "0.20.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" +checksum = "54e36fcd13ed84ffdfda6f5be89b31287cbb80c439841fe69e04841435464391" dependencies = [ "darling_core", "darling_macro", @@ -639,27 +639,27 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.14.4" +version = "0.20.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" +checksum = "9c2cf1c23a687a1feeb728783b993c4e1ad83d99f351801977dd809b48d0a70f" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", "strsim 0.10.0", - "syn 1.0.109", + "syn 2.0.52", ] [[package]] name = "darling_macro" -version = "0.14.4" +version = "0.20.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" +checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" dependencies = [ "darling_core", "quote", - "syn 1.0.109", + "syn 2.0.52", ] [[package]] @@ -674,33 +674,33 @@ dependencies = [ [[package]] name = "derive_builder" -version = "0.12.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d67778784b508018359cbc8696edb3db78160bab2c2a28ba7f56ef6932997f8" +checksum = "0350b5cb0331628a5916d6c5c0b72e97393b8b6b03b47a9284f4e7f5a405ffd7" dependencies = [ "derive_builder_macro", ] [[package]] name = "derive_builder_core" -version = "0.12.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c11bdc11a0c47bc7d37d582b5285da6849c96681023680b906673c5707af7b0f" +checksum = "d48cda787f839151732d396ac69e3473923d54312c070ee21e9effcaa8ca0b1d" dependencies = [ "darling", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.52", ] [[package]] name = "derive_builder_macro" -version = "0.12.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebcda35c7a396850a55ffeac740804b40ffec779b98fffbb1738f4033f0ee79e" +checksum = "206868b8242f27cecce124c19fd88157fbd0dd334df2587f36417bafbc85097b" dependencies = [ "derive_builder_core", - "syn 1.0.109", + "syn 2.0.52", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 2b61c942..c4390422 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,7 +51,7 @@ secrecy = "0.8" base64 = "0.21" # Database -sqlx = { version = "0.6", features = [ "runtime-tokio-native-tls" , "sqlite", "postgres" ] } +sqlx = { version = "0.6", features = ["runtime-tokio-native-tls", "sqlite", "postgres"] } sea-orm = { workspace = true } # Time @@ -65,4 +65,4 @@ migration = { path = "database/migration" } [dev-dependencies] insta = "1.26" -derive_builder = "0.12" +derive_builder = "0.20.0" diff --git a/src/tests/state.rs b/src/tests/state.rs index 7b360211..3846bdc4 100644 --- a/src/tests/state.rs +++ b/src/tests/state.rs @@ -159,7 +159,7 @@ impl BorsState for TestBorsState { pub struct RepoConfig { #[builder(default = "Duration::from_secs(3600)")] timeout: Duration, - #[builder(field(type = "HashMap>"))] + #[builder(field(ty = "HashMap>"))] labels: HashMap>, } From e0b3019d2bc084b55c8b37e07998d38fc0ba1c2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Fri, 15 Mar 2024 21:04:15 +0100 Subject: [PATCH 09/57] Update `base64` --- Cargo.lock | 52 +++++++++++++++++++++++++++++----------------------- Cargo.toml | 6 +++--- 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0dc91111..8e990440 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -291,6 +291,12 @@ version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +[[package]] +name = "base64" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" + [[package]] name = "bigdecimal" version = "0.3.1" @@ -341,7 +347,7 @@ version = "0.1.0" dependencies = [ "anyhow", "axum", - "base64 0.21.7", + "base64 0.22.0", "chrono", "clap 4.5.3", "derive_builder", @@ -351,7 +357,7 @@ dependencies = [ "hmac", "hyper", "insta", - "itertools 0.10.5", + "itertools", "jsonwebtoken", "migration", "octocrab", @@ -1260,15 +1266,6 @@ version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" -[[package]] -name = "itertools" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" -dependencies = [ - "either", -] - [[package]] name = "itertools" version = "0.12.1" @@ -2512,7 +2509,7 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce81b7bd7c4493975347ef60d8c7e8b742d4694f4c49f93e0a12ea263938176c" dependencies = [ - "itertools 0.12.1", + "itertools", "nom", "unicode_categories", ] @@ -2875,14 +2872,14 @@ dependencies = [ [[package]] name = "toml" -version = "0.7.8" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257" +checksum = "af06656561d28735e9c1cd63dfd57132c8155426aa6af24f36a00a351f88c48e" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.19.15", + "toml_edit 0.22.7", ] [[package]] @@ -2896,26 +2893,26 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.19.15" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" +checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ "indexmap 2.2.5", - "serde", - "serde_spanned", "toml_datetime", - "winnow", + "winnow 0.5.40", ] [[package]] name = "toml_edit" -version = "0.21.1" +version = "0.22.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" +checksum = "18769cd1cec395d70860ceb4d932812a0b4d06b1a4bb336745a4d21b9496e992" dependencies = [ "indexmap 2.2.5", + "serde", + "serde_spanned", "toml_datetime", - "winnow", + "winnow 0.6.5", ] [[package]] @@ -3394,6 +3391,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "winnow" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dffa400e67ed5a4dd237983829e66475f0a4a26938c4b04c21baede6262215b8" +dependencies = [ + "memchr", +] + [[package]] name = "winreg" version = "0.50.0" diff --git a/Cargo.toml b/Cargo.toml index c4390422..7b234748 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,7 @@ thiserror = "1.0" # Serialization serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -toml = "0.7" +toml = "0.8" # GitHub octocrab = "0.18" @@ -48,7 +48,7 @@ sha2 = "0.10" hmac = "0.12" hex = "0.4" secrecy = "0.8" -base64 = "0.21" +base64 = "0.22.0" # Database sqlx = { version = "0.6", features = ["runtime-tokio-native-tls", "sqlite", "postgres"] } @@ -57,7 +57,7 @@ sea-orm = { workspace = true } # Time chrono = "0.4" -itertools = "0.10" +itertools = "0.12.1" # Local entity = { path = "database/entity" } From 62066da1f158141ca2fb4e60a38fcdaaa6fed8eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Fri, 15 Mar 2024 21:15:21 +0100 Subject: [PATCH 10/57] Update hyper and axum --- Cargo.lock | 139 +++++++++++++++++++++++++++++++++++------- Cargo.toml | 4 +- src/bin/bors.rs | 7 ++- src/github/webhook.rs | 32 +++++----- 4 files changed, 137 insertions(+), 45 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8e990440..cc40a6cd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -198,18 +198,19 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "axum" -version = "0.6.20" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" +checksum = "1236b4b292f6c4d6dc34604bb5120d85c3fe1d1aa596bd5cc52ca054d13e7b9e" dependencies = [ "async-trait", "axum-core", - "bitflags 1.3.2", "bytes", "futures-util", - "http", - "http-body", - "hyper", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", + "hyper 1.2.0", + "hyper-util", "itoa", "matchit", "memchr", @@ -226,23 +227,28 @@ dependencies = [ "tower", "tower-layer", "tower-service", + "tracing", ] [[package]] name = "axum-core" -version = "0.3.4" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" +checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3" dependencies = [ "async-trait", "bytes", "futures-util", - "http", - "http-body", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", "mime", + "pin-project-lite", "rustversion", + "sync_wrapper", "tower-layer", "tower-service", + "tracing", ] [[package]] @@ -355,7 +361,7 @@ dependencies = [ "futures", "hex", "hmac", - "hyper", + "hyper 1.2.0", "insta", "itertools", "jsonwebtoken", @@ -1001,7 +1007,26 @@ dependencies = [ "futures-core", "futures-sink", "futures-util", - "http", + "http 0.2.12", + "indexmap 2.2.5", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "h2" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51ee2dd2e4f378392eeff5d51618cd9a63166a2513846bbc55f21cfacd9199d4" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http 1.1.0", "indexmap 2.2.5", "slab", "tokio", @@ -1102,6 +1127,17 @@ dependencies = [ "itoa", ] +[[package]] +name = "http" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + [[package]] name = "http-body" version = "0.4.6" @@ -1109,7 +1145,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", - "http", + "http 0.2.12", + "pin-project-lite", +] + +[[package]] +name = "http-body" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" +dependencies = [ + "bytes", + "http 1.1.0", +] + +[[package]] +name = "http-body-util" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0475f8b2ac86659c21b64320d5d653f9efe42acd2a4e560073ec61a155a34f1d" +dependencies = [ + "bytes", + "futures-core", + "http 1.1.0", + "http-body 1.0.0", "pin-project-lite", ] @@ -1135,9 +1194,9 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2", - "http", - "http-body", + "h2 0.3.25", + "http 0.2.12", + "http-body 0.4.6", "httparse", "httpdate", "itoa", @@ -1149,6 +1208,26 @@ dependencies = [ "want", ] +[[package]] +name = "hyper" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "186548d73ac615b32a73aafe38fb4f56c0d340e110e5a200bcadbaf2e199263a" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "h2 0.4.3", + "http 1.1.0", + "http-body 1.0.0", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", +] + [[package]] name = "hyper-tls" version = "0.5.0" @@ -1156,12 +1235,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" dependencies = [ "bytes", - "hyper", + "hyper 0.14.28", "native-tls", "tokio", "tokio-native-tls", ] +[[package]] +name = "hyper-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa" +dependencies = [ + "bytes", + "futures-util", + "http 1.1.0", + "http-body 1.0.0", + "hyper 1.2.0", + "pin-project-lite", + "socket2", + "tokio", +] + [[package]] name = "hyperx" version = "1.4.0" @@ -1170,7 +1265,7 @@ checksum = "5617e92fc2f2501c3e2bc6ce547cad841adba2bae5b921c7e52510beca6d084c" dependencies = [ "base64 0.13.1", "bytes", - "http", + "http 0.2.12", "httpdate", "language-tags", "mime", @@ -1970,10 +2065,10 @@ dependencies = [ "encoding_rs", "futures-core", "futures-util", - "h2", - "http", - "http-body", - "hyper", + "h2 0.3.25", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.28", "hyper-tls", "ipnet", "js-sys", diff --git a/Cargo.toml b/Cargo.toml index 7b234748..1df90832 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,8 +36,8 @@ tokio = { version = "1.21", features = ["full"] } futures = "0.3" # Web -hyper = "0.14" -axum = "0.6" +hyper = "1.2.0" +axum = "0.7.4" tower = { version = "0.4", features = ["limit"] } jsonwebtoken = "8.2" url = "2.3" diff --git a/src/bin/bors.rs b/src/bin/bors.rs index a6e28cef..7a8b8b0e 100644 --- a/src/bin/bors.rs +++ b/src/bin/bors.rs @@ -53,10 +53,11 @@ async fn server(state: ServerState) -> anyhow::Result<()> { .layer(ConcurrencyLimitLayer::new(100)) .with_state(state); let addr = SocketAddr::from(([0, 0, 0, 0], 8080)); + let listener = tokio::net::TcpListener::bind(addr) + .await + .context("Cannot create TCP/IP server socket")?; - axum::Server::bind(&addr) - .serve(app.into_make_service()) - .await?; + axum::serve(listener, app.into_make_service()).await?; Ok(()) } diff --git a/src/github/webhook.rs b/src/github/webhook.rs index 87967ab3..0fe662bc 100644 --- a/src/github/webhook.rs +++ b/src/github/webhook.rs @@ -1,10 +1,10 @@ //! This module handles parsing webhooks and generating [`BorsEvent`]s from them. use std::fmt::Debug; -use axum::body::{Bytes, HttpBody}; +use axum::body::Bytes; use axum::extract::FromRequest; use axum::http::request::Parts; -use axum::http::{HeaderMap, HeaderValue, Request, StatusCode}; +use axum::http::{HeaderMap, HeaderValue, StatusCode}; use axum::{async_trait, RequestExt}; use hmac::{Hmac, Mac}; use octocrab::models::events::payload::{ @@ -93,30 +93,26 @@ pub struct WebhookPullRequestReviewEvent<'a> { #[derive(Debug)] pub struct GitHubWebhook(pub BorsEvent); +const REQUEST_BODY_LIMIT: usize = 10 * 1024 * 1024; + /// Extracts a webhook event from a HTTP request. #[async_trait] -impl FromRequest for GitHubWebhook -where - B: HttpBody + Send + Debug + 'static, - B::Data: Send, - B::Error: std::error::Error + Send + Sync + 'static, -{ +impl FromRequest for GitHubWebhook { type Rejection = StatusCode; async fn from_request( - request: Request, + request: axum::extract::Request, state: &ServerStateRef, ) -> Result { - let (parts, body) = request - .with_limited_body() - .expect("There should be a body size limit") - .into_parts(); + let (parts, body) = request.with_limited_body().into_parts(); // Eagerly load body - let body: Bytes = hyper::body::to_bytes(body).await.map_err(|error| { - tracing::error!("Parsing webhook body failed: {error:?}"); - StatusCode::BAD_REQUEST - })?; + let body: Bytes = axum::body::to_bytes(body, REQUEST_BODY_LIMIT) + .await + .map_err(|error| { + tracing::error!("Parsing webhook body failed: {error:?}"); + StatusCode::BAD_REQUEST + })?; // Verify that the request is valid if !verify_gh_signature(&parts.headers, &body, state.get_webhook_secret()) { @@ -621,7 +617,7 @@ mod tests { let hash = hex::encode(hash); let signature = format!("sha256={hash}"); - let mut request = Request::new(body.clone()); + let mut request = Request::new(axum::body::Body::from(body)); *request.method_mut() = Method::POST; let headers = request.headers_mut(); headers.insert("content-type", HeaderValue::from_static("application-json")); From 0b396fc8c2f89c13a413344dba2fd5d5b9321a29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Fri, 15 Mar 2024 21:16:29 +0100 Subject: [PATCH 11/57] Use `tokio` from workspace in the `migration` crate --- Cargo.toml | 3 ++- database/migration/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1df90832..8c24d873 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,7 @@ members = [".", "database/entity", "database/migration"] [workspace.dependencies] sea-orm = { version = "^0" } +tokio = { version = "1.21", features = ["full"] } [dependencies] # CLI @@ -32,8 +33,8 @@ toml = "0.8" octocrab = "0.18" # Async -tokio = { version = "1.21", features = ["full"] } futures = "0.3" +tokio = { workspace = true } # Web hyper = "1.2.0" diff --git a/database/migration/Cargo.toml b/database/migration/Cargo.toml index 742d9ee4..21639673 100644 --- a/database/migration/Cargo.toml +++ b/database/migration/Cargo.toml @@ -10,4 +10,4 @@ path = "src/lib.rs" [dependencies] sea-orm-migration = { version = "0.11.0", features = [ "runtime-tokio-native-tls", "sqlx-sqlite", "sqlx-postgres" ] } -tokio = { version = "1.28", features = ["macros"] } +tokio = { workspace = true } From 1d8b3c470d0c6d7fed6dd18f2ca067923944827d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Fri, 15 Mar 2024 21:43:39 +0100 Subject: [PATCH 12/57] Update `octocrab`, sqlx` and `SeaORM` --- Cargo.lock | 953 +++++++++++++++++++++------------- Cargo.toml | 11 +- database/migration/Cargo.toml | 2 +- src/bors/handlers/mod.rs | 2 +- src/github/api/client.rs | 67 +-- src/github/api/mod.rs | 7 + src/github/api/operations.rs | 15 +- src/github/webhook.rs | 6 +- 8 files changed, 662 insertions(+), 401 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cc40a6cd..ac1ae77c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,12 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "Inflector" -version = "0.11.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" - [[package]] name = "addr2line" version = "0.21.0" @@ -41,6 +35,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if", + "getrandom", "once_cell", "version_check", "zerocopy", @@ -183,9 +178,9 @@ dependencies = [ [[package]] name = "atoi" -version = "1.0.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7c57d12312ff59c811c0643f4d80830505833c9ffaebd193d819392b265be8e" +checksum = "f28d99ec8bfea296261ca1af174f24225171fea9664ba9003cbebee704810528" dependencies = [ "num-traits", ] @@ -266,31 +261,6 @@ dependencies = [ "rustc-demangle", ] -[[package]] -name = "bae" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33b8de67cc41132507eeece2584804efcb15f85ba516e34c944b7667f480397a" -dependencies = [ - "heck 0.3.3", - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "base64" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" - -[[package]] -name = "base64" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ea22880d78093b0cbe17c89f64a7d457941e65759157ec6cb31a31d652b05e5" - [[package]] name = "base64" version = "0.21.7" @@ -303,6 +273,12 @@ version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + [[package]] name = "bigdecimal" version = "0.3.1" @@ -325,6 +301,9 @@ name = "bitflags" version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +dependencies = [ + "serde", +] [[package]] name = "bitvec" @@ -355,12 +334,13 @@ dependencies = [ "axum", "base64 0.22.0", "chrono", - "clap 4.5.3", + "clap", "derive_builder", "entity", "futures", "hex", "hmac", + "http 1.1.0", "hyper 1.2.0", "insta", "itertools", @@ -480,20 +460,6 @@ dependencies = [ "windows-targets 0.52.4", ] -[[package]] -name = "clap" -version = "3.2.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" -dependencies = [ - "bitflags 1.3.2", - "clap_derive 3.2.25", - "clap_lex 0.2.4", - "indexmap 1.9.3", - "once_cell", - "textwrap", -] - [[package]] name = "clap" version = "4.5.3" @@ -501,7 +467,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "949626d00e063efc93b6dca932419ceb5432f99769911c0b995f7e884c778813" dependencies = [ "clap_builder", - "clap_derive 4.5.3", + "clap_derive", ] [[package]] @@ -512,23 +478,10 @@ checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" dependencies = [ "anstream", "anstyle", - "clap_lex 0.7.0", + "clap_lex", "strsim 0.11.0", ] -[[package]] -name = "clap_derive" -version = "3.2.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae6371b8bdc8b7d3959e9cf7b22d4435ef3e79e138688421ec654acf8c81b008" -dependencies = [ - "heck 0.4.1", - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "clap_derive" version = "4.5.3" @@ -541,15 +494,6 @@ dependencies = [ "syn 2.0.52", ] -[[package]] -name = "clap_lex" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" -dependencies = [ - "os_str_bytes", -] - [[package]] name = "clap_lex" version = "0.7.0" @@ -574,6 +518,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + [[package]] name = "core-foundation" version = "0.9.4" @@ -674,6 +624,17 @@ dependencies = [ "syn 2.0.52", ] +[[package]] +name = "der" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" +dependencies = [ + "const-oid", + "pem-rfc7468", + "zeroize", +] + [[package]] name = "deranged" version = "0.3.11" @@ -684,6 +645,17 @@ dependencies = [ "serde", ] +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "derive_builder" version = "0.20.0" @@ -722,36 +694,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", + "const-oid", "crypto-common", "subtle", ] -[[package]] -name = "dirs" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" -dependencies = [ - "dirs-sys", -] - -[[package]] -name = "dirs-sys" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" -dependencies = [ - "libc", - "redox_users", - "winapi", -] - -[[package]] -name = "doc-comment" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" - [[package]] name = "dotenvy" version = "0.15.7" @@ -763,6 +710,9 @@ name = "either" version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" +dependencies = [ + "serde", +] [[package]] name = "encode_unicode" @@ -802,6 +752,17 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "etcetera" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "136d1b5283a1ab77bd9257427ffd09d8667ced0570b6f938942bc7568ed5b943" +dependencies = [ + "cfg-if", + "home", + "windows-sys 0.48.0", +] + [[package]] name = "event-listener" version = "2.5.3" @@ -822,13 +783,12 @@ checksum = "8fcfdc7a0362c9f4444381a9e697c79d435fe65b52a37466fc2c1184cee9edc6" [[package]] name = "flume" -version = "0.10.14" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1657b4441c3403d9f7b3409e47575237dac27b1b5726df654a6ecbf92f0f7577" +checksum = "55ac459de2512911e4b674ce33cf20befaba382d05b62b008afc1c8b57cbf181" dependencies = [ "futures-core", "futures-sink", - "pin-project", "spin 0.9.8", ] @@ -913,13 +873,13 @@ dependencies = [ [[package]] name = "futures-intrusive" -version = "0.4.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a604f7a68fbf8103337523b1fadc8ade7361ee3f112f7c680ad179651616aed5" +checksum = "1d930c203dd0b6ff06e0201a4a2fe9149b43c684fd4420555b26d21b1a02956f" dependencies = [ "futures-core", "lock_api", - "parking_lot 0.11.2", + "parking_lot", ] [[package]] @@ -986,8 +946,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" dependencies = [ "cfg-if", + "js-sys", "libc", "wasi", + "wasm-bindgen", ] [[package]] @@ -996,6 +958,12 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + [[package]] name = "h2" version = "0.3.25" @@ -1008,7 +976,7 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.12", - "indexmap 2.2.5", + "indexmap", "slab", "tokio", "tokio-util", @@ -1027,7 +995,7 @@ dependencies = [ "futures-sink", "futures-util", "http 1.1.0", - "indexmap 2.2.5", + "indexmap", "slab", "tokio", "tokio-util", @@ -1062,15 +1030,6 @@ dependencies = [ "hashbrown 0.14.3", ] -[[package]] -name = "heck" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" -dependencies = [ - "unicode-segmentation", -] - [[package]] name = "heck" version = "0.4.1" @@ -1116,6 +1075,15 @@ dependencies = [ "digest", ] +[[package]] +name = "home" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +dependencies = [ + "windows-sys 0.52.0", +] + [[package]] name = "http" version = "0.2.12" @@ -1226,6 +1194,39 @@ dependencies = [ "pin-project-lite", "smallvec", "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0bea761b46ae2b24eb4aef630d8d1c398157b6fc29e6350ecf090a0b70c952c" +dependencies = [ + "futures-util", + "http 1.1.0", + "hyper 1.2.0", + "hyper-util", + "log", + "rustls", + "rustls-native-certs", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "tower-service", +] + +[[package]] +name = "hyper-timeout" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3203a961e5c83b6f5498933e78b6b263e208c197b63e9c6c53cc82ffd3f63793" +dependencies = [ + "hyper 1.2.0", + "hyper-util", + "pin-project-lite", + "tokio", + "tower-service", ] [[package]] @@ -1248,6 +1249,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa" dependencies = [ "bytes", + "futures-channel", "futures-util", "http 1.1.0", "http-body 1.0.0", @@ -1255,22 +1257,9 @@ dependencies = [ "pin-project-lite", "socket2", "tokio", -] - -[[package]] -name = "hyperx" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5617e92fc2f2501c3e2bc6ce547cad841adba2bae5b921c7e52510beca6d084c" -dependencies = [ - "base64 0.13.1", - "bytes", - "http 0.2.12", - "httpdate", - "language-tags", - "mime", - "percent-encoding", - "unicase", + "tower", + "tower-service", + "tracing", ] [[package]] @@ -1315,22 +1304,23 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.9.3" +version = "2.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" dependencies = [ - "autocfg", - "hashbrown 0.12.3", + "equivalent", + "hashbrown 0.14.3", ] [[package]] -name = "indexmap" -version = "2.2.5" +name = "inherent" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" +checksum = "0122b7114117e64a63ac49f752a5ca4624d534c7b1c7de796ac196381cd2d947" dependencies = [ - "equivalent", - "hashbrown 0.14.3", + "proc-macro2", + "quote", + "syn 2.0.52", ] [[package]] @@ -1346,21 +1336,22 @@ dependencies = [ "yaml-rust", ] -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", -] - [[package]] name = "ipnet" version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" +[[package]] +name = "iri-string" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21859b667d66a4c1dacd9df0863b3efb65785474255face87f5bca39dd8407c0" +dependencies = [ + "memchr", + "serde", +] + [[package]] name = "itertools" version = "0.12.1" @@ -1387,11 +1378,12 @@ dependencies = [ [[package]] name = "jsonwebtoken" -version = "8.3.0" +version = "9.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6971da4d9c3aa03c3d8f3ff0f4155b534aad021292003895a469716b2a230378" +checksum = "5c7ea04a7c5c055c175f189b6dc6ba036fd62306b58c66c9f6389036c503a3f4" dependencies = [ "base64 0.21.7", + "js-sys", "pem", "ring", "serde", @@ -1399,17 +1391,14 @@ dependencies = [ "simple_asn1", ] -[[package]] -name = "language-tags" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4345964bb142484797b161f473a503a434de77149dd8c7427788c6e13379388" - [[package]] name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +dependencies = [ + "spin 0.5.2", +] [[package]] name = "libc" @@ -1418,21 +1407,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] -name = "libredox" -version = "0.0.1" +name = "libm" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" -dependencies = [ - "bitflags 2.4.2", - "libc", - "redox_syscall 0.4.1", -] +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "libsqlite3-sys" -version = "0.24.2" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "898745e570c7d0453cc1fbc4a701eb6c662ed54e8fec8b7d14be137ebeeb9d14" +checksum = "cf4e226dcd58b4be396f7bd3c20da8fdee2911400705297ba7d2d7cc2c30f716" dependencies = [ "cc", "pkg-config", @@ -1593,6 +1577,23 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-bigint-dig" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc84195820f291c7697304f3cbdadd1cb7199c0efc917ff5eafd71225c136151" +dependencies = [ + "byteorder", + "lazy_static", + "libm", + "num-integer", + "num-iter", + "num-traits", + "rand", + "smallvec", + "zeroize", +] + [[package]] name = "num-conv" version = "0.1.0" @@ -1608,6 +1609,17 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-iter" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d869c01cc0c455284163fd0092f1f93835385ccab5a98a0dcc497b2f8bf055a9" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.18" @@ -1615,6 +1627,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" dependencies = [ "autocfg", + "libm", ] [[package]] @@ -1638,26 +1651,40 @@ dependencies = [ [[package]] name = "octocrab" -version = "0.18.1" +version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55f21c2c98d2c7556e4bbacac59eb3d7449ef6a9b0f14d3aa348f692f4e851f6" +checksum = "a6d07f2ea5f11065486c5d66e7fa592833038377c8b55c0b8694a624732fee32" dependencies = [ "arc-swap", "async-trait", - "base64 0.20.0", + "base64 0.22.0", "bytes", "cfg-if", "chrono", "either", - "hyperx", + "futures", + "futures-util", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", + "hyper 1.2.0", + "hyper-rustls", + "hyper-timeout", + "hyper-util", "jsonwebtoken", "once_cell", - "reqwest", + "percent-encoding", + "pin-project", "secrecy", "serde", "serde_json", "serde_path_to_error", + "serde_urlencoded", "snafu", + "tokio", + "tower", + "tower-http", + "tracing", "url", ] @@ -1712,32 +1739,36 @@ dependencies = [ ] [[package]] -name = "os_str_bytes" -version = "6.6.1" +name = "ordered-float" +version = "3.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1" +checksum = "f1e1c390732d15f1d48471625cd92d154e66db2c56645e29a9cd26f4699f72dc" +dependencies = [ + "num-traits", +] [[package]] name = "ouroboros" -version = "0.15.6" +version = "0.17.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1358bd1558bd2a083fed428ffeda486fbfb323e698cdda7794259d592ca72db" +checksum = "e2ba07320d39dfea882faa70554b4bd342a5f273ed59ba7c1c6b4c840492c954" dependencies = [ "aliasable", "ouroboros_macro", + "static_assertions", ] [[package]] name = "ouroboros_macro" -version = "0.15.6" +version = "0.17.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f7d21ccd03305a674437ee1248f3ab5d4b1db095cf1caf49f1713ddf61956b7" +checksum = "ec4c6225c69b4ca778c0aea097321a64c421cf4577b331c61b229267edabb6f8" dependencies = [ - "Inflector", + "heck 0.4.1", "proc-macro-error", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.52", ] [[package]] @@ -1746,17 +1777,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" -[[package]] -name = "parking_lot" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" -dependencies = [ - "instant", - "lock_api", - "parking_lot_core 0.8.6", -] - [[package]] name = "parking_lot" version = "0.12.1" @@ -1764,32 +1784,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ "lock_api", - "parking_lot_core 0.9.9", + "parking_lot_core", ] [[package]] name = "parking_lot_core" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" -dependencies = [ - "cfg-if", - "instant", - "libc", - "redox_syscall 0.2.16", - "smallvec", - "winapi", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.9" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.4.1", + "redox_syscall", "smallvec", "windows-targets 0.48.5", ] @@ -1802,18 +1808,28 @@ checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" [[package]] name = "pem" -version = "1.1.1" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8835c273a76a90455d7344889b0964598e3316e2a79ede8e36f16bdcf2228b8" +checksum = "1b8fcc794035347fb64beda2d3b462595dd2753e3f268d89c5aae77e8cf2c310" dependencies = [ - "base64 0.13.1", + "base64 0.21.7", + "serde", +] + +[[package]] +name = "pem-rfc7468" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +dependencies = [ + "base64ct", ] [[package]] name = "percent-encoding" -version = "2.1.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project" @@ -1847,6 +1863,27 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkcs1" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" +dependencies = [ + "der", + "pkcs8", + "spki", +] + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + [[package]] name = "pkg-config" version = "0.3.30" @@ -1972,15 +2009,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "redox_syscall" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "redox_syscall" version = "0.4.1" @@ -1990,17 +2018,6 @@ dependencies = [ "bitflags 1.3.2", ] -[[package]] -name = "redox_users" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" -dependencies = [ - "getrandom", - "libredox", - "thiserror", -] - [[package]] name = "regex" version = "1.10.3" @@ -2078,7 +2095,7 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls-pemfile", + "rustls-pemfile 1.0.4", "serde", "serde_json", "serde_urlencoded", @@ -2096,17 +2113,17 @@ dependencies = [ [[package]] name = "ring" -version = "0.16.20" +version = "0.17.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" dependencies = [ "cc", + "cfg-if", + "getrandom", "libc", - "once_cell", - "spin 0.5.2", + "spin 0.9.8", "untrusted", - "web-sys", - "winapi", + "windows-sys 0.52.0", ] [[package]] @@ -2137,6 +2154,26 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "rsa" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0e5124fcb30e76a7e79bfee683a2746db83784b86289f6251b54b7950a0dfc" +dependencies = [ + "const-oid", + "digest", + "num-bigint-dig", + "num-integer", + "num-traits", + "pkcs1", + "pkcs8", + "rand_core", + "signature", + "spki", + "subtle", + "zeroize", +] + [[package]] name = "rust_decimal" version = "1.34.3" @@ -2172,6 +2209,33 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "rustls" +version = "0.22.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e87c9956bd9807afa1f77e0f7594af32566e830e088a5576d27c5b6f30f49d41" +dependencies = [ + "log", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-native-certs" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f1fb85efa936c42c6d5fc28d2629bb51e4b2f4b8a5211e297d599cc5a093792" +dependencies = [ + "openssl-probe", + "rustls-pemfile 2.1.1", + "rustls-pki-types", + "schannel", + "security-framework", +] + [[package]] name = "rustls-pemfile" version = "1.0.4" @@ -2181,6 +2245,33 @@ dependencies = [ "base64 0.21.7", ] +[[package]] +name = "rustls-pemfile" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f48172685e6ff52a556baa527774f61fcaa884f59daf3375c62a3f1cd2549dab" +dependencies = [ + "base64 0.21.7", + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ede67b28608b4c60685c7d54122d4400d90f62b40caee7700e700380a390fa8" + +[[package]] +name = "rustls-webpki" +version = "0.102.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faaa0a62740bedb9b2ef5afa303da42764c012f743917351dc9a237ea1663610" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + [[package]] name = "rustversion" version = "1.0.14" @@ -2208,11 +2299,24 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "sea-bae" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bd3534a9978d0aa7edd2808dc1f8f31c4d0ecd31ddf71d997b3c98e9f3c9114" +dependencies = [ + "heck 0.4.1", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.52", +] + [[package]] name = "sea-orm" -version = "0.11.3" +version = "0.12.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fade86e8d41fd1a4721f84cb834f4ca2783f973cc30e6212b7fafc134f169214" +checksum = "6632f499b80cc6aaa781b302e4c9fae663e0e3dcf2640e9d80034d5b10731efe" dependencies = [ "async-stream", "async-trait", @@ -2225,10 +2329,10 @@ dependencies = [ "sea-orm-macros", "sea-query", "sea-query-binder", - "sea-strum", "serde", "serde_json", "sqlx", + "strum", "thiserror", "time", "tracing", @@ -2238,13 +2342,14 @@ dependencies = [ [[package]] name = "sea-orm-cli" -version = "0.11.3" +version = "0.12.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efbf34a2caf70c2e3be9bb1e674e9540f6dfd7c8f40f6f05daf3b9740e476005" +checksum = "465ea2308d4716837e9af4a2cff8e14c28135867a580bb93e9e03d408a3a6afb" dependencies = [ "chrono", - "clap 3.2.25", + "clap", "dotenvy", + "glob", "regex", "sea-schema", "tracing", @@ -2254,25 +2359,26 @@ dependencies = [ [[package]] name = "sea-orm-macros" -version = "0.11.3" +version = "0.12.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28936f26d62234ff0be16f80115dbdeb3237fe9c25cf18fbcd1e3b3592360f20" +checksum = "ec13bfb4c4aef208f68dbea970dd40d13830c868aa8dcb4e106b956e6bb4f2fa" dependencies = [ - "bae", - "heck 0.3.3", + "heck 0.4.1", "proc-macro2", "quote", - "syn 1.0.109", + "sea-bae", + "syn 2.0.52", + "unicode-ident", ] [[package]] name = "sea-orm-migration" -version = "0.11.3" +version = "0.12.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "278d3adfd0832b6ffc17d3cfbc574d3695a5c1b38814e0bc8ac238d33f3d87cf" +checksum = "ac734b6e5610c2764056cc8495fbc293cd1c8ebe084fdfb74c3b0cdaaff9bb92" dependencies = [ "async-trait", - "clap 3.2.25", + "clap", "dotenvy", "futures", "sea-orm", @@ -2284,12 +2390,15 @@ dependencies = [ [[package]] name = "sea-query" -version = "0.28.5" +version = "0.30.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbab99b8cd878ab7786157b7eb8df96333a6807cc6e45e8888c85b51534b401a" +checksum = "4166a1e072292d46dc91f31617c2a1cdaf55a8be4b5c9f4bf2ba248e3ac4999b" dependencies = [ "bigdecimal", "chrono", + "derivative", + "inherent", + "ordered-float", "rust_decimal", "sea-query-derive", "serde_json", @@ -2299,9 +2408,9 @@ dependencies = [ [[package]] name = "sea-query-binder" -version = "0.3.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cea85029985b40dfbf18318d85fe985c04db7c1b4e5e8e0a0a0cdff5f1e30f9" +checksum = "36bbb68df92e820e4d5aeb17b4acd5cc8b5d18b2c36a4dd6f4626aabfa7ab1b9" dependencies = [ "bigdecimal", "chrono", @@ -2315,22 +2424,22 @@ dependencies = [ [[package]] name = "sea-query-derive" -version = "0.3.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63f62030c60f3a691f5fe251713b4e220b306e50a71e1d6f9cce1f24bb781978" +checksum = "25a82fcb49253abcb45cdcb2adf92956060ec0928635eb21b4f7a6d8f25ab0bc" dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.52", "thiserror", ] [[package]] name = "sea-schema" -version = "0.11.0" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eeb2940bb5a10bc6cd05b450ce6cd3993e27fddd7eface2becb97fc5af3a040e" +checksum = "30d148608012d25222442d1ebbfafd1228dbc5221baf4ec35596494e27a2394e" dependencies = [ "futures", "sea-query", @@ -2339,35 +2448,13 @@ dependencies = [ [[package]] name = "sea-schema-derive" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56821b7076f5096b8f726e2791ad255a99c82498e08ec477a65a96c461ff1927" -dependencies = [ - "heck 0.3.3", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "sea-strum" -version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "391d06a6007842cfe79ac6f7f53911b76dfd69fc9a6769f1cf6569d12ce20e1b" -dependencies = [ - "sea-strum_macros", -] - -[[package]] -name = "sea-strum_macros" -version = "0.23.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69b4397b825df6ccf1e98bcdabef3bbcfc47ff5853983467850eeab878384f21" +checksum = "c6f686050f76bffc4f635cda8aea6df5548666b830b52387e8bc7de11056d11e" dependencies = [ - "heck 0.3.3", + "heck 0.4.1", "proc-macro2", "quote", - "rustversion", "syn 1.0.109", ] @@ -2511,6 +2598,16 @@ dependencies = [ "libc", ] +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "digest", + "rand_core", +] + [[package]] name = "simdutf8" version = "0.1.4" @@ -2552,25 +2649,23 @@ checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" [[package]] name = "snafu" -version = "0.7.5" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4de37ad025c587a29e8f3f5605c00f70b98715ef90b9061a815b9e59e9042d6" +checksum = "75976f4748ab44f6e5332102be424e7c2dc18daeaf7e725f2040c3ebb133512e" dependencies = [ - "backtrace", - "doc-comment", "snafu-derive", ] [[package]] name = "snafu-derive" -version = "0.7.5" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "990079665f075b699031e9c08fd3ab99be5029b96f3b78dc0709e8f77e4efebf" +checksum = "b4b19911debfb8c2fb1107bc6cb2d61868aaf53a988449213959bb1b5b1ed95f" dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.52", ] [[package]] @@ -2598,6 +2693,16 @@ dependencies = [ "lock_api", ] +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", +] + [[package]] name = "sqlformat" version = "0.2.3" @@ -2611,105 +2716,224 @@ dependencies = [ [[package]] name = "sqlx" -version = "0.6.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8de3b03a925878ed54a954f621e64bf55a3c1bd29652d0d1a17830405350188" +checksum = "c9a2ccff1a000a5a59cd33da541d9f2fdcd9e6e8229cc200565942bff36d0aaa" dependencies = [ "sqlx-core", "sqlx-macros", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", ] [[package]] name = "sqlx-core" -version = "0.6.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa8241483a83a3f33aa5fff7e7d9def398ff9990b2752b6c6112b83c6d246029" +checksum = "24ba59a9342a3d9bab6c56c118be528b27c9b60e490080e9711a04dccac83ef6" dependencies = [ - "ahash 0.7.8", + "ahash 0.8.11", "atoi", - "base64 0.13.1", "bigdecimal", - "bitflags 1.3.2", "byteorder", "bytes", "chrono", "crc", "crossbeam-queue", - "dirs", - "dotenvy", "either", "event-listener", - "flume", "futures-channel", "futures-core", - "futures-executor", "futures-intrusive", + "futures-io", "futures-util", "hashlink", "hex", - "hkdf", - "hmac", - "indexmap 1.9.3", - "itoa", - "libc", - "libsqlite3-sys", + "indexmap", "log", - "md-5", "memchr", - "num-bigint", + "native-tls", "once_cell", "paste", "percent-encoding", - "rand", "rust_decimal", "serde", "serde_json", - "sha1", "sha2", "smallvec", "sqlformat", - "sqlx-rt", - "stringprep", "thiserror", "time", + "tokio", "tokio-stream", + "tracing", "url", "uuid", - "whoami", ] [[package]] name = "sqlx-macros" -version = "0.6.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9966e64ae989e7e575b19d7265cb79d7fc3cbbdf179835cb0d716f294c2049c9" +checksum = "4ea40e2345eb2faa9e1e5e326db8c34711317d2b5e08d0d5741619048a803127" +dependencies = [ + "proc-macro2", + "quote", + "sqlx-core", + "sqlx-macros-core", + "syn 1.0.109", +] + +[[package]] +name = "sqlx-macros-core" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5833ef53aaa16d860e92123292f1f6a3d53c34ba8b1969f152ef1a7bb803f3c8" dependencies = [ "dotenvy", "either", "heck 0.4.1", + "hex", "once_cell", "proc-macro2", "quote", + "serde", "serde_json", "sha2", "sqlx-core", - "sqlx-rt", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", "syn 1.0.109", + "tempfile", + "tokio", "url", ] [[package]] -name = "sqlx-rt" -version = "0.6.3" +name = "sqlx-mysql" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "804d3f245f894e61b1e6263c84b23ca675d96753b5abfd5cc8597d86806e8024" +checksum = "1ed31390216d20e538e447a7a9b959e06ed9fc51c37b514b46eb758016ecd418" dependencies = [ - "native-tls", + "atoi", + "base64 0.21.7", + "bigdecimal", + "bitflags 2.4.2", + "byteorder", + "bytes", + "chrono", + "crc", + "digest", + "dotenvy", + "either", + "futures-channel", + "futures-core", + "futures-io", + "futures-util", + "generic-array", + "hex", + "hkdf", + "hmac", + "itoa", + "log", + "md-5", + "memchr", "once_cell", - "tokio", - "tokio-native-tls", + "percent-encoding", + "rand", + "rsa", + "rust_decimal", + "serde", + "sha1", + "sha2", + "smallvec", + "sqlx-core", + "stringprep", + "thiserror", + "time", + "tracing", + "uuid", + "whoami", ] +[[package]] +name = "sqlx-postgres" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c824eb80b894f926f89a0b9da0c7f435d27cdd35b8c655b114e58223918577e" +dependencies = [ + "atoi", + "base64 0.21.7", + "bigdecimal", + "bitflags 2.4.2", + "byteorder", + "chrono", + "crc", + "dotenvy", + "etcetera", + "futures-channel", + "futures-core", + "futures-io", + "futures-util", + "hex", + "hkdf", + "hmac", + "home", + "itoa", + "log", + "md-5", + "memchr", + "num-bigint", + "once_cell", + "rand", + "rust_decimal", + "serde", + "serde_json", + "sha2", + "smallvec", + "sqlx-core", + "stringprep", + "thiserror", + "time", + "tracing", + "uuid", + "whoami", +] + +[[package]] +name = "sqlx-sqlite" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b244ef0a8414da0bed4bb1910426e890b19e5e9bccc27ada6b797d05c55ae0aa" +dependencies = [ + "atoi", + "chrono", + "flume", + "futures-channel", + "futures-core", + "futures-executor", + "futures-intrusive", + "futures-util", + "libsqlite3-sys", + "log", + "percent-encoding", + "serde", + "sqlx-core", + "time", + "tracing", + "url", + "urlencoding", + "uuid", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + [[package]] name = "stringprep" version = "0.1.4" @@ -2733,6 +2957,12 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" +[[package]] +name = "strum" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" + [[package]] name = "subtle" version = "2.5.0" @@ -2818,12 +3048,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "textwrap" -version = "0.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" - [[package]] name = "thiserror" version = "1.0.58" @@ -2911,7 +3135,7 @@ dependencies = [ "libc", "mio", "num_cpus", - "parking_lot 0.12.1", + "parking_lot", "pin-project-lite", "signal-hook-registry", "socket2", @@ -2940,6 +3164,17 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-rustls" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" +dependencies = [ + "rustls", + "rustls-pki-types", + "tokio", +] + [[package]] name = "tokio-stream" version = "0.1.15" @@ -2992,7 +3227,7 @@ version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ - "indexmap 2.2.5", + "indexmap", "toml_datetime", "winnow 0.5.40", ] @@ -3003,7 +3238,7 @@ version = "0.22.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "18769cd1cec395d70860ceb4d932812a0b4d06b1a4bb336745a4d21b9496e992" dependencies = [ - "indexmap 2.2.5", + "indexmap", "serde", "serde_spanned", "toml_datetime", @@ -3027,6 +3262,26 @@ dependencies = [ "tracing", ] +[[package]] +name = "tower-http" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5" +dependencies = [ + "bitflags 2.4.2", + "bytes", + "futures-util", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", + "iri-string", + "pin-project-lite", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + [[package]] name = "tower-layer" version = "0.3.2" @@ -3113,15 +3368,6 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" -[[package]] -name = "unicase" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" -dependencies = [ - "version_check", -] - [[package]] name = "unicode-bidi" version = "0.3.15" @@ -3157,9 +3403,9 @@ checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" [[package]] name = "untrusted" -version = "0.7.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" @@ -3173,6 +3419,12 @@ dependencies = [ "serde", ] +[[package]] +name = "urlencoding" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" + [[package]] name = "utf8parse" version = "0.2.1" @@ -3309,9 +3561,8 @@ version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a44ab49fad634e88f55bf8f9bb3abd2f27d7204172a112c7c9987e01c1c94ea9" dependencies = [ - "redox_syscall 0.4.1", + "redox_syscall", "wasite", - "web-sys", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 8c24d873..0fc01f94 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" members = [".", "database/entity", "database/migration"] [workspace.dependencies] -sea-orm = { version = "^0" } +sea-orm = { version = "0.12.14" } tokio = { version = "1.21", features = ["full"] } [dependencies] @@ -30,7 +30,7 @@ serde_json = "1.0" toml = "0.8" # GitHub -octocrab = "0.18" +octocrab = "0.35.0" # Async futures = "0.3" @@ -40,9 +40,10 @@ tokio = { workspace = true } hyper = "1.2.0" axum = "0.7.4" tower = { version = "0.4", features = ["limit"] } -jsonwebtoken = "8.2" +jsonwebtoken = "9.2.0" url = "2.3" -reqwest = "0.11" +reqwest = { version = "0.11", features = ["json"] } +http = "1.1.0" # Cryptography sha2 = "0.10" @@ -52,7 +53,7 @@ secrecy = "0.8" base64 = "0.22.0" # Database -sqlx = { version = "0.6", features = ["runtime-tokio-native-tls", "sqlite", "postgres"] } +sqlx = { version = "0.7.4", features = ["runtime-tokio-native-tls", "sqlite", "postgres"] } sea-orm = { workspace = true } # Time diff --git a/database/migration/Cargo.toml b/database/migration/Cargo.toml index 21639673..84d43f6a 100644 --- a/database/migration/Cargo.toml +++ b/database/migration/Cargo.toml @@ -9,5 +9,5 @@ name = "migration" path = "src/lib.rs" [dependencies] -sea-orm-migration = { version = "0.11.0", features = [ "runtime-tokio-native-tls", "sqlx-sqlite", "sqlx-postgres" ] } +sea-orm-migration = { version = "0.12.14", features = ["runtime-tokio-native-tls", "sqlx-sqlite", "sqlx-postgres"] } tokio = { workspace = true } diff --git a/src/bors/handlers/mod.rs b/src/bors/handlers/mod.rs index e1f38e7a..495630d2 100644 --- a/src/bors/handlers/mod.rs +++ b/src/bors/handlers/mod.rs @@ -243,7 +243,7 @@ mod tests { #[tokio::test] async fn test_do_not_comment_when_pr_fetch_fails() { let mut state = ClientBuilder::default().create_state().await; - state.client().get_pr_fn = Box::new(|pr| Err(anyhow::anyhow!("Foo"))); + state.client().get_pr_fn = Box::new(|_| Err(anyhow::anyhow!("Foo"))); state.comment(comment("foo").create()).await; state.client().check_comments(default_pr_number(), &[]); } diff --git a/src/github/api/client.rs b/src/github/api/client.rs index 51dcc00a..aa151260 100644 --- a/src/github/api/client.rs +++ b/src/github/api/client.rs @@ -5,6 +5,7 @@ use octocrab::{Error, Octocrab}; use tracing::log; use crate::bors::{CheckSuite, CheckSuiteStatus, RepositoryClient}; +use crate::github::api::base_github_url; use crate::github::api::operations::{merge_branches, set_branch_to_commit, MergeError}; use crate::github::{Branch, CommitSha, GithubRepoName, PullRequest, PullRequestNumber}; @@ -41,19 +42,20 @@ impl RepositoryClient for GithubRepositoryClient { async fn get_branch_sha(&mut self, name: &str) -> anyhow::Result { // https://docs.github.com/en/rest/branches/branches?apiVersion=2022-11-28#get-a-branch - let response = self + let branch: octocrab::models::repos::Branch = self .client - ._get( - self.client.base_url.join(&format!( - "/repos/{}/{}/branches/{name}", - self.repo_name.owner(), - self.repo_name.name(), - ))?, + .get( + base_github_url() + .join(&format!( + "/repos/{}/{}/branches/{name}", + self.repo_name.owner(), + self.repo_name.name(), + ))? + .as_str(), None::<&()>, ) - .await?; - let branch: octocrab::models::repos::Branch = - response.json().await.context("Cannot deserialize branch")?; + .await + .context("Cannot deserialize branch")?; Ok(CommitSha(branch.commit.sha)) } @@ -97,41 +99,40 @@ impl RepositoryClient for GithubRepositoryClient { branch: &str, sha: &CommitSha, ) -> anyhow::Result> { - let response = self - .client - ._get( - self.client.base_url.join(&format!( - "/repos/{}/{}/commits/{}/check-suites", - self.repo_name.owner(), - self.repo_name.name(), - sha.0 - ))?, - None::<&()>, - ) - .await?; - #[derive(serde::Deserialize, Debug)] - struct CheckSuitePayload<'a> { - conclusion: Option<&'a str>, - head_branch: &'a str, + struct CheckSuitePayload { + conclusion: Option, + head_branch: String, } #[derive(serde::Deserialize, Debug)] - struct CheckSuiteResponse<'a> { - #[serde(borrow)] - check_suites: Vec>, + struct CheckSuiteResponse { + check_suites: Vec, } - // `response.json()` is not used because of the 'a lifetime - let text = response.text().await?; - let response: CheckSuiteResponse = serde_json::from_str(&text)?; + let response: CheckSuiteResponse = self + .client + .get( + base_github_url() + .join(&format!( + "/repos/{}/{}/commits/{}/check-suites", + self.repo_name.owner(), + self.repo_name.name(), + sha.0 + ))? + .as_str(), + None::<&()>, + ) + .await + .context("Cannot fetch CheckSuiteResponse")?; + let suites = response .check_suites .into_iter() .filter(|suite| suite.head_branch == branch) .map(|suite| CheckSuite { status: match suite.conclusion { - Some(status) => match status { + Some(status) => match status.as_str() { "success" => CheckSuiteStatus::Success, "failure" | "neutral" | "cancelled" | "skipped" | "timed_out" | "action_required" | "startup_failure" | "stale" => { diff --git a/src/github/api/mod.rs b/src/github/api/mod.rs index 558ea550..3d8f590a 100644 --- a/src/github/api/mod.rs +++ b/src/github/api/mod.rs @@ -7,6 +7,7 @@ use base64::Engine; use octocrab::models::{App, AppId, InstallationRepositories, Repository}; use octocrab::Octocrab; use secrecy::{ExposeSecret, SecretVec}; +use url::Url; use client::GithubRepositoryClient; @@ -24,6 +25,12 @@ type GHRepositoryState = RepositoryState; type RepositoryMap = HashMap; +fn base_github_url() -> Url { + let url = std::cell::OnceCell::new(); + url.get_or_init(|| Url::parse("https://api.github.com").expect("Cannot parse base GitHub URL")) + .clone() +} + /// Provides access to managed GitHub repositories. pub struct GithubAppState { app: App, diff --git a/src/github/api/operations.rs b/src/github/api/operations.rs index fdc0336d..8c9d8070 100644 --- a/src/github/api/operations.rs +++ b/src/github/api/operations.rs @@ -1,5 +1,6 @@ +use crate::github::api::base_github_url; +use http::StatusCode; use octocrab::params::repos::Reference; -use reqwest::StatusCode; use thiserror::Error; use crate::github::api::client::GithubRepositoryClient; @@ -49,7 +50,7 @@ pub async fn merge_branches( .unwrap_or_else(|| { format!( "{}/repos/{}/{}/merges", - client.base_url, + base_github_url(), repo.name().owner, repo.name().name ) @@ -65,7 +66,7 @@ pub async fn merge_branches( match response { Ok(response) => { let status = response.status(); - let text = response.text().await.unwrap_or_default(); + let text = client.body_to_string(response).await.unwrap_or_default(); tracing::trace!( "Response from merging `{head_sha}` into `{base_ref}` in `{}`: {status} ({text})", @@ -157,11 +158,11 @@ async fn update_branch( tracing::debug!("Updating branch {} to SHA {}", url, sha.as_ref()); - let url = repo.client().base_url.join(&url).unwrap(); - let res: reqwest::Response = repo + let url = base_github_url().join(&url).unwrap(); + let res = repo .client ._patch( - url, + url.as_str(), Some(&serde_json::json!({ "sha": sha.as_ref(), "force": true @@ -173,7 +174,7 @@ async fn update_branch( tracing::trace!( "Updating branch response: status={}, text={:?}", status, - res.text().await + repo.client.body_to_string(res).await ); match status { diff --git a/src/github/webhook.rs b/src/github/webhook.rs index 0fe662bc..fc02dff2 100644 --- a/src/github/webhook.rs +++ b/src/github/webhook.rs @@ -12,7 +12,7 @@ use octocrab::models::events::payload::{ PullRequestReviewCommentEventPayload, }; use octocrab::models::pulls::{PullRequest, Review}; -use octocrab::models::{workflows, App, CheckRun, Repository, RunId, User}; +use octocrab::models::{workflows, App, Author, CheckRun, Repository, RunId}; use secrecy::{ExposeSecret, SecretString}; use sha2::Sha256; @@ -86,7 +86,7 @@ pub struct WebhookPullRequestReviewEvent<'a> { pull_request: PullRequest, review: Review, repository: Repository, - sender: User, + sender: Author, } /// axum extractor for GitHub webhook events. @@ -280,7 +280,7 @@ fn parse_comment_from_pr_review( }) } -fn parse_user(user: User) -> GithubUser { +fn parse_user(user: Author) -> GithubUser { GithubUser { username: user.login, html_url: user.html_url, From 21e910a61da5458189691b152ddb8567279cd7a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Fri, 15 Mar 2024 21:47:31 +0100 Subject: [PATCH 13/57] Remove dependency on `OpenSSL` --- Cargo.lock | 165 ++++++++++++++-------------------- Cargo.toml | 4 +- Dockerfile | 2 +- database/migration/Cargo.toml | 2 +- 4 files changed, 72 insertions(+), 101 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ac1ae77c..c096180b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -798,21 +798,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - [[package]] name = "form_urlencoded" version = "1.0.1" @@ -1197,6 +1182,20 @@ dependencies = [ "want", ] +[[package]] +name = "hyper-rustls" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" +dependencies = [ + "futures-util", + "http 0.2.12", + "hyper 0.14.28", + "rustls 0.21.10", + "tokio", + "tokio-rustls 0.24.1", +] + [[package]] name = "hyper-rustls" version = "0.26.0" @@ -1208,11 +1207,11 @@ dependencies = [ "hyper 1.2.0", "hyper-util", "log", - "rustls", + "rustls 0.22.2", "rustls-native-certs", "rustls-pki-types", "tokio", - "tokio-rustls", + "tokio-rustls 0.25.0", "tower-service", ] @@ -1229,19 +1228,6 @@ dependencies = [ "tower-service", ] -[[package]] -name = "hyper-tls" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" -dependencies = [ - "bytes", - "hyper 0.14.28", - "native-tls", - "tokio", - "tokio-native-tls", -] - [[package]] name = "hyper-util" version = "0.1.3" @@ -1528,24 +1514,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "native-tls" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" -dependencies = [ - "lazy_static", - "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", -] - [[package]] name = "nom" version = "7.1.3" @@ -1668,7 +1636,7 @@ dependencies = [ "http-body 1.0.0", "http-body-util", "hyper 1.2.0", - "hyper-rustls", + "hyper-rustls 0.26.0", "hyper-timeout", "hyper-util", "jsonwebtoken", @@ -1694,50 +1662,12 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "openssl" -version = "0.10.64" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" -dependencies = [ - "bitflags 2.4.2", - "cfg-if", - "foreign-types", - "libc", - "once_cell", - "openssl-macros", - "openssl-sys", -] - -[[package]] -name = "openssl-macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.52", -] - [[package]] name = "openssl-probe" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" -[[package]] -name = "openssl-sys" -version = "0.9.101" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dda2b0f344e78efc2facf7d195d098df0dd72151b26ab98da807afc26c198dff" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "ordered-float" version = "3.9.2" @@ -2086,15 +2016,15 @@ dependencies = [ "http 0.2.12", "http-body 0.4.6", "hyper 0.14.28", - "hyper-tls", + "hyper-rustls 0.24.2", "ipnet", "js-sys", "log", "mime", - "native-tls", "once_cell", "percent-encoding", "pin-project-lite", + "rustls 0.21.10", "rustls-pemfile 1.0.4", "serde", "serde_json", @@ -2102,12 +2032,13 @@ dependencies = [ "sync_wrapper", "system-configuration", "tokio", - "tokio-native-tls", + "tokio-rustls 0.24.1", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", + "webpki-roots", "winreg", ] @@ -2209,6 +2140,18 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "rustls" +version = "0.21.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" +dependencies = [ + "log", + "ring", + "rustls-webpki 0.101.7", + "sct", +] + [[package]] name = "rustls" version = "0.22.2" @@ -2218,7 +2161,7 @@ dependencies = [ "log", "ring", "rustls-pki-types", - "rustls-webpki", + "rustls-webpki 0.102.2", "subtle", "zeroize", ] @@ -2261,6 +2204,16 @@ version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ede67b28608b4c60685c7d54122d4400d90f62b40caee7700e700380a390fa8" +[[package]] +name = "rustls-webpki" +version = "0.101.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "rustls-webpki" version = "0.102.2" @@ -2299,6 +2252,16 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "sct" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "sea-bae" version = "0.2.0" @@ -2753,11 +2716,12 @@ dependencies = [ "indexmap", "log", "memchr", - "native-tls", "once_cell", "paste", "percent-encoding", "rust_decimal", + "rustls 0.21.10", + "rustls-pemfile 1.0.4", "serde", "serde_json", "sha2", @@ -2770,6 +2734,7 @@ dependencies = [ "tracing", "url", "uuid", + "webpki-roots", ] [[package]] @@ -3155,12 +3120,12 @@ dependencies = [ ] [[package]] -name = "tokio-native-tls" -version = "0.3.1" +name = "tokio-rustls" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "native-tls", + "rustls 0.21.10", "tokio", ] @@ -3170,7 +3135,7 @@ version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" dependencies = [ - "rustls", + "rustls 0.22.2", "rustls-pki-types", "tokio", ] @@ -3555,6 +3520,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "webpki-roots" +version = "0.25.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" + [[package]] name = "whoami" version = "1.5.1" diff --git a/Cargo.toml b/Cargo.toml index 0fc01f94..86cd1c5e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,7 +42,7 @@ axum = "0.7.4" tower = { version = "0.4", features = ["limit"] } jsonwebtoken = "9.2.0" url = "2.3" -reqwest = { version = "0.11", features = ["json"] } +reqwest = { version = "0.11", features = ["json", "rustls-tls"], default-features = false } http = "1.1.0" # Cryptography @@ -53,7 +53,7 @@ secrecy = "0.8" base64 = "0.22.0" # Database -sqlx = { version = "0.7.4", features = ["runtime-tokio-native-tls", "sqlite", "postgres"] } +sqlx = { version = "0.7.4", features = ["runtime-tokio-rustls", "sqlite", "postgres"] } sea-orm = { workspace = true } # Time diff --git a/Dockerfile b/Dockerfile index 771bdc9c..c5f85dc9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,7 +28,7 @@ FROM ubuntu:20.04 as runtime WORKDIR / -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y ca-certificates libssl-dev +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y ca-certificates COPY --from=build /app/target/release/bors . diff --git a/database/migration/Cargo.toml b/database/migration/Cargo.toml index 84d43f6a..4a2ab116 100644 --- a/database/migration/Cargo.toml +++ b/database/migration/Cargo.toml @@ -9,5 +9,5 @@ name = "migration" path = "src/lib.rs" [dependencies] -sea-orm-migration = { version = "0.12.14", features = ["runtime-tokio-native-tls", "sqlx-sqlite", "sqlx-postgres"] } +sea-orm-migration = { version = "0.12.14", features = ["runtime-tokio-rustls", "sqlx-sqlite", "sqlx-postgres"] } tokio = { workspace = true } From 9c9794877f2cf54a388d9e0541fb1bf27a90148e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Fri, 15 Mar 2024 22:02:20 +0100 Subject: [PATCH 14/57] Use Rust `1.76` on CI --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 381ce3ee..711fb34b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,7 +19,7 @@ jobs: uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.70.0 + toolchain: 1.76.0 override: true components: clippy, rustfmt From 7126eeb491b0ce52b05162673e9d2f96e4f78f94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Fri, 15 Mar 2024 22:09:08 +0100 Subject: [PATCH 15/57] Use debug info in release everywhere --- Cargo.toml | 3 +++ Dockerfile | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 86cd1c5e..be3b0e26 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -68,3 +68,6 @@ migration = { path = "database/migration" } [dev-dependencies] insta = "1.26" derive_builder = "0.20.0" + +[profile.release] +debug = 1 diff --git a/Dockerfile b/Dockerfile index c5f85dc9..d6b5fcb4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,7 +22,7 @@ COPY Cargo.lock . COPY src src COPY database database -RUN CARGO_PROFILE_RELEASE_DEBUG=1 cargo build --release +RUN cargo build --release FROM ubuntu:20.04 as runtime From 87973b750ea255383980d1c14908c062f2b7dbba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Fri, 15 Mar 2024 21:50:10 +0100 Subject: [PATCH 16/57] Add test for running the Docker image on CI --- .github/workflows/test.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 711fb34b..9f8a2a83 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -61,3 +61,10 @@ jobs: context: . cache-from: type=gha cache-to: type=gha,mode=max + tags: bors + load: true + - name: Run Docker image + run: | + # Check that the service starts + docker run bors & + timeout 20 bash -c 'until nc -z localhost 8080; do sleep 1; done' From 74ab4c11b2136b448a2133d816586906ba7a37fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Fri, 15 Mar 2024 22:16:17 +0100 Subject: [PATCH 17/57] Update ubuntu version in Docker --- .github/workflows/test.yml | 5 +---- Dockerfile | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9f8a2a83..24d89c68 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -64,7 +64,4 @@ jobs: tags: bors load: true - name: Run Docker image - run: | - # Check that the service starts - docker run bors & - timeout 20 bash -c 'until nc -z localhost 8080; do sleep 1; done' + run: docker run bors --help diff --git a/Dockerfile b/Dockerfile index d6b5fcb4..e733f179 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,7 +24,7 @@ COPY database database RUN cargo build --release -FROM ubuntu:20.04 as runtime +FROM ubuntu:22.04 as runtime WORKDIR / From 952713e803d5e410bedf32af808208093c43cd50 Mon Sep 17 00:00:00 2001 From: vohoanglong0107 Date: Sun, 24 Mar 2024 13:05:10 +0000 Subject: [PATCH 18/57] refactor: reload permission on refresh event --- src/bors/handlers/refresh.rs | 16 ++++++++++++-- src/permissions.rs | 41 +++++++----------------------------- src/tests/permissions.rs | 2 ++ 3 files changed, 24 insertions(+), 35 deletions(-) diff --git a/src/bors/handlers/refresh.rs b/src/bors/handlers/refresh.rs index 7580bd1a..88aa5812 100644 --- a/src/bors/handlers/refresh.rs +++ b/src/bors/handlers/refresh.rs @@ -10,12 +10,21 @@ pub async fn refresh_repository( repo: &mut RepositoryState, db: &dyn DbClient, ) -> anyhow::Result<()> { - let timeout = repo.config.timeout; + cancel_timed_out_builds(repo, db).await?; + reload_permission(repo).await; + Ok(()) +} + +async fn cancel_timed_out_builds( + repo: &mut RepositoryState, + db: &dyn DbClient, +) -> anyhow::Result<()> { let running_builds = db.get_running_builds(&repo.repository).await?; tracing::info!("Found {} running build(s)", running_builds.len()); for build in running_builds { + let timeout = repo.config.timeout; if elapsed_time(build.created_at) >= timeout { tracing::info!("Cancelling build {}", build.commit_sha); @@ -41,10 +50,13 @@ pub async fn refresh_repository( } } } - Ok(()) } +async fn reload_permission(repo: &mut RepositoryState) { + repo.permissions_resolver.reload().await +} + #[cfg(not(test))] fn now() -> DateTime { Utc::now() diff --git a/src/permissions.rs b/src/permissions.rs index 33a44f27..f53d062f 100644 --- a/src/permissions.rs +++ b/src/permissions.rs @@ -1,6 +1,5 @@ use axum::async_trait; use std::collections::HashSet; -use std::time::{Duration, SystemTime}; use tokio::sync::Mutex; use crate::github::GithubRepoName; @@ -16,15 +15,13 @@ pub enum PermissionType { #[async_trait] pub trait PermissionResolver { async fn has_permission(&self, username: &str, permission: PermissionType) -> bool; + async fn reload(&self); } -/// For how long should the permissions be cached. -const CACHE_DURATION: Duration = Duration::from_secs(60); - /// Loads permission information from the Rust Team API. pub struct TeamApiPermissionResolver { repo: GithubRepoName, - permissions: Mutex, + permissions: Mutex, } impl TeamApiPermissionResolver { @@ -33,14 +30,13 @@ impl TeamApiPermissionResolver { Ok(Self { repo, - permissions: Mutex::new(CachedUserPermissions::new(permissions)), + permissions: Mutex::new(permissions), }) } - async fn reload_permissions(&self) { let result = load_permissions(&self.repo).await; match result { - Ok(perms) => *self.permissions.lock().await = CachedUserPermissions::new(perms), + Ok(perms) => *self.permissions.lock().await = perms, Err(error) => { tracing::error!("Cannot reload permissions for {}: {error:?}", self.repo); } @@ -51,16 +47,15 @@ impl TeamApiPermissionResolver { #[async_trait] impl PermissionResolver for TeamApiPermissionResolver { async fn has_permission(&self, username: &str, permission: PermissionType) -> bool { - if self.permissions.lock().await.is_stale() { - self.reload_permissions().await; - } - self.permissions .lock() .await - .permissions .has_permission(username, permission) } + + async fn reload(&self) { + self.reload_permissions().await + } } pub struct UserPermissions { @@ -77,26 +72,6 @@ impl UserPermissions { } } -struct CachedUserPermissions { - permissions: UserPermissions, - created_at: SystemTime, -} -impl CachedUserPermissions { - fn new(permissions: UserPermissions) -> Self { - Self { - permissions, - created_at: SystemTime::now(), - } - } - - fn is_stale(&self) -> bool { - self.created_at - .elapsed() - .map(|duration| duration > CACHE_DURATION) - .unwrap_or(true) - } -} - async fn load_permissions(repo: &GithubRepoName) -> anyhow::Result { tracing::info!("Reloading permissions for repository {repo}"); diff --git a/src/tests/permissions.rs b/src/tests/permissions.rs index b335b8b1..49aaa083 100644 --- a/src/tests/permissions.rs +++ b/src/tests/permissions.rs @@ -8,6 +8,7 @@ impl PermissionResolver for NoPermissions { async fn has_permission(&self, _username: &str, _permission: PermissionType) -> bool { false } + async fn reload(&self) {} } pub struct AllPermissions; @@ -17,4 +18,5 @@ impl PermissionResolver for AllPermissions { async fn has_permission(&self, _username: &str, _permission: PermissionType) -> bool { true } + async fn reload(&self) {} } From e694b75614dec5d42a5b960281abb1fc441fa09b Mon Sep 17 00:00:00 2001 From: vohoanglong0107 Date: Wed, 27 Mar 2024 08:41:29 +0000 Subject: [PATCH 19/57] fix: still run refresh when cancel build error --- src/bors/handlers/refresh.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bors/handlers/refresh.rs b/src/bors/handlers/refresh.rs index 88aa5812..d3e800ea 100644 --- a/src/bors/handlers/refresh.rs +++ b/src/bors/handlers/refresh.rs @@ -10,10 +10,10 @@ pub async fn refresh_repository( repo: &mut RepositoryState, db: &dyn DbClient, ) -> anyhow::Result<()> { - cancel_timed_out_builds(repo, db).await?; + let res = cancel_timed_out_builds(repo, db).await; reload_permission(repo).await; - Ok(()) + res } async fn cancel_timed_out_builds( From ddc81f0898dd74eaacbb69e5f839ee557176cd50 Mon Sep 17 00:00:00 2001 From: vohoanglong0107 Date: Wed, 27 Mar 2024 08:41:54 +0000 Subject: [PATCH 20/57] test: refresh permission --- src/bors/handlers/refresh.rs | 13 +++++++++++++ src/tests/permissions.rs | 24 ++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/src/bors/handlers/refresh.rs b/src/bors/handlers/refresh.rs index d3e800ea..b1c2bf8e 100644 --- a/src/bors/handlers/refresh.rs +++ b/src/bors/handlers/refresh.rs @@ -80,6 +80,7 @@ fn elapsed_time(date: DateTime) -> Duration { #[cfg(test)] mod tests { use std::future::Future; + use std::sync::{Arc, Mutex}; use std::time::Duration; use chrono::Utc; @@ -89,6 +90,7 @@ mod tests { use crate::bors::handlers::trybuild::TRY_BRANCH_NAME; use crate::database::DbClient; use crate::tests::event::{default_pr_number, WorkflowStartedBuilder}; + use crate::tests::permissions::MockPermissions; use crate::tests::state::{default_repo_name, ClientBuilder, RepoConfigBuilder}; #[tokio::test(flavor = "current_thread")] @@ -97,6 +99,17 @@ mod tests { state.refresh().await; } + #[tokio::test(flavor = "current_thread")] + async fn refresh_permission() { + let permission_resolver = Arc::new(Mutex::new(MockPermissions::default())); + let mut state = ClientBuilder::default() + .permission_resolver(Box::new(Arc::clone(&permission_resolver))) + .create_state() + .await; + state.refresh().await; + assert_eq!(permission_resolver.lock().unwrap().num_reload_called, 1); + } + #[tokio::test(flavor = "current_thread")] async fn refresh_do_nothing_before_timeout() { let mut state = ClientBuilder::default() diff --git a/src/tests/permissions.rs b/src/tests/permissions.rs index 49aaa083..cf94c34c 100644 --- a/src/tests/permissions.rs +++ b/src/tests/permissions.rs @@ -1,3 +1,5 @@ +use std::sync::{Arc, Mutex}; + use crate::permissions::{PermissionResolver, PermissionType}; use axum::async_trait; @@ -20,3 +22,25 @@ impl PermissionResolver for AllPermissions { } async fn reload(&self) {} } + +pub struct MockPermissions { + pub num_reload_called: i32, +} + +impl Default for MockPermissions { + fn default() -> Self { + Self { + num_reload_called: 0, + } + } +} + +#[async_trait] +impl PermissionResolver for Arc> { + async fn has_permission(&self, _username: &str, _permission: PermissionType) -> bool { + false + } + async fn reload(&self) { + self.lock().unwrap().num_reload_called += 1 + } +} From debf50e88584a5d6d1f982ddd26863b81350105d Mon Sep 17 00:00:00 2001 From: vohoanglong0107 Date: Thu, 28 Mar 2024 06:16:50 +0000 Subject: [PATCH 21/57] feat: reload config --- src/bors/handlers/refresh.rs | 9 +++++++ src/bors/mod.rs | 3 +++ src/github/api/client.rs | 36 +++++++++++++++++++++++++ src/github/api/mod.rs | 51 ++++++------------------------------ src/tests/state.rs | 4 +++ 5 files changed, 60 insertions(+), 43 deletions(-) diff --git a/src/bors/handlers/refresh.rs b/src/bors/handlers/refresh.rs index b1c2bf8e..17aec07e 100644 --- a/src/bors/handlers/refresh.rs +++ b/src/bors/handlers/refresh.rs @@ -12,6 +12,7 @@ pub async fn refresh_repository( ) -> anyhow::Result<()> { let res = cancel_timed_out_builds(repo, db).await; reload_permission(repo).await; + reload_config(repo).await?; res } @@ -57,6 +58,14 @@ async fn reload_permission(repo: &mut RepositoryState< repo.permissions_resolver.reload().await } +async fn reload_config( + repo: &mut RepositoryState, +) -> anyhow::Result<()> { + let config = repo.client.load_config().await?; + repo.config = config; + Ok(()) +} + #[cfg(not(test))] fn now() -> DateTime { Utc::now() diff --git a/src/bors/mod.rs b/src/bors/mod.rs index a3ea0b75..36ffb21b 100644 --- a/src/bors/mod.rs +++ b/src/bors/mod.rs @@ -23,6 +23,9 @@ pub use handlers::handle_bors_event; pub trait RepositoryClient { fn repository(&self) -> &GithubRepoName; + /// load repository config + async fn load_config(&mut self) -> anyhow::Result; + /// Return the current SHA of the given branch. async fn get_branch_sha(&mut self, name: &str) -> anyhow::Result; diff --git a/src/github/api/client.rs b/src/github/api/client.rs index aa151260..27037f05 100644 --- a/src/github/api/client.rs +++ b/src/github/api/client.rs @@ -1,10 +1,12 @@ use anyhow::Context; use axum::async_trait; +use base64::Engine; use octocrab::models::{Repository, RunId}; use octocrab::{Error, Octocrab}; use tracing::log; use crate::bors::{CheckSuite, CheckSuiteStatus, RepositoryClient}; +use crate::config::{RepositoryConfig, CONFIG_FILE_PATH}; use crate::github::api::base_github_url; use crate::github::api::operations::{merge_branches, set_branch_to_commit, MergeError}; use crate::github::{Branch, CommitSha, GithubRepoName, PullRequest, PullRequestNumber}; @@ -40,6 +42,40 @@ impl RepositoryClient for GithubRepositoryClient { self.name() } + /// Loads repository configuration from a file located at `[CONFIG_FILE_PATH]` in the main + /// branch. + async fn load_config(&mut self) -> anyhow::Result { + let mut response = self + .client + .repos(&self.repo_name.owner, &self.repo_name.name) + .get_content() + .path(CONFIG_FILE_PATH) + .send() + .await + .map_err(|error| { + anyhow::anyhow!( + "Could not fetch {CONFIG_FILE_PATH} from {}: {error:?}", + self.repo_name + ) + })?; + + let engine = base64::engine::general_purpose::STANDARD; + response + .take_items() + .into_iter() + .next() + .and_then(|content| content.content) + .ok_or_else(|| anyhow::anyhow!("Configuration file not found")) + .and_then(|content| Ok(engine.decode(content.trim())?)) + .and_then(|content| Ok(String::from_utf8(content)?)) + .and_then(|content| { + let config: RepositoryConfig = toml::from_str(&content).map_err(|error| { + anyhow::anyhow!("Could not deserialize repository config: {error:?}") + })?; + Ok(config) + }) + } + async fn get_branch_sha(&mut self, name: &str) -> anyhow::Result { // https://docs.github.com/en/rest/branches/branches?apiVersion=2022-11-28#get-a-branch let branch: octocrab::models::repos::Branch = self diff --git a/src/github/api/mod.rs b/src/github/api/mod.rs index 3d8f590a..02647d24 100644 --- a/src/github/api/mod.rs +++ b/src/github/api/mod.rs @@ -3,7 +3,6 @@ use std::future::Future; use std::pin::Pin; use anyhow::Context; -use base64::Engine; use octocrab::models::{App, AppId, InstallationRepositories, Repository}; use octocrab::Octocrab; use secrecy::{ExposeSecret, SecretVec}; @@ -12,8 +11,7 @@ use url::Url; use client::GithubRepositoryClient; use crate::bors::event::PullRequestComment; -use crate::bors::{BorsState, RepositoryState}; -use crate::config::{RepositoryConfig, CONFIG_FILE_PATH}; +use crate::bors::{BorsState, RepositoryClient, RepositoryState}; use crate::database::{DbClient, SeaORMClient}; use crate::github::GithubRepoName; use crate::permissions::TeamApiPermissionResolver; @@ -142,7 +140,13 @@ async fn create_repo_state( let name = GithubRepoName::new(&owner.login, &repo.name); tracing::info!("Found repository {name}"); - let config = match load_repository_config(&repo_client, &name).await { + let mut client = GithubRepositoryClient { + client: repo_client, + repo_name: name.clone(), + repository: repo, + }; + + let config = match client.load_config().await { Ok(config) => { tracing::info!("Loaded repository config for {name}: {config:#?}"); config @@ -158,12 +162,6 @@ async fn create_repo_state( .await .map_err(|error| anyhow::anyhow!("Could not load permissions for {name}: {error:?}"))?; - let client = GithubRepositoryClient { - client: repo_client, - repo_name: name.clone(), - repository: repo, - }; - Ok(RepositoryState { repository: name, client, @@ -172,39 +170,6 @@ async fn create_repo_state( }) } -/// Loads repository configuration from a file located at `[CONFIG_FILE_PATH]` in the main -/// branch. -async fn load_repository_config( - gh_client: &Octocrab, - repo: &GithubRepoName, -) -> anyhow::Result { - let mut response = gh_client - .repos(&repo.owner, &repo.name) - .get_content() - .path(CONFIG_FILE_PATH) - .send() - .await - .map_err(|error| { - anyhow::anyhow!("Could not fetch {CONFIG_FILE_PATH} from {repo}: {error:?}") - })?; - - let engine = base64::engine::general_purpose::STANDARD; - response - .take_items() - .into_iter() - .next() - .and_then(|content| content.content) - .ok_or_else(|| anyhow::anyhow!("Configuration file not found")) - .and_then(|content| Ok(engine.decode(content.trim())?)) - .and_then(|content| Ok(String::from_utf8(content)?)) - .and_then(|content| { - let config: RepositoryConfig = toml::from_str(&content).map_err(|error| { - anyhow::anyhow!("Could not deserialize repository config: {error:?}") - })?; - Ok(config) - }) -} - impl BorsState for GithubAppState { fn is_comment_internal(&self, comment: &PullRequestComment) -> bool { comment.author.html_url == self.app.html_url diff --git a/src/tests/state.rs b/src/tests/state.rs index 3846bdc4..24bf3a79 100644 --- a/src/tests/state.rs +++ b/src/tests/state.rs @@ -409,4 +409,8 @@ impl RepositoryClient for TestRepositoryClient { .extend(labels.to_vec()); Ok(()) } + + async fn load_config(&mut self) -> anyhow::Result { + Ok(RepoConfigBuilder::default().create()) + } } From dc3bfd02b37c539ac34a7d681cc14e740146c6d0 Mon Sep 17 00:00:00 2001 From: vohoanglong0107 Date: Fri, 29 Mar 2024 00:10:08 +0000 Subject: [PATCH 22/57] feat: use user id instead of username --- src/bors/handlers/trybuild.rs | 2 +- src/github/mod.rs | 2 ++ src/github/webhook.rs | 10 ++++++++++ src/permissions.rs | 23 ++++++++++++----------- src/tests/event.rs | 3 ++- src/tests/permissions.rs | 7 ++++--- src/tests/state.rs | 4 +++- 7 files changed, 34 insertions(+), 17 deletions(-) diff --git a/src/bors/handlers/trybuild.rs b/src/bors/handlers/trybuild.rs index 08866e57..0cc8c0b1 100644 --- a/src/bors/handlers/trybuild.rs +++ b/src/bors/handlers/trybuild.rs @@ -262,7 +262,7 @@ async fn check_try_permissions( ) -> anyhow::Result { let result = if !repo .permissions_resolver - .has_permission(&author.username, PermissionType::Try) + .has_permission(&author.id, PermissionType::Try) .await { tracing::info!("Permission denied"); diff --git a/src/github/mod.rs b/src/github/mod.rs index 10d6f957..68497609 100644 --- a/src/github/mod.rs +++ b/src/github/mod.rs @@ -2,6 +2,7 @@ //! for working with (GitHub) repositories. use std::fmt::{Debug, Display, Formatter}; +use octocrab::models::UserId; use url::Url; pub mod api; @@ -46,6 +47,7 @@ impl Display for GithubRepoName { #[derive(Debug, PartialEq)] pub struct GithubUser { + pub id: UserId, pub username: String, pub html_url: Url, } diff --git a/src/github/webhook.rs b/src/github/webhook.rs index fc02dff2..60dae176 100644 --- a/src/github/webhook.rs +++ b/src/github/webhook.rs @@ -282,6 +282,7 @@ fn parse_comment_from_pr_review( fn parse_user(user: Author) -> GithubUser { GithubUser { + id: user.id, username: user.login, html_url: user.html_url, } @@ -381,6 +382,9 @@ mod tests { name: "bors-kindergarten", }, author: GithubUser { + id: UserId( + 4539057, + ), username: "Kobzol", html_url: Url { scheme: "https", @@ -424,6 +428,9 @@ mod tests { name: "bors-kindergarten", }, author: GithubUser { + id: UserId( + 4539057, + ), username: "Kobzol", html_url: Url { scheme: "https", @@ -467,6 +474,9 @@ mod tests { name: "bors-kindergarten", }, author: GithubUser { + id: UserId( + 4539057, + ), username: "Kobzol", html_url: Url { scheme: "https", diff --git a/src/permissions.rs b/src/permissions.rs index f53d062f..28db6331 100644 --- a/src/permissions.rs +++ b/src/permissions.rs @@ -1,4 +1,5 @@ use axum::async_trait; +use octocrab::models::UserId; use std::collections::HashSet; use tokio::sync::Mutex; @@ -14,7 +15,7 @@ pub enum PermissionType { /// Decides if a GitHub user can perform various actions using the bot. #[async_trait] pub trait PermissionResolver { - async fn has_permission(&self, username: &str, permission: PermissionType) -> bool; + async fn has_permission(&self, _username: &UserId, _permission: PermissionType) -> bool; async fn reload(&self); } @@ -46,11 +47,11 @@ impl TeamApiPermissionResolver { #[async_trait] impl PermissionResolver for TeamApiPermissionResolver { - async fn has_permission(&self, username: &str, permission: PermissionType) -> bool { + async fn has_permission(&self, user_id: &UserId, permission: PermissionType) -> bool { self.permissions .lock() .await - .has_permission(username, permission) + .has_permission(user_id, permission) } async fn reload(&self) { @@ -59,15 +60,15 @@ impl PermissionResolver for TeamApiPermissionResolver { } pub struct UserPermissions { - review_users: HashSet, - try_users: HashSet, + review_users: HashSet, + try_users: HashSet, } impl UserPermissions { - fn has_permission(&self, username: &str, permission: PermissionType) -> bool { + fn has_permission(&self, user_id: &UserId, permission: PermissionType) -> bool { match permission { - PermissionType::Review => self.review_users.contains(username), - PermissionType::Try => self.try_users.contains(username), + PermissionType::Review => self.review_users.contains(user_id), + PermissionType::Try => self.try_users.contains(user_id), } } } @@ -90,14 +91,14 @@ async fn load_permissions(repo: &GithubRepoName) -> anyhow::Result, + github_ids: HashSet, } /// Loads users that are allowed to perform try/review from the Rust Team API. async fn load_users_from_team_api( repository_name: &str, permission: PermissionType, -) -> anyhow::Result> { +) -> anyhow::Result> { let permission = match permission { PermissionType::Review => "review", PermissionType::Try => "try", @@ -112,5 +113,5 @@ async fn load_users_from_team_api( .json::() .await .map_err(|error| anyhow::anyhow!("Cannot deserialize users from team API: {error:?}"))?; - Ok(users.github_users) + Ok(users.github_ids) } diff --git a/src/tests/event.rs b/src/tests/event.rs index c11b3fa7..0cd2595a 100644 --- a/src/tests/event.rs +++ b/src/tests/event.rs @@ -1,5 +1,5 @@ use derive_builder::Builder; -use octocrab::models::RunId; +use octocrab::models::{RunId, UserId}; use crate::bors::event::PullRequestComment; use crate::bors::{event, CheckSuite, CheckSuiteStatus}; @@ -9,6 +9,7 @@ use crate::tests::state::{default_merge_sha, default_repo_name}; fn default_user() -> GithubUser { GithubUser { + id: UserId(1), username: "".to_string(), html_url: "https://user.com".parse().unwrap(), } diff --git a/src/tests/permissions.rs b/src/tests/permissions.rs index cf94c34c..1e33a1f4 100644 --- a/src/tests/permissions.rs +++ b/src/tests/permissions.rs @@ -2,12 +2,13 @@ use std::sync::{Arc, Mutex}; use crate::permissions::{PermissionResolver, PermissionType}; use axum::async_trait; +use octocrab::models::UserId; pub struct NoPermissions; #[async_trait] impl PermissionResolver for NoPermissions { - async fn has_permission(&self, _username: &str, _permission: PermissionType) -> bool { + async fn has_permission(&self, _username: &UserId, _permission: PermissionType) -> bool { false } async fn reload(&self) {} @@ -17,7 +18,7 @@ pub struct AllPermissions; #[async_trait] impl PermissionResolver for AllPermissions { - async fn has_permission(&self, _username: &str, _permission: PermissionType) -> bool { + async fn has_permission(&self, _username: &UserId, _permission: PermissionType) -> bool { true } async fn reload(&self) {} @@ -37,7 +38,7 @@ impl Default for MockPermissions { #[async_trait] impl PermissionResolver for Arc> { - async fn has_permission(&self, _username: &str, _permission: PermissionType) -> bool { + async fn has_permission(&self, _username: &UserId, _permission: PermissionType) -> bool { false } async fn reload(&self) { diff --git a/src/tests/state.rs b/src/tests/state.rs index 24bf3a79..c94109f3 100644 --- a/src/tests/state.rs +++ b/src/tests/state.rs @@ -7,7 +7,7 @@ use std::time::Duration; use crate::config::RepositoryConfig; use axum::async_trait; use derive_builder::Builder; -use octocrab::models::RunId; +use octocrab::models::{RunId, UserId}; use super::permissions::AllPermissions; use crate::bors::event::{ @@ -29,6 +29,8 @@ use crate::tests::github::{default_base_branch, PRBuilder}; pub fn test_bot_user() -> GithubUser { GithubUser { + // just a random one, to reduce the chance of duplicate id + id: UserId(517237103), username: "".to_string(), html_url: "https://test-bors.bot.com".parse().unwrap(), } From 808c0bcfe4190e3931540c4e74db13f9dc068740 Mon Sep 17 00:00:00 2001 From: vohoanglong0107 Date: Sat, 30 Mar 2024 15:59:30 +0000 Subject: [PATCH 23/57] fix: rename username to user id --- src/permissions.rs | 2 +- src/tests/permissions.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/permissions.rs b/src/permissions.rs index 28db6331..760b4370 100644 --- a/src/permissions.rs +++ b/src/permissions.rs @@ -15,7 +15,7 @@ pub enum PermissionType { /// Decides if a GitHub user can perform various actions using the bot. #[async_trait] pub trait PermissionResolver { - async fn has_permission(&self, _username: &UserId, _permission: PermissionType) -> bool; + async fn has_permission(&self, user_id: &UserId, permission: PermissionType) -> bool; async fn reload(&self); } diff --git a/src/tests/permissions.rs b/src/tests/permissions.rs index 1e33a1f4..ba13d212 100644 --- a/src/tests/permissions.rs +++ b/src/tests/permissions.rs @@ -8,7 +8,7 @@ pub struct NoPermissions; #[async_trait] impl PermissionResolver for NoPermissions { - async fn has_permission(&self, _username: &UserId, _permission: PermissionType) -> bool { + async fn has_permission(&self, _user_id: &UserId, _permission: PermissionType) -> bool { false } async fn reload(&self) {} @@ -18,7 +18,7 @@ pub struct AllPermissions; #[async_trait] impl PermissionResolver for AllPermissions { - async fn has_permission(&self, _username: &UserId, _permission: PermissionType) -> bool { + async fn has_permission(&self, _user_id: &UserId, _permission: PermissionType) -> bool { true } async fn reload(&self) {} @@ -38,7 +38,7 @@ impl Default for MockPermissions { #[async_trait] impl PermissionResolver for Arc> { - async fn has_permission(&self, _username: &UserId, _permission: PermissionType) -> bool { + async fn has_permission(&self, _user_id: &UserId, _permission: PermissionType) -> bool { false } async fn reload(&self) { From 79fb5e66a0bf1f16418103267b641efc8edb3438 Mon Sep 17 00:00:00 2001 From: vohoanglong0107 Date: Sat, 30 Mar 2024 15:32:53 +0000 Subject: [PATCH 24/57] feat: display workflow url --- src/bors/handlers/trybuild.rs | 65 ++++++++++++++++------------------- src/bors/mod.rs | 5 ++- src/github/api/client.rs | 29 +++++++++++++--- src/github/api/mod.rs | 6 ++++ src/tests/state.rs | 17 ++++++++- 5 files changed, 81 insertions(+), 41 deletions(-) diff --git a/src/bors/handlers/trybuild.rs b/src/bors/handlers/trybuild.rs index 0cc8c0b1..3f1dfaac 100644 --- a/src/bors/handlers/trybuild.rs +++ b/src/bors/handlers/trybuild.rs @@ -1,4 +1,5 @@ use anyhow::{anyhow, Context}; +use octocrab::models::RunId; use crate::bors::command::Parent; use crate::bors::handlers::labels::handle_label_trigger; @@ -167,21 +168,29 @@ pub(super) async fn command_try_cancel( return Ok(()); }; - if let Err(error) = cancel_build_workflows(repo, db, &build).await { - tracing::error!( + match cancel_build_workflows(repo, db, &build).await { + Err(error) => tracing::error!( "Could not cancel workflows for SHA {}: {error:?}", build.commit_sha - ); - } - - db.update_build_status(&build, BuildStatus::Cancelled) - .await?; + ), + Ok(workflow_ids) => { + db.update_build_status(&build, BuildStatus::Cancelled) + .await?; - tracing::info!("Try build cancelled"); + tracing::info!("Try build cancelled"); - repo.client - .post_comment(pr_number, "Try build cancelled.") - .await?; + let mut try_build_cancelled_comment = r#"Try build cancelled. +Cancelled workflows:"# + .to_string(); + for id in workflow_ids { + let url = repo.client.get_workflow_url(id).await; + try_build_cancelled_comment += format!("\n- {}", url).as_str(); + } + repo.client + .post_comment(pr_number, &try_build_cancelled_comment) + .await? + } + } Ok(()) } @@ -190,7 +199,7 @@ pub async fn cancel_build_workflows( repo: &mut RepositoryState, db: &dyn DbClient, build: &BuildModel, -) -> anyhow::Result<()> { +) -> anyhow::Result> { let pending_workflows = db .get_workflows_for_build(build) .await? @@ -200,7 +209,8 @@ pub async fn cancel_build_workflows( .collect::>(); tracing::info!("Cancelling workflows {:?}", pending_workflows); - repo.client.cancel_workflows(pending_workflows).await + repo.client.cancel_workflows(&pending_workflows).await?; + Ok(pending_workflows) } fn get_pending_build(pr: PullRequestModel) -> Option { @@ -551,28 +561,6 @@ mod tests { insta::assert_snapshot!(state.client().get_last_comment(default_pr_number()), @":exclamation: There is currently no try build in progress."); } - #[tokio::test] - async fn test_try_cancel_running_build() { - let mut state = ClientBuilder::default().create_state().await; - - state.comment("@bors try").await; - state.comment("@bors try cancel").await; - - insta::assert_snapshot!(state.client().get_last_comment(default_pr_number()), @"Try build cancelled."); - - let build = state - .db - .find_build( - &default_repo_name(), - TRY_BRANCH_NAME.to_string(), - default_merge_sha().into(), - ) - .await - .unwrap() - .unwrap(); - assert_eq!(build.status, BuildStatus::Cancelled); - } - #[tokio::test] async fn test_try_cancel_cancel_workflows() { let mut state = ClientBuilder::default().create_state().await; @@ -594,6 +582,13 @@ mod tests { .await; state.comment("@bors try cancel").await; state.client().check_cancelled_workflows(&[123, 124]); + + insta::assert_snapshot!(state.client().get_last_comment(default_pr_number()), @r###" + Try build cancelled. + Cancelled workflows: + - https://github.com/owner/name/actions/runs/123 + - https://github.com/owner/name/actions/runs/124 + "###); } #[tokio::test] diff --git a/src/bors/mod.rs b/src/bors/mod.rs index 36ffb21b..a2008101 100644 --- a/src/bors/mod.rs +++ b/src/bors/mod.rs @@ -54,7 +54,7 @@ pub trait RepositoryClient { ) -> anyhow::Result>; /// Cancels Github Actions workflows. - async fn cancel_workflows(&mut self, run_ids: Vec) -> anyhow::Result<()>; + async fn cancel_workflows(&mut self, run_ids: &[RunId]) -> anyhow::Result<()>; /// Add a set of labels to a PR. async fn add_labels(&mut self, pr: PullRequestNumber, labels: &[String]) -> anyhow::Result<()>; @@ -65,6 +65,9 @@ pub trait RepositoryClient { pr: PullRequestNumber, labels: &[String], ) -> anyhow::Result<()>; + + /// Get a workflow url + async fn get_workflow_url(&mut self, run_id: RunId) -> String; } #[derive(Clone)] diff --git a/src/github/api/client.rs b/src/github/api/client.rs index 27037f05..296b8bdb 100644 --- a/src/github/api/client.rs +++ b/src/github/api/client.rs @@ -7,8 +7,8 @@ use tracing::log; use crate::bors::{CheckSuite, CheckSuiteStatus, RepositoryClient}; use crate::config::{RepositoryConfig, CONFIG_FILE_PATH}; -use crate::github::api::base_github_url; use crate::github::api::operations::{merge_branches, set_branch_to_commit, MergeError}; +use crate::github::api::{base_github_html_url, base_github_url}; use crate::github::{Branch, CommitSha, GithubRepoName, PullRequest, PullRequestNumber}; /// Provides access to a single app installation (repository) using the GitHub API. @@ -190,12 +190,16 @@ impl RepositoryClient for GithubRepositoryClient { Ok(suites) } - async fn cancel_workflows(&mut self, run_ids: Vec) -> anyhow::Result<()> { + async fn cancel_workflows(&mut self, run_ids: &[RunId]) -> anyhow::Result<()> { let actions = self.client.actions(); // Cancel all workflows in parallel - futures::future::join_all(run_ids.into_iter().map(|run_id| { - actions.cancel_workflow_run(self.repo_name.owner(), self.repo_name.name(), run_id) + futures::future::join_all(run_ids.iter().map(|run_id| { + actions.cancel_workflow_run( + self.repo_name.owner(), + self.repo_name.name(), + run_id.clone(), + ) })) .await .into_iter() @@ -247,6 +251,23 @@ impl RepositoryClient for GithubRepositoryClient { Ok(()) } + + async fn get_workflow_url(&mut self, run_id: RunId) -> String { + let html_url = self + .repository + .html_url + .as_ref() + .map(|url| url.to_string()) + .unwrap_or_else(|| { + format!( + "{}/{}/{}", + base_github_html_url(), + self.name().owner, + self.name().name + ) + }); + format!("{}/actions/runs/{}", html_url, run_id) + } } fn github_pr_to_pr(pr: octocrab::models::pulls::PullRequest) -> PullRequest { diff --git a/src/github/api/mod.rs b/src/github/api/mod.rs index 02647d24..a4dfe04f 100644 --- a/src/github/api/mod.rs +++ b/src/github/api/mod.rs @@ -23,6 +23,12 @@ type GHRepositoryState = RepositoryState; type RepositoryMap = HashMap; +fn base_github_html_url() -> Url { + let url = std::cell::OnceCell::new(); + url.get_or_init(|| Url::parse("https://github.com").expect("Cannot parse base GitHub URL")) + .clone() +} + fn base_github_url() -> Url { let url = std::cell::OnceCell::new(); url.get_or_init(|| Url::parse("https://api.github.com").expect("Cannot parse base GitHub URL")) diff --git a/src/tests/state.rs b/src/tests/state.rs index c94109f3..cd9ed121 100644 --- a/src/tests/state.rs +++ b/src/tests/state.rs @@ -8,6 +8,7 @@ use crate::config::RepositoryConfig; use axum::async_trait; use derive_builder::Builder; use octocrab::models::{RunId, UserId}; +use url::Url; use super::permissions::AllPermissions; use crate::bors::event::{ @@ -386,7 +387,7 @@ impl RepositoryClient for TestRepositoryClient { Ok(self.check_suites.get(&sha.0).cloned().unwrap_or_default()) } - async fn cancel_workflows(&mut self, run_ids: Vec) -> anyhow::Result<()> { + async fn cancel_workflows(&mut self, run_ids: &[RunId]) -> anyhow::Result<()> { self.cancelled_workflows .extend(run_ids.into_iter().map(|id| id.0)); Ok(()) @@ -415,4 +416,18 @@ impl RepositoryClient for TestRepositoryClient { async fn load_config(&mut self) -> anyhow::Result { Ok(RepoConfigBuilder::default().create()) } + + async fn get_workflow_url(&mut self, run_id: RunId) -> String { + let mut url = Url::parse("https://github.com").expect("Cannot parse base GitHub URL"); + url.set_path( + format!( + "{}/{}/actions/runs/{}", + self.repository().owner(), + self.repository().name(), + run_id + ) + .as_str(), + ); + url.to_string() + } } From 6c856794c2927ecdd7a25f659a123b8058b3bd7f Mon Sep 17 00:00:00 2001 From: vohoanglong0107 Date: Wed, 3 Apr 2024 09:07:43 +0000 Subject: [PATCH 25/57] fix: also mark build as cancalled in failure --- src/bors/handlers/trybuild.rs | 41 ++++++++++-- src/tests/database.rs | 123 ++++++++++++++++++++++++++++++++-- src/tests/state.rs | 33 ++++----- 3 files changed, 166 insertions(+), 31 deletions(-) diff --git a/src/bors/handlers/trybuild.rs b/src/bors/handlers/trybuild.rs index 3f1dfaac..88c8bec6 100644 --- a/src/bors/handlers/trybuild.rs +++ b/src/bors/handlers/trybuild.rs @@ -169,14 +169,21 @@ pub(super) async fn command_try_cancel( }; match cancel_build_workflows(repo, db, &build).await { - Err(error) => tracing::error!( - "Could not cancel workflows for SHA {}: {error:?}", - build.commit_sha - ), - Ok(workflow_ids) => { + Err(error) => { + tracing::error!( + "Could not cancel workflows for SHA {}: {error:?}", + build.commit_sha + ); db.update_build_status(&build, BuildStatus::Cancelled) .await?; + repo.client + .post_comment(pr_number, "There was an error cancelling try build!") + .await? + } + Ok(workflow_ids) => { + db.update_build_status(&build, BuildStatus::Cancelled) + .await?; tracing::info!("Try build cancelled"); let mut try_build_cancelled_comment = r#"Try build cancelled. @@ -294,13 +301,15 @@ async fn check_try_permissions( #[cfg(test)] mod tests { + use anyhow::anyhow; use sea_orm::EntityTrait; use entity::workflow; use crate::bors::handlers::trybuild::{TRY_BRANCH_NAME, TRY_MERGE_BRANCH_NAME}; use crate::database::{BuildStatus, DbClient, WorkflowStatus, WorkflowType}; - use crate::github::{CommitSha, LabelTrigger, MergeError}; + use crate::github::{CommitSha, LabelTrigger, MergeError, PullRequestNumber}; + use crate::tests::database::create_test_db; use crate::tests::event::{ default_pr_number, suite_failure, suite_pending, suite_success, WorkflowStartedBuilder, }; @@ -591,6 +600,26 @@ mod tests { "###); } + #[tokio::test] + async fn test_try_cancel_error() { + let mut db = create_test_db().await; + db.get_workflows_for_build = Some(Box::new(|| Err(anyhow::anyhow!("Errr")))); + let mut state = ClientBuilder::default().db(Some(db)).create_state().await; + + state.comment("@bors try").await; + state.comment("@bors try cancel").await; + let name = default_repo_name(); + let pr = state + .db + .get_or_create_pull_request(&name, PullRequestNumber(default_pr_number())) + .await + .unwrap(); + let build = pr.try_build.unwrap(); + assert_eq!(build.status, BuildStatus::Cancelled); + + insta::assert_snapshot!(state.client().get_last_comment(default_pr_number()), @"There was an error cancelling try build!"); + } + #[tokio::test] async fn test_try_cancel_ignore_finished_workflows() { let mut state = ClientBuilder::default().create_state().await; diff --git a/src/tests/database.rs b/src/tests/database.rs index e86ec821..c5295660 100644 --- a/src/tests/database.rs +++ b/src/tests/database.rs @@ -1,11 +1,124 @@ -use sea_orm::Database; - +use axum::async_trait; use migration::{Migrator, MigratorTrait}; +use octocrab::models::RunId; +use sea_orm::Database; +use sea_orm::DatabaseConnection; -use crate::database::SeaORMClient; +use crate::{ + database::{ + BuildModel, BuildStatus, DbClient, PullRequestModel, SeaORMClient, WorkflowModel, + WorkflowStatus, WorkflowType, + }, + github::{CommitSha, GithubRepoName, PullRequestNumber}, +}; -pub async fn create_test_db() -> SeaORMClient { +pub async fn create_test_db() -> MockedDBClient { let db = Database::connect("sqlite::memory:").await.unwrap(); Migrator::up(&db, None).await.unwrap(); - SeaORMClient::new(db.clone()) + MockedDBClient::new(SeaORMClient::new(db.clone())) +} + +pub struct MockedDBClient { + db: SeaORMClient, + pub get_workflows_for_build: + Option anyhow::Result> + Send + Sync>>, +} + +impl MockedDBClient { + fn new(db: SeaORMClient) -> Self { + Self { + db, + get_workflows_for_build: None, + } + } + + pub fn connection(&mut self) -> &mut DatabaseConnection { + self.db.connection() + } +} + +#[async_trait] +impl DbClient for MockedDBClient { + async fn get_or_create_pull_request( + &self, + repo: &GithubRepoName, + pr_number: PullRequestNumber, + ) -> anyhow::Result { + self.db.get_or_create_pull_request(repo, pr_number).await + } + + async fn find_pr_by_build( + &self, + build: &BuildModel, + ) -> anyhow::Result> { + self.db.find_pr_by_build(build).await + } + + async fn attach_try_build( + &self, + pr: PullRequestModel, + branch: String, + commit_sha: CommitSha, + parent: CommitSha, + ) -> anyhow::Result<()> { + self.db + .attach_try_build(pr, branch, commit_sha, parent) + .await + } + + async fn find_build( + &self, + repo: &GithubRepoName, + branch: String, + commit_sha: CommitSha, + ) -> anyhow::Result> { + self.db.find_build(repo, branch, commit_sha).await + } + + async fn get_running_builds(&self, repo: &GithubRepoName) -> anyhow::Result> { + self.db.get_running_builds(repo).await + } + + async fn update_build_status( + &self, + build: &BuildModel, + status: BuildStatus, + ) -> anyhow::Result<()> { + self.db.update_build_status(build, status).await + } + + async fn create_workflow( + &self, + build: &BuildModel, + name: String, + url: String, + run_id: RunId, + workflow_type: WorkflowType, + status: WorkflowStatus, + ) -> anyhow::Result<()> { + self.db + .create_workflow(build, name, url, run_id, workflow_type, status) + .await + } + + /// Updates the status of a workflow with the given run ID in the DB. + async fn update_workflow_status( + &self, + run_id: u64, + status: WorkflowStatus, + ) -> anyhow::Result<()> { + self.db.update_workflow_status(run_id, status).await + } + + /// Get all workflows attached to a build. + async fn get_workflows_for_build( + &self, + build: &BuildModel, + ) -> anyhow::Result> { + if let Some(f) = &self.get_workflows_for_build { + f() + } else { + self.db.get_workflows_for_build(build).await + } + } } diff --git a/src/tests/state.rs b/src/tests/state.rs index cd9ed121..26777137 100644 --- a/src/tests/state.rs +++ b/src/tests/state.rs @@ -10,6 +10,7 @@ use derive_builder::Builder; use octocrab::models::{RunId, UserId}; use url::Url; +use super::database::MockedDBClient; use super::permissions::AllPermissions; use crate::bors::event::{ BorsEvent, CheckSuiteCompleted, PullRequestComment, WorkflowCompleted, WorkflowStarted, @@ -47,7 +48,7 @@ pub fn default_merge_sha() -> String { pub struct TestBorsState { repos: HashMap>, - pub db: SeaORMClient, + pub db: MockedDBClient, } impl TestBorsState { @@ -192,35 +193,35 @@ impl RepoConfigBuilder { #[derive(Builder)] #[builder(pattern = "owned")] pub struct Client { - #[builder(default)] - name: Option, + #[builder(default = "default_repo_name()")] + name: GithubRepoName, #[builder(default = "Box::new(AllPermissions)")] permission_resolver: Box, #[builder(default)] config: RepoConfigBuilder, + #[builder(default)] + db: Option, } impl ClientBuilder { pub async fn create_state(self) -> TestBorsState { - self.create().into_state().await - } - pub fn create(self) -> RepositoryState { let Client { name, permission_resolver, config, + db, } = self.build().unwrap(); let mut branch_history = HashMap::default(); let default_base_branch = default_base_branch(); branch_history.insert(default_base_branch.name, vec![default_base_branch.sha]); + let db = db.unwrap_or(create_test_db().await); - let name = name.unwrap_or_else(default_repo_name); - RepositoryState { + let repo_state = RepositoryState { repository: name.clone(), client: TestRepositoryClient { comments: Default::default(), - name, + name: name.clone(), merge_branches_fn: Box::new(|| Ok(CommitSha(default_merge_sha()))), get_pr_fn: Box::new(move |pr| Ok(PRBuilder::default().number(pr.0).create())), check_suites: Default::default(), @@ -231,18 +232,10 @@ impl ClientBuilder { }, permissions_resolver: permission_resolver, config: config.create(), - } - } -} - -impl RepositoryState { - pub async fn into_state(self) -> TestBorsState { + }; let mut repos = HashMap::new(); - repos.insert(self.repository.clone(), self); - TestBorsState { - repos, - db: create_test_db().await, - } + repos.insert(name.clone(), repo_state); + TestBorsState { repos, db } } } From cb99558d51cb73c427f7ec454b0c3759b56658e3 Mon Sep 17 00:00:00 2001 From: vohoanglong0107 Date: Wed, 3 Apr 2024 11:30:53 +0000 Subject: [PATCH 26/57] fix: clippy --- src/github/api/client.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/github/api/client.rs b/src/github/api/client.rs index 296b8bdb..6faa7d44 100644 --- a/src/github/api/client.rs +++ b/src/github/api/client.rs @@ -195,11 +195,7 @@ impl RepositoryClient for GithubRepositoryClient { // Cancel all workflows in parallel futures::future::join_all(run_ids.iter().map(|run_id| { - actions.cancel_workflow_run( - self.repo_name.owner(), - self.repo_name.name(), - run_id.clone(), - ) + actions.cancel_workflow_run(self.repo_name.owner(), self.repo_name.name(), *run_id) })) .await .into_iter() @@ -266,7 +262,7 @@ impl RepositoryClient for GithubRepositoryClient { self.name().name ) }); - format!("{}/actions/runs/{}", html_url, run_id) + format!("{html_url}/actions/runs/{run_id}") } } From 282aba6396d6b8ff6a7cf3ed739bde89b27aeb6a Mon Sep 17 00:00:00 2001 From: vohoanglong0107 Date: Wed, 3 Apr 2024 11:37:40 +0000 Subject: [PATCH 27/57] fix: use static string for url --- src/github/api/client.rs | 30 +++++++++++++++--------------- src/github/api/mod.rs | 13 ++++--------- src/github/api/operations.rs | 4 ++-- 3 files changed, 21 insertions(+), 26 deletions(-) diff --git a/src/github/api/client.rs b/src/github/api/client.rs index 6faa7d44..48ef0ef7 100644 --- a/src/github/api/client.rs +++ b/src/github/api/client.rs @@ -81,13 +81,13 @@ impl RepositoryClient for GithubRepositoryClient { let branch: octocrab::models::repos::Branch = self .client .get( - base_github_url() - .join(&format!( - "/repos/{}/{}/branches/{name}", - self.repo_name.owner(), - self.repo_name.name(), - ))? - .as_str(), + format!( + "{}/repos/{}/{}/branches/{name}", + base_github_url(), + self.repo_name.owner(), + self.repo_name.name(), + ) + .as_str(), None::<&()>, ) .await @@ -149,14 +149,14 @@ impl RepositoryClient for GithubRepositoryClient { let response: CheckSuiteResponse = self .client .get( - base_github_url() - .join(&format!( - "/repos/{}/{}/commits/{}/check-suites", - self.repo_name.owner(), - self.repo_name.name(), - sha.0 - ))? - .as_str(), + format!( + "{}/repos/{}/{}/commits/{}/check-suites", + base_github_url(), + self.repo_name.owner(), + self.repo_name.name(), + sha.0 + ) + .as_str(), None::<&()>, ) .await diff --git a/src/github/api/mod.rs b/src/github/api/mod.rs index a4dfe04f..da0775ec 100644 --- a/src/github/api/mod.rs +++ b/src/github/api/mod.rs @@ -6,7 +6,6 @@ use anyhow::Context; use octocrab::models::{App, AppId, InstallationRepositories, Repository}; use octocrab::Octocrab; use secrecy::{ExposeSecret, SecretVec}; -use url::Url; use client::GithubRepositoryClient; @@ -23,16 +22,12 @@ type GHRepositoryState = RepositoryState; type RepositoryMap = HashMap; -fn base_github_html_url() -> Url { - let url = std::cell::OnceCell::new(); - url.get_or_init(|| Url::parse("https://github.com").expect("Cannot parse base GitHub URL")) - .clone() +fn base_github_html_url() -> &'static str { + "https://github.com" } -fn base_github_url() -> Url { - let url = std::cell::OnceCell::new(); - url.get_or_init(|| Url::parse("https://api.github.com").expect("Cannot parse base GitHub URL")) - .clone() +fn base_github_url() -> &'static str { + "https://api.github.com" } /// Provides access to managed GitHub repositories. diff --git a/src/github/api/operations.rs b/src/github/api/operations.rs index 8c9d8070..b16b974c 100644 --- a/src/github/api/operations.rs +++ b/src/github/api/operations.rs @@ -150,7 +150,8 @@ async fn update_branch( sha: &CommitSha, ) -> Result<(), BranchUpdateError> { let url = format!( - "repos/{}/{}/git/refs/{}", + "{}/repos/{}/{}/git/refs/{}", + base_github_url(), repo.name().owner(), repo.name().name(), Reference::Branch(branch_name.clone()).ref_url() @@ -158,7 +159,6 @@ async fn update_branch( tracing::debug!("Updating branch {} to SHA {}", url, sha.as_ref()); - let url = base_github_url().join(&url).unwrap(); let res = repo .client ._patch( From 64facf43fd1c15bc404e4070dfcde8ba96a4a86b Mon Sep 17 00:00:00 2001 From: vohoanglong0107 Date: Thu, 4 Apr 2024 00:22:59 +0000 Subject: [PATCH 28/57] fix: don't need async function --- src/bors/handlers/trybuild.rs | 3 +-- src/bors/mod.rs | 2 +- src/github/api/client.rs | 2 +- src/tests/state.rs | 4 ++-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/bors/handlers/trybuild.rs b/src/bors/handlers/trybuild.rs index 88c8bec6..2b3d1790 100644 --- a/src/bors/handlers/trybuild.rs +++ b/src/bors/handlers/trybuild.rs @@ -190,7 +190,7 @@ pub(super) async fn command_try_cancel( Cancelled workflows:"# .to_string(); for id in workflow_ids { - let url = repo.client.get_workflow_url(id).await; + let url = repo.client.get_workflow_url(id); try_build_cancelled_comment += format!("\n- {}", url).as_str(); } repo.client @@ -301,7 +301,6 @@ async fn check_try_permissions( #[cfg(test)] mod tests { - use anyhow::anyhow; use sea_orm::EntityTrait; use entity::workflow; diff --git a/src/bors/mod.rs b/src/bors/mod.rs index a2008101..75aa7ddf 100644 --- a/src/bors/mod.rs +++ b/src/bors/mod.rs @@ -67,7 +67,7 @@ pub trait RepositoryClient { ) -> anyhow::Result<()>; /// Get a workflow url - async fn get_workflow_url(&mut self, run_id: RunId) -> String; + fn get_workflow_url(&self, run_id: RunId) -> String; } #[derive(Clone)] diff --git a/src/github/api/client.rs b/src/github/api/client.rs index 48ef0ef7..3408174a 100644 --- a/src/github/api/client.rs +++ b/src/github/api/client.rs @@ -248,7 +248,7 @@ impl RepositoryClient for GithubRepositoryClient { Ok(()) } - async fn get_workflow_url(&mut self, run_id: RunId) -> String { + fn get_workflow_url(&self, run_id: RunId) -> String { let html_url = self .repository .html_url diff --git a/src/tests/state.rs b/src/tests/state.rs index 26777137..c66eaa22 100644 --- a/src/tests/state.rs +++ b/src/tests/state.rs @@ -17,7 +17,7 @@ use crate::bors::event::{ }; use crate::bors::{handle_bors_event, BorsContext, CheckSuite, CommandParser, RepositoryState}; use crate::bors::{BorsState, RepositoryClient}; -use crate::database::{DbClient, SeaORMClient, WorkflowStatus}; +use crate::database::{DbClient, WorkflowStatus}; use crate::github::{ CommitSha, GithubRepoName, GithubUser, LabelModification, LabelTrigger, PullRequest, }; @@ -410,7 +410,7 @@ impl RepositoryClient for TestRepositoryClient { Ok(RepoConfigBuilder::default().create()) } - async fn get_workflow_url(&mut self, run_id: RunId) -> String { + fn get_workflow_url(&self, run_id: RunId) -> String { let mut url = Url::parse("https://github.com").expect("Cannot parse base GitHub URL"); url.set_path( format!( From f8086b417f5526098942d52e2ea630eee5119d73 Mon Sep 17 00:00:00 2001 From: vohoanglong0107 Date: Thu, 4 Apr 2024 00:24:57 +0000 Subject: [PATCH 29/57] fix: reword cancel error message --- src/bors/handlers/trybuild.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/bors/handlers/trybuild.rs b/src/bors/handlers/trybuild.rs index 2b3d1790..36a7ab9f 100644 --- a/src/bors/handlers/trybuild.rs +++ b/src/bors/handlers/trybuild.rs @@ -178,7 +178,10 @@ pub(super) async fn command_try_cancel( .await?; repo.client - .post_comment(pr_number, "There was an error cancelling try build!") + .post_comment( + pr_number, + "Try build was cancelled. It was not possible to cancel some workflows.", + ) .await? } Ok(workflow_ids) => { @@ -616,7 +619,7 @@ mod tests { let build = pr.try_build.unwrap(); assert_eq!(build.status, BuildStatus::Cancelled); - insta::assert_snapshot!(state.client().get_last_comment(default_pr_number()), @"There was an error cancelling try build!"); + insta::assert_snapshot!(state.client().get_last_comment(default_pr_number()), @"Try build was cancelled. It was not possible to cancel some workflows."); } #[tokio::test] From 290e57d22847c4ea85b1409f4c6be6d024eff84d Mon Sep 17 00:00:00 2001 From: vohoanglong0107 Date: Tue, 9 Apr 2024 02:56:44 +0000 Subject: [PATCH 30/57] refactor: Arc and RwLock instead of &mut --- src/bors/handlers/help.rs | 4 ++- src/bors/handlers/labels.rs | 35 ++++++++++++----------- src/bors/handlers/mod.rs | 36 ++++++++++++++--------- src/bors/handlers/ping.rs | 4 ++- src/bors/handlers/refresh.rs | 14 ++++----- src/bors/handlers/trybuild.rs | 18 +++++++----- src/bors/handlers/workflow.rs | 18 ++++++------ src/bors/mod.rs | 54 ++++++++++++++++------------------- src/database/mod.rs | 2 +- src/github/api/client.rs | 24 +++++++--------- src/github/api/mod.rs | 53 +++++++++++++++++++--------------- src/github/server.rs | 24 ++++++++++------ src/permissions.rs | 2 +- 13 files changed, 154 insertions(+), 134 deletions(-) diff --git a/src/bors/handlers/help.rs b/src/bors/handlers/help.rs index 2a28b5bd..a60802c3 100644 --- a/src/bors/handlers/help.rs +++ b/src/bors/handlers/help.rs @@ -1,3 +1,5 @@ +use std::sync::Arc; + use crate::bors::RepositoryClient; use crate::bors::RepositoryState; use crate::github::PullRequest; @@ -10,7 +12,7 @@ const HELP_MESSAGE: &str = r#" "#; pub(super) async fn command_help( - repo: &mut RepositoryState, + repo: Arc>, pr: &PullRequest, ) -> anyhow::Result<()> { repo.client.post_comment(pr.number, HELP_MESSAGE).await?; diff --git a/src/bors/handlers/labels.rs b/src/bors/handlers/labels.rs index 5ec1b80b..80f4b5ee 100644 --- a/src/bors/handlers/labels.rs +++ b/src/bors/handlers/labels.rs @@ -7,27 +7,28 @@ use crate::github::{LabelModification, LabelTrigger, PullRequestNumber}; /// If there are any label modifications that should be performed on the given PR when `trigger` /// happens, this function will perform them. pub async fn handle_label_trigger( - repo: &mut RepositoryState, + repo: &RepositoryState, pr: PullRequestNumber, trigger: LabelTrigger, ) -> anyhow::Result<()> { - if let Some(modifications) = repo.config.labels.get(&trigger) { + let mut add: Vec = Vec::new(); + let mut remove: Vec = Vec::new(); + if let Some(modifications) = repo.config.read().unwrap().labels.get(&trigger) { log::debug!("Performing label modifications {modifications:?}"); - let (add, remove): (Vec<_>, Vec<_>) = - modifications - .iter() - .partition_map(|modification| match modification { - LabelModification::Add(label) => itertools::Either::Left(label.clone()), - LabelModification::Remove(label) => itertools::Either::Right(label.clone()), - }); - if !add.is_empty() { - log::info!("Adding label(s) {add:?}"); - repo.client.add_labels(pr, &add).await?; - } - if !remove.is_empty() { - log::info!("Removing label(s) {remove:?}"); - repo.client.remove_labels(pr, &remove).await?; - } + (add, remove) = modifications + .iter() + .partition_map(|modification| match modification { + LabelModification::Add(label) => itertools::Either::Left(label.clone()), + LabelModification::Remove(label) => itertools::Either::Right(label.clone()), + }); + } + if !add.is_empty() { + log::info!("Adding label(s) {add:?}"); + repo.client.add_labels(pr, &add).await?; + } + if !remove.is_empty() { + log::info!("Removing label(s) {remove:?}"); + repo.client.remove_labels(pr, &remove).await?; } Ok(()) } diff --git a/src/bors/handlers/mod.rs b/src/bors/handlers/mod.rs index 495630d2..b5486da5 100644 --- a/src/bors/handlers/mod.rs +++ b/src/bors/handlers/mod.rs @@ -1,4 +1,5 @@ use anyhow::Context; +use std::sync::Arc; use tracing::Instrument; use crate::bors::command::BorsCommand; @@ -26,8 +27,8 @@ mod workflow; /// This function performs a single BORS event, it is the main execution function of the bot. pub async fn handle_bors_event( event: BorsEvent, - state: &mut dyn BorsState, - ctx: &BorsContext, + state: Arc>, + ctx: Arc, ) -> anyhow::Result<()> { match event { BorsEvent::Comment(comment) => { @@ -44,7 +45,7 @@ pub async fn handle_bors_event( author = comment.author.username ); let pr_number = comment.pr_number; - if let Err(error) = handle_comment(repo, db, ctx, comment) + if let Err(error) = handle_comment(Arc::clone(&repo), db, ctx, comment) .instrument(span.clone()) .await { @@ -111,10 +112,15 @@ pub async fn handle_bors_event( } BorsEvent::Refresh => { let span = tracing::info_span!("Refresh"); - let (repos, db) = state.get_all_repos_mut(); - futures::future::join_all(repos.into_iter().map(|repo| async { - let subspan = tracing::info_span!("Repo", repo = repo.repository.to_string()); - refresh_repository(repo, db).instrument(subspan).await + let (repos, db) = state.get_all_repos(); + futures::future::join_all(repos.into_iter().map(|repo| { + let repo = Arc::clone(&repo); + async { + let subspan = tracing::info_span!("Repo", repo = repo.repository.to_string()); + refresh_repository(repo, Arc::clone(&db)) + .instrument(subspan) + .await + } })) .instrument(span) .await; @@ -123,11 +129,11 @@ pub async fn handle_bors_event( Ok(()) } -fn get_repo_state<'a, Client: RepositoryClient>( - state: &'a mut dyn BorsState, +fn get_repo_state( + state: Arc>, repo: &GithubRepoName, -) -> Option<(&'a mut RepositoryState, &'a mut dyn DbClient)> { - match state.get_repo_state_mut(repo) { +) -> Option<(Arc>, Arc)> { + match state.get_repo_state(repo) { Some(result) => Some(result), None => { tracing::warn!("Repository {} not found", repo); @@ -137,9 +143,9 @@ fn get_repo_state<'a, Client: RepositoryClient>( } async fn handle_comment( - repo: &mut RepositoryState, - database: &mut dyn DbClient, - ctx: &BorsContext, + repo: Arc>, + database: Arc, + ctx: Arc, comment: PullRequestComment, ) -> anyhow::Result<()> { let pr_number = comment.pr_number; @@ -163,6 +169,8 @@ async fn handle_comment( for command in commands { match command { Ok(command) => { + let repo = Arc::clone(&repo); + let database = Arc::clone(&database); let result = match command { BorsCommand::Help => { let span = tracing::info_span!("Help"); diff --git a/src/bors/handlers/ping.rs b/src/bors/handlers/ping.rs index 6e6868d6..71707d4e 100644 --- a/src/bors/handlers/ping.rs +++ b/src/bors/handlers/ping.rs @@ -1,9 +1,11 @@ +use std::sync::Arc; + use crate::bors::RepositoryClient; use crate::bors::RepositoryState; use crate::github::PullRequest; pub(super) async fn command_ping( - repo: &mut RepositoryState, + repo: Arc>, pr: &PullRequest, ) -> anyhow::Result<()> { repo.client.post_comment(pr.number, "Pong 🏓!").await?; diff --git a/src/bors/handlers/refresh.rs b/src/bors/handlers/refresh.rs index 17aec07e..dcc5a820 100644 --- a/src/bors/handlers/refresh.rs +++ b/src/bors/handlers/refresh.rs @@ -7,8 +7,8 @@ use crate::bors::{RepositoryClient, RepositoryState}; use crate::database::{BuildStatus, DbClient}; pub async fn refresh_repository( - repo: &mut RepositoryState, - db: &dyn DbClient, + repo: Arc>, + db: Arc, ) -> anyhow::Result<()> { let res = cancel_timed_out_builds(repo, db).await; reload_permission(repo).await; @@ -18,14 +18,14 @@ pub async fn refresh_repository( } async fn cancel_timed_out_builds( - repo: &mut RepositoryState, + repo: &RepositoryState, db: &dyn DbClient, ) -> anyhow::Result<()> { let running_builds = db.get_running_builds(&repo.repository).await?; tracing::info!("Found {} running build(s)", running_builds.len()); + let timeout = repo.config.read().unwrap().timeout.clone(); for build in running_builds { - let timeout = repo.config.timeout; if elapsed_time(build.created_at) >= timeout { tracing::info!("Cancelling build {}", build.commit_sha); @@ -54,15 +54,15 @@ async fn cancel_timed_out_builds( Ok(()) } -async fn reload_permission(repo: &mut RepositoryState) { +async fn reload_permission(repo: &RepositoryState) { repo.permissions_resolver.reload().await } async fn reload_config( - repo: &mut RepositoryState, + repo: &RepositoryState, ) -> anyhow::Result<()> { let config = repo.client.load_config().await?; - repo.config = config; + *repo.config.write().unwrap() = config; Ok(()) } diff --git a/src/bors/handlers/trybuild.rs b/src/bors/handlers/trybuild.rs index 36a7ab9f..0dbbe3ff 100644 --- a/src/bors/handlers/trybuild.rs +++ b/src/bors/handlers/trybuild.rs @@ -1,3 +1,5 @@ +use std::sync::Arc; + use anyhow::{anyhow, Context}; use octocrab::models::RunId; @@ -28,12 +30,13 @@ pub(super) const TRY_BRANCH_NAME: &str = "automation/bors/try"; /// If `parent` is set, it will use it as a base commit for the merge. /// Otherwise, it will use the latest commit on the main repository branch. pub(super) async fn command_try_build( - repo: &mut RepositoryState, - db: &mut dyn DbClient, + repo: Arc>, + db: Arc, pr: &PullRequest, author: &GithubUser, parent: Option, ) -> anyhow::Result<()> { + let repo = repo.as_ref(); if !check_try_permissions(repo, pr, author).await? { return Ok(()); } @@ -143,11 +146,12 @@ pub(super) async fn command_try_build( } pub(super) async fn command_try_cancel( - repo: &mut RepositoryState, - db: &mut dyn DbClient, + repo: Arc>, + db: Arc, pr: &PullRequest, author: &GithubUser, ) -> anyhow::Result<()> { + let repo = repo.as_ref(); if !check_try_permissions(repo, pr, author).await? { return Ok(()); } @@ -168,7 +172,7 @@ pub(super) async fn command_try_cancel( return Ok(()); }; - match cancel_build_workflows(repo, db, &build).await { + match cancel_build_workflows(repo, db.as_ref(), &build).await { Err(error) => { tracing::error!( "Could not cancel workflows for SHA {}: {error:?}", @@ -206,7 +210,7 @@ Cancelled workflows:"# } pub async fn cancel_build_workflows( - repo: &mut RepositoryState, + repo: &RepositoryState, db: &dyn DbClient, build: &BuildModel, ) -> anyhow::Result> { @@ -276,7 +280,7 @@ handled during merge and rebase. This is normal, and you should still perform st } async fn check_try_permissions( - repo: &mut RepositoryState, + repo: &RepositoryState, pr: &PullRequest, author: &GithubUser, ) -> anyhow::Result { diff --git a/src/bors/handlers/workflow.rs b/src/bors/handlers/workflow.rs index 27f9726b..e0c2e442 100644 --- a/src/bors/handlers/workflow.rs +++ b/src/bors/handlers/workflow.rs @@ -6,7 +6,7 @@ use crate::database::{BuildStatus, DbClient, WorkflowStatus}; use crate::github::LabelTrigger; pub(super) async fn handle_workflow_started( - db: &mut dyn DbClient, + db: Arc, payload: WorkflowStarted, ) -> anyhow::Result<()> { if !is_bors_observed_branch(&payload.branch) { @@ -54,8 +54,8 @@ pub(super) async fn handle_workflow_started( } pub(super) async fn handle_workflow_completed( - repo: &mut RepositoryState, - db: &mut dyn DbClient, + repo: Arc>, + db: Arc, payload: WorkflowCompleted, ) -> anyhow::Result<()> { if !is_bors_observed_branch(&payload.branch) { @@ -72,12 +72,12 @@ pub(super) async fn handle_workflow_completed( branch: payload.branch, commit_sha: payload.commit_sha, }; - try_complete_build(repo, db, event).await + try_complete_build(repo.as_ref(), db.as_ref(), event).await } pub(super) async fn handle_check_suite_completed( - repo: &mut RepositoryState, - db: &mut dyn DbClient, + repo: Arc>, + db: Arc, payload: CheckSuiteCompleted, ) -> anyhow::Result<()> { if !is_bors_observed_branch(&payload.branch) { @@ -89,12 +89,12 @@ pub(super) async fn handle_check_suite_completed( payload.branch, payload.commit_sha ); - try_complete_build(repo, db, payload).await + try_complete_build(repo.as_ref(), db.as_ref(), payload).await } async fn try_complete_build( - repo: &mut RepositoryState, - db: &mut dyn DbClient, + repo: &RepositoryState, + db: &dyn DbClient, payload: CheckSuiteCompleted, ) -> anyhow::Result<()> { if !is_bors_observed_branch(&payload.branch) { diff --git a/src/bors/mod.rs b/src/bors/mod.rs index 75aa7ddf..47fa6248 100644 --- a/src/bors/mod.rs +++ b/src/bors/mod.rs @@ -1,46 +1,44 @@ -use crate::config::RepositoryConfig; -use axum::async_trait; -use octocrab::models::RunId; -use std::future::Future; -use std::pin::Pin; - -use crate::github::{CommitSha, GithubRepoName, MergeError, PullRequest, PullRequestNumber}; -use crate::permissions::PermissionResolver; - mod command; mod context; pub mod event; mod handlers; +use std::sync::{Arc, RwLock}; + +use octocrab::models::RunId; + use crate::bors::event::PullRequestComment; +use crate::config::RepositoryConfig; use crate::database::DbClient; +use crate::github::{CommitSha, GithubRepoName, MergeError, PullRequest, PullRequestNumber}; +use crate::permissions::PermissionResolver; pub use command::CommandParser; pub use context::BorsContext; pub use handlers::handle_bors_event; /// Provides functionality for working with a remote repository. #[async_trait] -pub trait RepositoryClient { +pub trait RepositoryClient: Send + Sync { fn repository(&self) -> &GithubRepoName; /// load repository config - async fn load_config(&mut self) -> anyhow::Result; + async fn load_config(&self) -> anyhow::Result; /// Return the current SHA of the given branch. - async fn get_branch_sha(&mut self, name: &str) -> anyhow::Result; + async fn get_branch_sha(&self, name: &str) -> anyhow::Result; /// Resolve a pull request from this repository by it's number. - async fn get_pull_request(&mut self, pr: PullRequestNumber) -> anyhow::Result; + async fn get_pull_request(&self, pr: PullRequestNumber) -> anyhow::Result; /// Post a comment to the pull request with the given number. - async fn post_comment(&mut self, pr: PullRequestNumber, text: &str) -> anyhow::Result<()>; + async fn post_comment(&self, pr: PullRequestNumber, text: &str) -> anyhow::Result<()>; /// Set the given branch to a commit with the given `sha`. - async fn set_branch_to_sha(&mut self, branch: &str, sha: &CommitSha) -> anyhow::Result<()>; + async fn set_branch_to_sha(&self, branch: &str, sha: &CommitSha) -> anyhow::Result<()>; /// Merge `head` into `base`. Returns the SHA of the merge commit. async fn merge_branches( - &mut self, + &self, base: &str, head: &CommitSha, commit_message: &str, @@ -48,23 +46,19 @@ pub trait RepositoryClient { /// Find all check suites attached to the given commit and branch. async fn get_check_suites_for_commit( - &mut self, + &self, branch: &str, sha: &CommitSha, ) -> anyhow::Result>; /// Cancels Github Actions workflows. - async fn cancel_workflows(&mut self, run_ids: &[RunId]) -> anyhow::Result<()>; + async fn cancel_workflows(&self, run_ids: &[RunId]) -> anyhow::Result<()>; /// Add a set of labels to a PR. - async fn add_labels(&mut self, pr: PullRequestNumber, labels: &[String]) -> anyhow::Result<()>; + async fn add_labels(&self, pr: PullRequestNumber, labels: &[String]) -> anyhow::Result<()>; /// Remove a set of labels from a PR. - async fn remove_labels( - &mut self, - pr: PullRequestNumber, - labels: &[String], - ) -> anyhow::Result<()>; + async fn remove_labels(&self, pr: PullRequestNumber, labels: &[String]) -> anyhow::Result<()>; /// Get a workflow url fn get_workflow_url(&self, run_id: RunId) -> String; @@ -86,18 +80,18 @@ pub struct CheckSuite { /// Main state holder for the bot. /// It is behind a trait to allow easier mocking in tests. -pub trait BorsState { +pub trait BorsState: Send + Sync { /// Was the comment created by the bot? fn is_comment_internal(&self, comment: &PullRequestComment) -> bool; /// Get repository and database state for the given repository name. - fn get_repo_state_mut( - &mut self, + fn get_repo_state( + &self, repo: &GithubRepoName, - ) -> Option<(&mut RepositoryState, &mut dyn DbClient)>; + ) -> Option<(Arc>, Arc)>; /// Get all repositories. - fn get_all_repos_mut(&mut self) -> (Vec<&mut RepositoryState>, &mut dyn DbClient); + fn get_all_repos(&self) -> (Vec>>, Arc); /// Reload state of repositories due to some external change. fn reload_repositories(&mut self) -> Pin> + '_>>; @@ -110,5 +104,5 @@ pub struct RepositoryState { pub repository: GithubRepoName, pub client: Client, pub permissions_resolver: Box, - pub config: RepositoryConfig, + pub config: RwLock, } diff --git a/src/database/mod.rs b/src/database/mod.rs index e3762be6..29f3cf25 100644 --- a/src/database/mod.rs +++ b/src/database/mod.rs @@ -86,7 +86,7 @@ pub struct WorkflowModel { /// Provides access to a database. #[async_trait] -pub trait DbClient { +pub trait DbClient: Sync + Send { /// Finds a Pull request row for the given repository and PR number. /// If it doesn't exist, a new row is created. async fn get_or_create_pull_request( diff --git a/src/github/api/client.rs b/src/github/api/client.rs index 3408174a..54c12b28 100644 --- a/src/github/api/client.rs +++ b/src/github/api/client.rs @@ -44,7 +44,7 @@ impl RepositoryClient for GithubRepositoryClient { /// Loads repository configuration from a file located at `[CONFIG_FILE_PATH]` in the main /// branch. - async fn load_config(&mut self) -> anyhow::Result { + async fn load_config(&self) -> anyhow::Result { let mut response = self .client .repos(&self.repo_name.owner, &self.repo_name.name) @@ -76,7 +76,7 @@ impl RepositoryClient for GithubRepositoryClient { }) } - async fn get_branch_sha(&mut self, name: &str) -> anyhow::Result { + async fn get_branch_sha(&self, name: &str) -> anyhow::Result { // https://docs.github.com/en/rest/branches/branches?apiVersion=2022-11-28#get-a-branch let branch: octocrab::models::repos::Branch = self .client @@ -95,7 +95,7 @@ impl RepositoryClient for GithubRepositoryClient { Ok(CommitSha(branch.commit.sha)) } - async fn get_pull_request(&mut self, pr: PullRequestNumber) -> anyhow::Result { + async fn get_pull_request(&self, pr: PullRequestNumber) -> anyhow::Result { let pr = self .client .pulls(self.repository().owner(), self.repository().name()) @@ -108,7 +108,7 @@ impl RepositoryClient for GithubRepositoryClient { } /// The comment will be posted as the Github App user of the bot. - async fn post_comment(&mut self, pr: PullRequestNumber, text: &str) -> anyhow::Result<()> { + async fn post_comment(&self, pr: PullRequestNumber, text: &str) -> anyhow::Result<()> { self.client .issues(&self.name().owner, &self.name().name) .create_comment(pr.0, text) @@ -117,12 +117,12 @@ impl RepositoryClient for GithubRepositoryClient { Ok(()) } - async fn set_branch_to_sha(&mut self, branch: &str, sha: &CommitSha) -> anyhow::Result<()> { + async fn set_branch_to_sha(&self, branch: &str, sha: &CommitSha) -> anyhow::Result<()> { Ok(set_branch_to_commit(self, branch.to_string(), sha).await?) } async fn merge_branches( - &mut self, + &self, base: &str, head: &CommitSha, commit_message: &str, @@ -131,7 +131,7 @@ impl RepositoryClient for GithubRepositoryClient { } async fn get_check_suites_for_commit( - &mut self, + &self, branch: &str, sha: &CommitSha, ) -> anyhow::Result> { @@ -190,7 +190,7 @@ impl RepositoryClient for GithubRepositoryClient { Ok(suites) } - async fn cancel_workflows(&mut self, run_ids: &[RunId]) -> anyhow::Result<()> { + async fn cancel_workflows(&self, run_ids: &[RunId]) -> anyhow::Result<()> { let actions = self.client.actions(); // Cancel all workflows in parallel @@ -204,7 +204,7 @@ impl RepositoryClient for GithubRepositoryClient { Ok(()) } - async fn add_labels(&mut self, pr: PullRequestNumber, labels: &[String]) -> anyhow::Result<()> { + async fn add_labels(&self, pr: PullRequestNumber, labels: &[String]) -> anyhow::Result<()> { let client = self.client.issues(self.name().owner(), self.name().name()); if !labels.is_empty() { client @@ -216,11 +216,7 @@ impl RepositoryClient for GithubRepositoryClient { Ok(()) } - async fn remove_labels( - &mut self, - pr: PullRequestNumber, - labels: &[String], - ) -> anyhow::Result<()> { + async fn remove_labels(&self, pr: PullRequestNumber, labels: &[String]) -> anyhow::Result<()> { let client = self.client.issues(self.name().owner(), self.name().name()); // The GitHub API only allows removing labels one by one, so we remove all of them in // parallel to speed it up a little. diff --git a/src/github/api/mod.rs b/src/github/api/mod.rs index da0775ec..9b6f1295 100644 --- a/src/github/api/mod.rs +++ b/src/github/api/mod.rs @@ -1,8 +1,8 @@ use std::collections::HashMap; -use std::future::Future; -use std::pin::Pin; +use std::sync::{Arc, RwLock}; use anyhow::Context; +use axum::async_trait; use octocrab::models::{App, AppId, InstallationRepositories, Repository}; use octocrab::Octocrab; use secrecy::{ExposeSecret, SecretVec}; @@ -20,7 +20,7 @@ pub(crate) mod operations; type GHRepositoryState = RepositoryState; -type RepositoryMap = HashMap; +type RepositoryMap = HashMap>; fn base_github_html_url() -> &'static str { "https://github.com" @@ -34,8 +34,8 @@ fn base_github_url() -> &'static str { pub struct GithubAppState { app: App, client: Octocrab, - repositories: RepositoryMap, - db: SeaORMClient, + repositories: Arc>, + db: Arc, } impl GithubAppState { @@ -63,8 +63,8 @@ impl GithubAppState { Ok(GithubAppState { app, client, - repositories, - db, + repositories: Arc::new(RwLock::new(repositories)), + db: Arc::new(db), }) } } @@ -100,8 +100,8 @@ pub async fn load_repositories(client: &Octocrab) -> anyhow::Result { tracing::info!("Loaded repository {}", repo_state.repository); - if let Some(existing) = - repositories.insert(repo_state.repository.clone(), repo_state) + if let Some(existing) = repositories + .insert(repo_state.repository.clone(), Arc::new(repo_state)) { return Err(anyhow::anyhow!( "Repository {} found in multiple installations!", @@ -141,7 +141,7 @@ async fn create_repo_state( let name = GithubRepoName::new(&owner.login, &repo.name); tracing::info!("Found repository {name}"); - let mut client = GithubRepositoryClient { + let client = GithubRepositoryClient { client: repo_client, repo_name: name.clone(), repository: repo, @@ -166,7 +166,7 @@ async fn create_repo_state( Ok(RepositoryState { repository: name, client, - config, + config: RwLock::new(config), permissions_resolver: Box::new(permissions_resolver), }) } @@ -176,27 +176,34 @@ impl BorsState for GithubAppState { comment.author.html_url == self.app.html_url } - fn get_repo_state_mut( - &mut self, + fn get_repo_state( + &self, repo: &GithubRepoName, ) -> Option<( - &mut RepositoryState, - &mut dyn DbClient, + Arc>, + Arc, )> { self.repositories - .get_mut(repo) - .map(|repo| (repo, (&mut self.db) as &mut dyn DbClient)) + .read() + .unwrap() + .get(repo) + .map(|repo| (Arc::clone(&repo), Arc::clone(&self.db) as Arc)) } - fn get_all_repos_mut( - &mut self, + fn get_all_repos( + &self, ) -> ( - Vec<&mut RepositoryState>, - &mut dyn DbClient, + Vec>>, + Arc, ) { ( - self.repositories.values_mut().collect(), - (&mut self.db) as &mut dyn DbClient, + self.repositories + .read() + .unwrap() + .values() + .cloned() + .collect(), + Arc::clone(&self.db) as Arc, ) } diff --git a/src/github/server.rs b/src/github/server.rs index 0f3fd042..a55dca4a 100644 --- a/src/github/server.rs +++ b/src/github/server.rs @@ -1,5 +1,5 @@ use crate::bors::event::BorsEvent; -use crate::bors::{handle_bors_event, BorsContext}; +use crate::bors::{handle_bors_event, BorsContext, BorsState}; use crate::github::api::GithubAppState; use crate::github::webhook::GitHubWebhook; use crate::github::webhook::WebhookSecret; @@ -52,22 +52,28 @@ type WebhookSender = mpsc::Sender; /// Creates a future with a Bors process that continuously receives webhook events and reacts to /// them. pub fn create_bors_process( - mut state: GithubAppState, + state: GithubAppState, ctx: BorsContext, ) -> (WebhookSender, impl Future) { let (tx, mut rx) = mpsc::channel::(1024); let service = async move { + let state: Arc> = Arc::new(state); + let ctx = Arc::new(ctx); while let Some(event) = rx.recv().await { tracing::trace!("Received event: {event:#?}"); + let state = state.clone(); + let ctx = ctx.clone(); - let span = tracing::info_span!("Event"); - if let Err(error) = handle_bors_event(event, &mut state, &ctx) - .instrument(span.clone()) - .await - { - span.log_error(error); - } + tokio::spawn(async move { + let span = tracing::info_span!("Event"); + if let Err(error) = handle_bors_event(event, state, ctx) + .instrument(span.clone()) + .await + { + span.log_error(error); + } + }); } }; (tx, service) diff --git a/src/permissions.rs b/src/permissions.rs index 760b4370..b26ed7d6 100644 --- a/src/permissions.rs +++ b/src/permissions.rs @@ -14,7 +14,7 @@ pub enum PermissionType { /// Decides if a GitHub user can perform various actions using the bot. #[async_trait] -pub trait PermissionResolver { +pub trait PermissionResolver: Sync + Send { async fn has_permission(&self, user_id: &UserId, permission: PermissionType) -> bool; async fn reload(&self); } From 7d3ffeda792094cfb0b86f38c957c32ecd15e685 Mon Sep 17 00:00:00 2001 From: vohoanglong0107 Date: Tue, 9 Apr 2024 02:58:03 +0000 Subject: [PATCH 31/57] refactor: run refresh commands in parallel --- src/bors/handlers/refresh.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/bors/handlers/refresh.rs b/src/bors/handlers/refresh.rs index dcc5a820..c984fc49 100644 --- a/src/bors/handlers/refresh.rs +++ b/src/bors/handlers/refresh.rs @@ -1,3 +1,4 @@ +use std::sync::Arc; use std::time::Duration; use chrono::{DateTime, Utc}; @@ -10,11 +11,17 @@ pub async fn refresh_repository( repo: Arc>, db: Arc, ) -> anyhow::Result<()> { - let res = cancel_timed_out_builds(repo, db).await; - reload_permission(repo).await; - reload_config(repo).await?; - - res + let repo = repo.as_ref(); + if let (Ok(_), _, Ok(_)) = tokio::join!( + cancel_timed_out_builds(repo, db.as_ref()), + reload_permission(repo), + reload_config(repo) + ) { + Ok(()) + } else { + tracing::error!("Failed to refresh repository"); + anyhow::bail!("Failed to refresh repository") + } } async fn cancel_timed_out_builds( From 134ce42dcf7ebcc02f59feb6dda32e6e119b7392 Mon Sep 17 00:00:00 2001 From: vohoanglong0107 Date: Tue, 9 Apr 2024 02:59:37 +0000 Subject: [PATCH 32/57] refactor: use async trait in BorsState --- src/bors/mod.rs | 4 +++- src/github/api/mod.rs | 9 ++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/bors/mod.rs b/src/bors/mod.rs index 47fa6248..740a74ad 100644 --- a/src/bors/mod.rs +++ b/src/bors/mod.rs @@ -5,6 +5,7 @@ mod handlers; use std::sync::{Arc, RwLock}; +use axum::async_trait; use octocrab::models::RunId; use crate::bors::event::PullRequestComment; @@ -80,6 +81,7 @@ pub struct CheckSuite { /// Main state holder for the bot. /// It is behind a trait to allow easier mocking in tests. +#[async_trait] pub trait BorsState: Send + Sync { /// Was the comment created by the bot? fn is_comment_internal(&self, comment: &PullRequestComment) -> bool; @@ -94,7 +96,7 @@ pub trait BorsState: Send + Sync { fn get_all_repos(&self) -> (Vec>>, Arc); /// Reload state of repositories due to some external change. - fn reload_repositories(&mut self) -> Pin> + '_>>; + async fn reload_repositories(&self) -> anyhow::Result<()>; } /// An access point to a single repository. diff --git a/src/github/api/mod.rs b/src/github/api/mod.rs index 9b6f1295..0a208b72 100644 --- a/src/github/api/mod.rs +++ b/src/github/api/mod.rs @@ -171,6 +171,7 @@ async fn create_repo_state( }) } +#[async_trait] impl BorsState for GithubAppState { fn is_comment_internal(&self, comment: &PullRequestComment) -> bool { comment.author.html_url == self.app.html_url @@ -208,10 +209,8 @@ impl BorsState for GithubAppState { } /// Re-download information about repositories connected to this GitHub app. - fn reload_repositories(&mut self) -> Pin> + '_>> { - Box::pin(async move { - self.repositories = load_repositories(&self.client).await?; - Ok(()) - }) + async fn reload_repositories(&self) -> anyhow::Result<()> { + *self.repositories.write().unwrap() = load_repositories(&self.client).await?; + Ok(()) } } From a3a428be62a4b82f1adac0902d68202182962f85 Mon Sep 17 00:00:00 2001 From: vohoanglong0107 Date: Tue, 9 Apr 2024 03:00:20 +0000 Subject: [PATCH 33/57] fix: remove deprecated function --- src/database/sea_orm_client.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/database/sea_orm_client.rs b/src/database/sea_orm_client.rs index c63b22d6..8ab2ae13 100644 --- a/src/database/sea_orm_client.rs +++ b/src/database/sea_orm_client.rs @@ -310,7 +310,7 @@ fn pr_from_db(pr: pull_request::Model, build: Option) -> PullReque } fn datetime_from_db(datetime: NaiveDateTime) -> DateTime { - DateTime::from_utc(datetime, Utc) + DateTime::from_naive_utc_and_offset(datetime, Utc) } fn full_repo_name(repo: &GithubRepoName) -> String { From 73abe2839e764b823e9d57bc408877b09a52385a Mon Sep 17 00:00:00 2001 From: vohoanglong0107 Date: Tue, 9 Apr 2024 03:00:51 +0000 Subject: [PATCH 34/57] refactors: update tests --- src/bors/handlers/help.rs | 2 +- src/bors/handlers/mod.rs | 8 +- src/bors/handlers/ping.rs | 2 +- src/bors/handlers/trybuild.rs | 55 ++++---- src/bors/handlers/workflow.rs | 24 ++-- src/database/sea_orm_client.rs | 6 +- src/tests/database.rs | 2 +- src/tests/state.rs | 222 ++++++++++++++++++++------------- 8 files changed, 189 insertions(+), 132 deletions(-) diff --git a/src/bors/handlers/help.rs b/src/bors/handlers/help.rs index a60802c3..a5739e95 100644 --- a/src/bors/handlers/help.rs +++ b/src/bors/handlers/help.rs @@ -27,7 +27,7 @@ mod tests { #[tokio::test] async fn test_help() { - let mut state = ClientBuilder::default().create_state().await; + let state = ClientBuilder::default().create_state().await; state.comment("@bors help").await; state .client() diff --git a/src/bors/handlers/mod.rs b/src/bors/handlers/mod.rs index b5486da5..2f594d1f 100644 --- a/src/bors/handlers/mod.rs +++ b/src/bors/handlers/mod.rs @@ -241,7 +241,7 @@ mod tests { #[tokio::test] async fn test_ignore_bot_comment() { - let mut state = ClientBuilder::default().create_state().await; + let state = ClientBuilder::default().create_state().await; state .comment(comment("@bors ping").author(test_bot_user()).create()) .await; @@ -250,8 +250,10 @@ mod tests { #[tokio::test] async fn test_do_not_comment_when_pr_fetch_fails() { - let mut state = ClientBuilder::default().create_state().await; - state.client().get_pr_fn = Box::new(|_| Err(anyhow::anyhow!("Foo"))); + let state = ClientBuilder::default().create_state().await; + state + .client() + .set_get_pr_fn(|_| Err(anyhow::anyhow!("Foo"))); state.comment(comment("foo").create()).await; state.client().check_comments(default_pr_number(), &[]); } diff --git a/src/bors/handlers/ping.rs b/src/bors/handlers/ping.rs index 71707d4e..b2556346 100644 --- a/src/bors/handlers/ping.rs +++ b/src/bors/handlers/ping.rs @@ -19,7 +19,7 @@ mod tests { #[tokio::test] async fn test_ping() { - let mut state = ClientBuilder::default().create_state().await; + let state = ClientBuilder::default().create_state().await; state.comment("@bors ping").await; state .client() diff --git a/src/bors/handlers/trybuild.rs b/src/bors/handlers/trybuild.rs index 0dbbe3ff..d50415de 100644 --- a/src/bors/handlers/trybuild.rs +++ b/src/bors/handlers/trybuild.rs @@ -327,7 +327,7 @@ mod tests { #[tokio::test] async fn test_try_no_permission() { - let mut state = ClientBuilder::default() + let state = ClientBuilder::default() .permission_resolver(Box::new(NoPermissions)) .create_state() .await; @@ -340,8 +340,8 @@ mod tests { #[tokio::test] async fn test_try_merge_comment() { - let mut state = ClientBuilder::default().create_state().await; - state.client().get_pr_fn = Box::new(|pr| { + let state = ClientBuilder::default().create_state().await; + state.client().set_get_pr_fn(|pr| { Ok(PRBuilder::default() .number(pr.0) .head(BranchBuilder::default().sha("head1".to_string()).create()) @@ -358,8 +358,8 @@ mod tests { #[tokio::test] async fn test_try_merge_unknown_base_branch() { - let mut state = ClientBuilder::default().create_state().await; - state.client().get_pr_fn = Box::new(|pr| { + let state = ClientBuilder::default().create_state().await; + state.client().set_get_pr_fn(|pr| { Ok(PRBuilder::default() .number(pr.0) .base( @@ -381,11 +381,11 @@ mod tests { #[tokio::test] async fn test_try_merge_branch_history() { - let mut state = ClientBuilder::default().create_state().await; + let state = ClientBuilder::default().create_state().await; let main_sha = "main1-sha"; let main_name = "main1"; - state.client().get_pr_fn = Box::new(|pr| { + state.client().set_get_pr_fn(|pr| { Ok(PRBuilder::default() .number(pr.0) .base( @@ -397,6 +397,7 @@ mod tests { .head(BranchBuilder::default().sha("head1".to_string()).create()) .create()) }); + state.client().add_branch_sha(main_name, main_sha); state.comment("@bors try").await; @@ -410,7 +411,7 @@ mod tests { #[tokio::test] async fn test_try_merge_explicit_parent() { - let mut state = ClientBuilder::default().create_state().await; + let state = ClientBuilder::default().create_state().await; state .comment("@bors try parent=ea9c1b050cc8b420c2c211d2177811e564a4dc60") .await; @@ -425,7 +426,7 @@ mod tests { #[tokio::test] async fn test_try_merge_last_parent() { - let mut state = ClientBuilder::default().create_state().await; + let state = ClientBuilder::default().create_state().await; state .comment("@bors try parent=ea9c1b050cc8b420c2c211d2177811e564a4dc60") @@ -460,7 +461,7 @@ mod tests { #[tokio::test] async fn test_try_merge_last_parent_unknown() { - let mut state = ClientBuilder::default().create_state().await; + let state = ClientBuilder::default().create_state().await; state.comment("@bors try parent=last").await; state.client().check_comments( @@ -471,8 +472,10 @@ mod tests { #[tokio::test] async fn test_try_merge_conflict() { - let mut state = ClientBuilder::default().create_state().await; - state.client().merge_branches_fn = Box::new(|| Err(MergeError::Conflict)); + let state = ClientBuilder::default().create_state().await; + state + .client() + .set_merge_branches_fn(Box::new(|| Err(MergeError::Conflict))); state.comment("@bors try").await; insta::assert_snapshot!(state.client().get_comment(default_pr_number(), 0), @r###" @@ -509,7 +512,7 @@ mod tests { #[tokio::test] async fn test_try_merge_insert_into_db() { - let mut state = ClientBuilder::default().create_state().await; + let state = ClientBuilder::default().create_state().await; state.comment("@bors try").await; assert!(state @@ -526,7 +529,7 @@ mod tests { #[tokio::test] async fn test_try_merge_active_build() { - let mut state = ClientBuilder::default().create_state().await; + let state = ClientBuilder::default().create_state().await; state.comment("@bors try").await; state.comment("@bors try").await; @@ -536,7 +539,7 @@ mod tests { #[tokio::test] async fn test_try_again_after_checks_finish() { - let mut state = ClientBuilder::default().create_state().await; + let state = ClientBuilder::default().create_state().await; state .client() .set_checks(&default_merge_sha(), &[suite_success()]); @@ -551,8 +554,10 @@ mod tests { ) .await; state.client().check_comment_count(default_pr_number(), 2); + state + .client() + .set_merge_branches_fn(|| Ok(CommitSha("merge2".to_string()))); - state.client().merge_branches_fn = Box::new(|| Ok(CommitSha("merge2".to_string()))); state.comment("@bors try").await; insta::assert_snapshot!(state.client().get_last_comment(default_pr_number()), @":hourglass: Trying commit pr-sha with merge merge2…"); @@ -569,7 +574,7 @@ mod tests { #[tokio::test] async fn test_try_cancel_no_running_build() { - let mut state = ClientBuilder::default().create_state().await; + let state = ClientBuilder::default().create_state().await; state.comment("@bors try cancel").await; @@ -578,7 +583,7 @@ mod tests { #[tokio::test] async fn test_try_cancel_cancel_workflows() { - let mut state = ClientBuilder::default().create_state().await; + let state = ClientBuilder::default().create_state().await; state.comment("@bors try").await; state @@ -610,7 +615,7 @@ mod tests { async fn test_try_cancel_error() { let mut db = create_test_db().await; db.get_workflows_for_build = Some(Box::new(|| Err(anyhow::anyhow!("Errr")))); - let mut state = ClientBuilder::default().db(Some(db)).create_state().await; + let state = ClientBuilder::default().db(Some(db)).create_state().await; state.comment("@bors try").await; state.comment("@bors try cancel").await; @@ -628,7 +633,7 @@ mod tests { #[tokio::test] async fn test_try_cancel_ignore_finished_workflows() { - let mut state = ClientBuilder::default().create_state().await; + let state = ClientBuilder::default().create_state().await; state.client().set_checks( &default_merge_sha(), &[suite_success(), suite_failure(), suite_pending()], @@ -664,7 +669,7 @@ mod tests { #[tokio::test] async fn test_try_cancel_ignore_external_workflows() { - let mut state = ClientBuilder::default().create_state().await; + let state = ClientBuilder::default().create_state().await; state .client() .set_checks(&default_merge_sha(), &[suite_success()]); @@ -684,7 +689,7 @@ mod tests { #[tokio::test] async fn test_try_workflow_start_after_cancel() { - let mut state = ClientBuilder::default().create_state().await; + let state = ClientBuilder::default().create_state().await; state .client() .set_checks(&default_merge_sha(), &[suite_success()]); @@ -710,7 +715,7 @@ mod tests { #[tokio::test] async fn test_try_build_start_modify_labels() { - let mut state = ClientBuilder::default() + let state = ClientBuilder::default() .config( RepoConfigBuilder::default() .add_label(LabelTrigger::TryBuildStarted, "foo") @@ -729,7 +734,7 @@ mod tests { #[tokio::test] async fn test_try_build_succeeded_modify_labels() { - let mut state = ClientBuilder::default() + let state = ClientBuilder::default() .config( RepoConfigBuilder::default() .add_label(LabelTrigger::TryBuildSucceeded, "foo") @@ -759,7 +764,7 @@ mod tests { #[tokio::test] async fn test_try_build_failed_modify_labels() { - let mut state = ClientBuilder::default() + let state = ClientBuilder::default() .config( RepoConfigBuilder::default() .add_label(LabelTrigger::TryBuildFailed, "foo") diff --git a/src/bors/handlers/workflow.rs b/src/bors/handlers/workflow.rs index e0c2e442..bd0ad23b 100644 --- a/src/bors/handlers/workflow.rs +++ b/src/bors/handlers/workflow.rs @@ -1,3 +1,5 @@ +use std::sync::Arc; + use crate::bors::event::{CheckSuiteCompleted, WorkflowCompleted, WorkflowStarted}; use crate::bors::handlers::is_bors_observed_branch; use crate::bors::handlers::labels::handle_label_trigger; @@ -221,7 +223,7 @@ mod tests { #[tokio::test] async fn test_workflow_started_unknown_build() { - let mut state = ClientBuilder::default().create_state().await; + let state = ClientBuilder::default().create_state().await; state .workflow_started( @@ -239,7 +241,7 @@ mod tests { #[tokio::test] async fn test_workflow_completed_unknown_build() { - let mut state = ClientBuilder::default().create_state().await; + let state = ClientBuilder::default().create_state().await; state .workflow_completed( @@ -258,7 +260,7 @@ mod tests { #[tokio::test] async fn test_try_workflow_started() { - let mut state = ClientBuilder::default().create_state().await; + let state = ClientBuilder::default().create_state().await; state.comment("@bors try").await; state @@ -278,7 +280,7 @@ mod tests { #[tokio::test] async fn test_try_workflow_start_twice() { - let mut state = ClientBuilder::default().create_state().await; + let state = ClientBuilder::default().create_state().await; state.comment("@bors try").await; let event = || { @@ -300,7 +302,7 @@ mod tests { #[tokio::test] async fn test_try_check_suite_finished_missing_build() { - let mut state = ClientBuilder::default().create_state().await; + let state = ClientBuilder::default().create_state().await; state .check_suite_completed( CheckSuiteCompletedBuilder::default() @@ -312,7 +314,7 @@ mod tests { #[tokio::test] async fn test_try_success() { - let mut state = ClientBuilder::default().create_state().await; + let state = ClientBuilder::default().create_state().await; state .client() .set_checks(&default_merge_sha(), &[suite_success()]); @@ -339,7 +341,7 @@ mod tests { #[tokio::test] async fn test_try_failure() { - let mut state = ClientBuilder::default().create_state().await; + let state = ClientBuilder::default().create_state().await; state .client() .set_checks(&default_merge_sha(), &[suite_failure()]); @@ -365,7 +367,7 @@ mod tests { #[tokio::test] async fn test_try_success_multiple_suites() { - let mut state = ClientBuilder::default().create_state().await; + let state = ClientBuilder::default().create_state().await; state .client() .set_checks(&default_merge_sha(), &[suite_success(), suite_pending()]); @@ -402,7 +404,7 @@ mod tests { #[tokio::test] async fn test_try_failure_multiple_suites() { - let mut state = ClientBuilder::default().create_state().await; + let state = ClientBuilder::default().create_state().await; state .client() .set_checks(&default_merge_sha(), &[suite_success(), suite_pending()]); @@ -438,7 +440,7 @@ mod tests { #[tokio::test] async fn test_try_suite_completed_received_before_workflow_completed() { - let mut state = ClientBuilder::default().create_state().await; + let state = ClientBuilder::default().create_state().await; state .client() .set_checks(&default_merge_sha(), &[suite_success()]); @@ -474,7 +476,7 @@ mod tests { #[tokio::test] async fn test_try_check_suite_finished_twice() { - let mut state = ClientBuilder::default().create_state().await; + let state = ClientBuilder::default().create_state().await; state .client() .set_checks(&default_merge_sha(), &[suite_success(), suite_success()]); diff --git a/src/database/sea_orm_client.rs b/src/database/sea_orm_client.rs index 8ab2ae13..2895a013 100644 --- a/src/database/sea_orm_client.rs +++ b/src/database/sea_orm_client.rs @@ -18,7 +18,7 @@ use crate::github::{CommitSha, GithubRepoName}; /// Provides access to a database using SeaORM mapping. pub struct SeaORMClient { - db: DatabaseConnection, + pub db: DatabaseConnection, } impl SeaORMClient { @@ -26,8 +26,8 @@ impl SeaORMClient { Self { db: connection } } - pub fn connection(&mut self) -> &mut DatabaseConnection { - &mut self.db + pub fn connection(&self) -> &DatabaseConnection { + &self.db } } diff --git a/src/tests/database.rs b/src/tests/database.rs index c5295660..2d2dc819 100644 --- a/src/tests/database.rs +++ b/src/tests/database.rs @@ -32,7 +32,7 @@ impl MockedDBClient { } } - pub fn connection(&mut self) -> &mut DatabaseConnection { + pub fn connection(&self) -> &DatabaseConnection { self.db.connection() } } diff --git a/src/tests/state.rs b/src/tests/state.rs index c66eaa22..d70122e6 100644 --- a/src/tests/state.rs +++ b/src/tests/state.rs @@ -1,10 +1,8 @@ use std::collections::{HashMap, HashSet}; -use std::future::Future; -use std::pin::Pin; use std::string::ToString; +use std::sync::{Arc, Mutex, RwLock}; use std::time::Duration; -use crate::config::RepositoryConfig; use axum::async_trait; use derive_builder::Builder; use octocrab::models::{RunId, UserId}; @@ -17,6 +15,7 @@ use crate::bors::event::{ }; use crate::bors::{handle_bors_event, BorsContext, CheckSuite, CommandParser, RepositoryState}; use crate::bors::{BorsState, RepositoryClient}; +use crate::config::RepositoryConfig; use crate::database::{DbClient, WorkflowStatus}; use crate::github::{ CommitSha, GithubRepoName, GithubUser, LabelModification, LabelTrigger, PullRequest, @@ -46,42 +45,46 @@ pub fn default_merge_sha() -> String { "sha-merged".to_string() } +type TestRepositoryState = RepositoryState>; + +#[derive(Clone)] pub struct TestBorsState { - repos: HashMap>, - pub db: MockedDBClient, + default_client: Arc, + repos: Arc>>, + pub db: Arc, } impl TestBorsState { /// Returns the default test client - pub fn client(&mut self) -> &mut TestRepositoryClient { - &mut self.repos.get_mut(&default_repo_name()).unwrap().client + pub fn client(&self) -> &TestRepositoryClient { + &self.default_client } /// Execute an event. - pub async fn event(&mut self, event: BorsEvent) { + pub async fn event(&self, event: BorsEvent) { handle_bors_event( event, - self, - &BorsContext::new(CommandParser::new("@bors".to_string())), + Arc::new(self.clone()), + Arc::new(BorsContext::new(CommandParser::new("@bors".to_string()))), ) .await .unwrap(); } - pub async fn comment>(&mut self, comment: T) { + pub async fn comment>(&self, comment: T) { self.event(BorsEvent::Comment(comment.into())).await; } - pub async fn workflow_started>(&mut self, payload: T) { + pub async fn workflow_started>(&self, payload: T) { self.event(BorsEvent::WorkflowStarted(payload.into())).await; } - pub async fn workflow_completed>(&mut self, payload: T) { + pub async fn workflow_completed>(&self, payload: T) { self.event(BorsEvent::WorkflowCompleted(payload.into())) .await; } - pub async fn check_suite_completed>(&mut self, payload: T) { + pub async fn check_suite_completed>(&self, payload: T) { self.event(BorsEvent::CheckSuiteCompleted(payload.into())) .await; } @@ -91,7 +94,7 @@ impl TestBorsState { } pub async fn perform_workflow_events( - &mut self, + &self, run_id: u64, branch: &str, commit: &str, @@ -124,37 +127,30 @@ impl TestBorsState { } } -impl BorsState for TestBorsState { +#[async_trait] +impl BorsState> for TestBorsState { fn is_comment_internal(&self, comment: &PullRequestComment) -> bool { comment.author == test_bot_user() } - fn get_repo_state_mut( - &mut self, + fn get_repo_state( + &self, repo: &GithubRepoName, - ) -> Option<( - &mut RepositoryState, - &mut dyn DbClient, - )> { + ) -> Option<(Arc, Arc)> { self.repos - .get_mut(repo) - .map(|repo| (repo, (&mut self.db) as &mut dyn DbClient)) + .get(repo) + .map(|repo| (Arc::clone(repo), Arc::clone(&self.db) as Arc)) } - fn get_all_repos_mut( - &mut self, - ) -> ( - Vec<&mut RepositoryState>, - &mut dyn DbClient, - ) { + fn get_all_repos(&self) -> (Vec>, Arc) { ( - self.repos.values_mut().collect(), - (&mut self.db) as &mut dyn DbClient, + self.repos.values().cloned().collect(), + Arc::clone(&self.db) as Arc, ) } - fn reload_repositories(&mut self) -> Pin> + '_>> { - Box::pin(async move { Ok(()) }) + async fn reload_repositories(&self) -> anyhow::Result<()> { + Ok(()) } } @@ -217,65 +213,101 @@ impl ClientBuilder { branch_history.insert(default_base_branch.name, vec![default_base_branch.sha]); let db = db.unwrap_or(create_test_db().await); + let client = Arc::new(TestRepositoryClient { + comments: Default::default(), + name: name.clone(), + merge_branches_fn: Mutex::new(Box::new(|| Ok(CommitSha(default_merge_sha())))), + get_pr_fn: Mutex::new(Box::new(|pr| { + Ok(PRBuilder::default().number(pr.0).create()) + })), + check_suites: Default::default(), + cancelled_workflows: Default::default(), + added_labels: Default::default(), + removed_labels: Default::default(), + branch_history: Mutex::new(branch_history), + }); + let repo_state = RepositoryState { repository: name.clone(), - client: TestRepositoryClient { - comments: Default::default(), - name: name.clone(), - merge_branches_fn: Box::new(|| Ok(CommitSha(default_merge_sha()))), - get_pr_fn: Box::new(move |pr| Ok(PRBuilder::default().number(pr.0).create())), - check_suites: Default::default(), - cancelled_workflows: Default::default(), - added_labels: Default::default(), - removed_labels: Default::default(), - branch_history, - }, + client: client.clone(), permissions_resolver: permission_resolver, - config: config.create(), + config: RwLock::new(config.create()), }; let mut repos = HashMap::new(); - repos.insert(name.clone(), repo_state); - TestBorsState { repos, db } + repos.insert(name.clone(), Arc::new(repo_state)); + TestBorsState { + repos: Arc::new(repos), + db: Arc::new(db), + default_client: client, + } } } pub struct TestRepositoryClient { - pub name: GithubRepoName, - comments: HashMap>, - pub merge_branches_fn: Box Result + Send>, - pub get_pr_fn: Box anyhow::Result + Send>, - pub check_suites: HashMap>, - pub cancelled_workflows: HashSet, - added_labels: HashMap>, - removed_labels: HashMap>, + name: GithubRepoName, + comments: Mutex>>, + merge_branches_fn: Mutex Result + Send + Sync>>, + get_pr_fn: Mutex anyhow::Result + Send + Sync>>, + check_suites: Mutex>>, + cancelled_workflows: Mutex>, + added_labels: Mutex>>, + removed_labels: Mutex>>, // Branch name -> history of SHAs - branch_history: HashMap>, + branch_history: Mutex>>, } impl TestRepositoryClient { // Getters - pub fn get_comment(&self, pr_number: u64, comment_index: usize) -> &str { - &self.comments.get(&pr_number).unwrap()[comment_index] + pub fn get_comment(&self, pr_number: u64, comment_index: usize) -> String { + self.comments.lock().unwrap().get(&pr_number).unwrap()[comment_index].clone() } - pub fn get_last_comment(&self, pr_number: u64) -> &str { + + pub fn get_last_comment(&self, pr_number: u64) -> String { self.comments + .lock() + .unwrap() .get(&pr_number) .unwrap() .last() .unwrap() - .as_str() + .clone() } // Setters - pub fn set_checks(&mut self, commit: &str, checks: &[CheckSuite]) { + pub fn set_checks(&self, commit: &str, checks: &[CheckSuite]) { self.check_suites + .lock() + .unwrap() .insert(commit.to_string(), checks.to_vec()); } + pub fn set_get_pr_fn< + F: Fn(PullRequestNumber) -> anyhow::Result + Send + Sync + 'static, + >( + &self, + f: F, + ) { + *self.get_pr_fn.lock().unwrap() = Box::new(f); + } + + pub fn set_merge_branches_fn< + F: Fn() -> Result + Send + Sync + 'static, + >( + &self, + f: F, + ) { + *self.merge_branches_fn.lock().unwrap() = Box::new(f); + } + // Checks pub fn check_comments(&self, pr_number: u64, comments: &[&str]) { assert_eq!( - self.comments.get(&pr_number).cloned().unwrap_or_default(), + self.comments + .lock() + .unwrap() + .get(&pr_number) + .cloned() + .unwrap_or_default(), comments .iter() .map(|&s| String::from(s)) @@ -285,6 +317,8 @@ impl TestRepositoryClient { pub fn check_comment_count(&self, pr_number: u64, count: usize) { assert_eq!( self.comments + .lock() + .unwrap() .get(&pr_number) .cloned() .unwrap_or_default() @@ -294,22 +328,22 @@ impl TestRepositoryClient { } pub fn check_added_labels(&self, pr: u64, added: &[&str]) -> &Self { - assert_eq!(self.added_labels[&pr], added); + assert_eq!(self.added_labels.lock().unwrap()[&pr], added); self } pub fn check_removed_labels(&self, pr: u64, removed: &[&str]) -> &Self { - assert_eq!(self.removed_labels[&pr], removed); + assert_eq!(self.removed_labels.lock().unwrap()[&pr], removed); self } pub fn check_cancelled_workflows(&self, cancelled: &[u64]) { let set = cancelled.iter().copied().collect::>(); - assert_eq!(self.cancelled_workflows, set); + assert_eq!(*self.cancelled_workflows.lock().unwrap(), set); } pub fn check_branch_history(&self, branch: &str, sha: &[&str]) { - let history = self - .branch_history + let branch_history = self.branch_history.lock().unwrap(); + let history = branch_history .get(branch) .unwrap_or_else(|| panic!("Branch {branch} not found")); assert_eq!( @@ -320,8 +354,10 @@ impl TestRepositoryClient { ); } - pub fn add_branch_sha(&mut self, branch: &str, sha: &str) { + pub fn add_branch_sha(&self, branch: &str, sha: &str) { self.branch_history + .lock() + .unwrap() .entry(branch.to_string()) .or_default() .push(CommitSha(sha.to_string())); @@ -329,43 +365,47 @@ impl TestRepositoryClient { } #[async_trait] -impl RepositoryClient for TestRepositoryClient { +impl RepositoryClient for Arc { fn repository(&self) -> &GithubRepoName { &self.name } - async fn get_branch_sha(&mut self, name: &str) -> anyhow::Result { + async fn get_branch_sha(&self, name: &str) -> anyhow::Result { let sha = self .branch_history + .lock() + .unwrap() .get(name) .and_then(|history| history.last().cloned()); sha.ok_or(anyhow::anyhow!("Branch {name} not found")) } - async fn get_pull_request(&mut self, pr: PullRequestNumber) -> anyhow::Result { - (self.get_pr_fn)(pr) + async fn get_pull_request(&self, pr: PullRequestNumber) -> anyhow::Result { + (self.get_pr_fn.lock().unwrap())(pr) } - async fn post_comment(&mut self, pr: PullRequestNumber, text: &str) -> anyhow::Result<()> { + async fn post_comment(&self, pr: PullRequestNumber, text: &str) -> anyhow::Result<()> { self.comments + .lock() + .unwrap() .entry(pr.0) .or_default() .push(text.to_string()); Ok(()) } - async fn set_branch_to_sha(&mut self, branch: &str, sha: &CommitSha) -> anyhow::Result<()> { + async fn set_branch_to_sha(&self, branch: &str, sha: &CommitSha) -> anyhow::Result<()> { self.add_branch_sha(branch, &sha.0); Ok(()) } async fn merge_branches( - &mut self, + &self, base: &str, _head: &CommitSha, _commit_message: &str, ) -> Result { - let res = (self.merge_branches_fn)(); + let res = (self.merge_branches_fn.lock().unwrap())(); if let Ok(ref sha) = res { self.add_branch_sha(base, &sha.0); } @@ -373,40 +413,48 @@ impl RepositoryClient for TestRepositoryClient { } async fn get_check_suites_for_commit( - &mut self, + &self, _branch: &str, sha: &CommitSha, ) -> anyhow::Result> { - Ok(self.check_suites.get(&sha.0).cloned().unwrap_or_default()) + Ok(self + .check_suites + .lock() + .unwrap() + .get(&sha.0) + .cloned() + .unwrap_or_default()) } - async fn cancel_workflows(&mut self, run_ids: &[RunId]) -> anyhow::Result<()> { + async fn cancel_workflows(&self, run_ids: &[RunId]) -> anyhow::Result<()> { self.cancelled_workflows + .lock() + .unwrap() .extend(run_ids.into_iter().map(|id| id.0)); Ok(()) } - async fn add_labels(&mut self, pr: PullRequestNumber, labels: &[String]) -> anyhow::Result<()> { + async fn add_labels(&self, pr: PullRequestNumber, labels: &[String]) -> anyhow::Result<()> { self.added_labels + .lock() + .unwrap() .entry(pr.0) .or_default() .extend(labels.to_vec()); Ok(()) } - async fn remove_labels( - &mut self, - pr: PullRequestNumber, - labels: &[String], - ) -> anyhow::Result<()> { + async fn remove_labels(&self, pr: PullRequestNumber, labels: &[String]) -> anyhow::Result<()> { self.removed_labels + .lock() + .unwrap() .entry(pr.0) .or_default() .extend(labels.to_vec()); Ok(()) } - async fn load_config(&mut self) -> anyhow::Result { + async fn load_config(&self) -> anyhow::Result { Ok(RepoConfigBuilder::default().create()) } From 422f918dc5116e7691f9b3c87e36aba5df902d30 Mon Sep 17 00:00:00 2001 From: vohoanglong0107 Date: Tue, 9 Apr 2024 03:37:34 +0000 Subject: [PATCH 35/57] feat: arc-swap instead of rwlock --- Cargo.lock | 5 +++-- Cargo.toml | 1 + src/github/api/mod.rs | 18 +++++++----------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c096180b..ddb8164c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -133,9 +133,9 @@ checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" [[package]] name = "arc-swap" -version = "1.7.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b3d0060af21e8d11a926981cc00c6c1541aa91dd64b9f881985c3da1094425f" +checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457" [[package]] name = "arrayvec" @@ -331,6 +331,7 @@ name = "bors" version = "0.1.0" dependencies = [ "anyhow", + "arc-swap", "axum", "base64 0.22.0", "chrono", diff --git a/Cargo.toml b/Cargo.toml index be3b0e26..9c58fd3a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,6 +35,7 @@ octocrab = "0.35.0" # Async futures = "0.3" tokio = { workspace = true } +arc-swap = "1.7.1" # Web hyper = "1.2.0" diff --git a/src/github/api/mod.rs b/src/github/api/mod.rs index 0a208b72..41bbaf85 100644 --- a/src/github/api/mod.rs +++ b/src/github/api/mod.rs @@ -2,6 +2,7 @@ use std::collections::HashMap; use std::sync::{Arc, RwLock}; use anyhow::Context; +use arc_swap::ArcSwap; use axum::async_trait; use octocrab::models::{App, AppId, InstallationRepositories, Repository}; use octocrab::Octocrab; @@ -34,7 +35,7 @@ fn base_github_url() -> &'static str { pub struct GithubAppState { app: App, client: Octocrab, - repositories: Arc>, + repositories: ArcSwap, db: Arc, } @@ -63,7 +64,7 @@ impl GithubAppState { Ok(GithubAppState { app, client, - repositories: Arc::new(RwLock::new(repositories)), + repositories: ArcSwap::new(Arc::new(repositories)), db: Arc::new(db), }) } @@ -185,8 +186,7 @@ impl BorsState for GithubAppState { Arc, )> { self.repositories - .read() - .unwrap() + .load() .get(repo) .map(|repo| (Arc::clone(&repo), Arc::clone(&self.db) as Arc)) } @@ -198,19 +198,15 @@ impl BorsState for GithubAppState { Arc, ) { ( - self.repositories - .read() - .unwrap() - .values() - .cloned() - .collect(), + self.repositories.load().values().cloned().collect(), Arc::clone(&self.db) as Arc, ) } /// Re-download information about repositories connected to this GitHub app. async fn reload_repositories(&self) -> anyhow::Result<()> { - *self.repositories.write().unwrap() = load_repositories(&self.client).await?; + self.repositories + .store(Arc::new(load_repositories(&self.client).await?)); Ok(()) } } From ab37550538268633ebdfaf51866f6fabe8a98f73 Mon Sep 17 00:00:00 2001 From: vohoanglong0107 Date: Tue, 9 Apr 2024 05:29:44 +0000 Subject: [PATCH 36/57] refactor: arc-swap for config --- src/bors/handlers/labels.rs | 2 +- src/bors/handlers/refresh.rs | 4 ++-- src/bors/mod.rs | 3 ++- src/github/api/mod.rs | 2 +- src/tests/state.rs | 3 ++- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/bors/handlers/labels.rs b/src/bors/handlers/labels.rs index 80f4b5ee..612f0d05 100644 --- a/src/bors/handlers/labels.rs +++ b/src/bors/handlers/labels.rs @@ -13,7 +13,7 @@ pub async fn handle_label_trigger( ) -> anyhow::Result<()> { let mut add: Vec = Vec::new(); let mut remove: Vec = Vec::new(); - if let Some(modifications) = repo.config.read().unwrap().labels.get(&trigger) { + if let Some(modifications) = repo.config.load().labels.get(&trigger) { log::debug!("Performing label modifications {modifications:?}"); (add, remove) = modifications .iter() diff --git a/src/bors/handlers/refresh.rs b/src/bors/handlers/refresh.rs index c984fc49..ff4edc9d 100644 --- a/src/bors/handlers/refresh.rs +++ b/src/bors/handlers/refresh.rs @@ -31,7 +31,7 @@ async fn cancel_timed_out_builds( let running_builds = db.get_running_builds(&repo.repository).await?; tracing::info!("Found {} running build(s)", running_builds.len()); - let timeout = repo.config.read().unwrap().timeout.clone(); + let timeout = repo.config.load().timeout.clone(); for build in running_builds { if elapsed_time(build.created_at) >= timeout { tracing::info!("Cancelling build {}", build.commit_sha); @@ -69,7 +69,7 @@ async fn reload_config( repo: &RepositoryState, ) -> anyhow::Result<()> { let config = repo.client.load_config().await?; - *repo.config.write().unwrap() = config; + repo.config.store(Arc::new(config)); Ok(()) } diff --git a/src/bors/mod.rs b/src/bors/mod.rs index 740a74ad..c48cf619 100644 --- a/src/bors/mod.rs +++ b/src/bors/mod.rs @@ -5,6 +5,7 @@ mod handlers; use std::sync::{Arc, RwLock}; +use arc_swap::ArcSwap; use axum::async_trait; use octocrab::models::RunId; @@ -106,5 +107,5 @@ pub struct RepositoryState { pub repository: GithubRepoName, pub client: Client, pub permissions_resolver: Box, - pub config: RwLock, + pub config: ArcSwap, } diff --git a/src/github/api/mod.rs b/src/github/api/mod.rs index 41bbaf85..f6b89de5 100644 --- a/src/github/api/mod.rs +++ b/src/github/api/mod.rs @@ -167,8 +167,8 @@ async fn create_repo_state( Ok(RepositoryState { repository: name, client, - config: RwLock::new(config), permissions_resolver: Box::new(permissions_resolver), + config: ArcSwap::new(Arc::new(config)), }) } diff --git a/src/tests/state.rs b/src/tests/state.rs index d70122e6..7894d68e 100644 --- a/src/tests/state.rs +++ b/src/tests/state.rs @@ -3,6 +3,7 @@ use std::string::ToString; use std::sync::{Arc, Mutex, RwLock}; use std::time::Duration; +use arc_swap::ArcSwap; use axum::async_trait; use derive_builder::Builder; use octocrab::models::{RunId, UserId}; @@ -231,7 +232,7 @@ impl ClientBuilder { repository: name.clone(), client: client.clone(), permissions_resolver: permission_resolver, - config: RwLock::new(config.create()), + config: ArcSwap::new(Arc::new(config.create())), }; let mut repos = HashMap::new(); repos.insert(name.clone(), Arc::new(repo_state)); From ea784da00c83f1d3ef230e241639dee8bc633eac Mon Sep 17 00:00:00 2001 From: vohoanglong0107 Date: Tue, 9 Apr 2024 05:33:27 +0000 Subject: [PATCH 37/57] refactor: arc-swap for permission --- src/bors/handlers/refresh.rs | 22 +++++-------- src/bors/handlers/trybuild.rs | 9 +++--- src/bors/mod.rs | 6 ++-- src/github/api/mod.rs | 8 ++--- src/permissions.rs | 59 +++++------------------------------ src/tests/event.rs | 2 +- src/tests/mod.rs | 1 - src/tests/permissions.rs | 47 ---------------------------- src/tests/state.rs | 39 ++++++++++++++++++----- 9 files changed, 59 insertions(+), 134 deletions(-) delete mode 100644 src/tests/permissions.rs diff --git a/src/bors/handlers/refresh.rs b/src/bors/handlers/refresh.rs index ff4edc9d..7c978fe5 100644 --- a/src/bors/handlers/refresh.rs +++ b/src/bors/handlers/refresh.rs @@ -6,6 +6,7 @@ use chrono::{DateTime, Utc}; use crate::bors::handlers::trybuild::cancel_build_workflows; use crate::bors::{RepositoryClient, RepositoryState}; use crate::database::{BuildStatus, DbClient}; +use crate::permissions::load_permissions; pub async fn refresh_repository( repo: Arc>, @@ -61,8 +62,12 @@ async fn cancel_timed_out_builds( Ok(()) } -async fn reload_permission(repo: &RepositoryState) { - repo.permissions_resolver.reload().await +async fn reload_permission( + repo: &RepositoryState, +) -> anyhow::Result<()> { + let permissions = load_permissions(&repo.repository).await?; + repo.permissions.store(Arc::new(permissions)); + Ok(()) } async fn reload_config( @@ -96,7 +101,6 @@ fn elapsed_time(date: DateTime) -> Duration { #[cfg(test)] mod tests { use std::future::Future; - use std::sync::{Arc, Mutex}; use std::time::Duration; use chrono::Utc; @@ -106,7 +110,6 @@ mod tests { use crate::bors::handlers::trybuild::TRY_BRANCH_NAME; use crate::database::DbClient; use crate::tests::event::{default_pr_number, WorkflowStartedBuilder}; - use crate::tests::permissions::MockPermissions; use crate::tests::state::{default_repo_name, ClientBuilder, RepoConfigBuilder}; #[tokio::test(flavor = "current_thread")] @@ -115,17 +118,6 @@ mod tests { state.refresh().await; } - #[tokio::test(flavor = "current_thread")] - async fn refresh_permission() { - let permission_resolver = Arc::new(Mutex::new(MockPermissions::default())); - let mut state = ClientBuilder::default() - .permission_resolver(Box::new(Arc::clone(&permission_resolver))) - .create_state() - .await; - state.refresh().await; - assert_eq!(permission_resolver.lock().unwrap().num_reload_called, 1); - } - #[tokio::test(flavor = "current_thread")] async fn refresh_do_nothing_before_timeout() { let mut state = ClientBuilder::default() diff --git a/src/bors/handlers/trybuild.rs b/src/bors/handlers/trybuild.rs index d50415de..7eac8594 100644 --- a/src/bors/handlers/trybuild.rs +++ b/src/bors/handlers/trybuild.rs @@ -285,9 +285,9 @@ async fn check_try_permissions( author: &GithubUser, ) -> anyhow::Result { let result = if !repo - .permissions_resolver + .permissions + .load() .has_permission(&author.id, PermissionType::Try) - .await { tracing::info!("Permission denied"); repo.client @@ -320,15 +320,14 @@ mod tests { default_pr_number, suite_failure, suite_pending, suite_success, WorkflowStartedBuilder, }; use crate::tests::github::{BranchBuilder, PRBuilder}; - use crate::tests::permissions::NoPermissions; use crate::tests::state::{ - default_merge_sha, default_repo_name, ClientBuilder, RepoConfigBuilder, + default_merge_sha, default_repo_name, ClientBuilder, PermissionsBuilder, RepoConfigBuilder, }; #[tokio::test] async fn test_try_no_permission() { let state = ClientBuilder::default() - .permission_resolver(Box::new(NoPermissions)) + .permissions(PermissionsBuilder::default()) .create_state() .await; state.comment("@bors try").await; diff --git a/src/bors/mod.rs b/src/bors/mod.rs index c48cf619..4c546b36 100644 --- a/src/bors/mod.rs +++ b/src/bors/mod.rs @@ -3,7 +3,7 @@ mod context; pub mod event; mod handlers; -use std::sync::{Arc, RwLock}; +use std::sync::Arc; use arc_swap::ArcSwap; use axum::async_trait; @@ -13,7 +13,7 @@ use crate::bors::event::PullRequestComment; use crate::config::RepositoryConfig; use crate::database::DbClient; use crate::github::{CommitSha, GithubRepoName, MergeError, PullRequest, PullRequestNumber}; -use crate::permissions::PermissionResolver; +use crate::permissions::UserPermissions; pub use command::CommandParser; pub use context::BorsContext; pub use handlers::handle_bors_event; @@ -106,6 +106,6 @@ pub trait BorsState: Send + Sync { pub struct RepositoryState { pub repository: GithubRepoName, pub client: Client, - pub permissions_resolver: Box, + pub permissions: ArcSwap, pub config: ArcSwap, } diff --git a/src/github/api/mod.rs b/src/github/api/mod.rs index f6b89de5..6ae697ba 100644 --- a/src/github/api/mod.rs +++ b/src/github/api/mod.rs @@ -1,5 +1,5 @@ use std::collections::HashMap; -use std::sync::{Arc, RwLock}; +use std::sync::Arc; use anyhow::Context; use arc_swap::ArcSwap; @@ -14,7 +14,7 @@ use crate::bors::event::PullRequestComment; use crate::bors::{BorsState, RepositoryClient, RepositoryState}; use crate::database::{DbClient, SeaORMClient}; use crate::github::GithubRepoName; -use crate::permissions::TeamApiPermissionResolver; +use crate::permissions::load_permissions; pub mod client; pub(crate) mod operations; @@ -160,15 +160,15 @@ async fn create_repo_state( } }; - let permissions_resolver = TeamApiPermissionResolver::load(name.clone()) + let permissions = load_permissions(&name) .await .map_err(|error| anyhow::anyhow!("Could not load permissions for {name}: {error:?}"))?; Ok(RepositoryState { repository: name, client, - permissions_resolver: Box::new(permissions_resolver), config: ArcSwap::new(Arc::new(config)), + permissions: ArcSwap::new(Arc::new(permissions)), }) } diff --git a/src/permissions.rs b/src/permissions.rs index b26ed7d6..5ae6b613 100644 --- a/src/permissions.rs +++ b/src/permissions.rs @@ -1,7 +1,5 @@ -use axum::async_trait; use octocrab::models::UserId; use std::collections::HashSet; -use tokio::sync::Mutex; use crate::github::GithubRepoName; @@ -12,60 +10,19 @@ pub enum PermissionType { Try, } -/// Decides if a GitHub user can perform various actions using the bot. -#[async_trait] -pub trait PermissionResolver: Sync + Send { - async fn has_permission(&self, user_id: &UserId, permission: PermissionType) -> bool; - async fn reload(&self); -} - -/// Loads permission information from the Rust Team API. -pub struct TeamApiPermissionResolver { - repo: GithubRepoName, - permissions: Mutex, -} - -impl TeamApiPermissionResolver { - pub async fn load(repo: GithubRepoName) -> anyhow::Result { - let permissions = load_permissions(&repo).await?; - - Ok(Self { - repo, - permissions: Mutex::new(permissions), - }) - } - async fn reload_permissions(&self) { - let result = load_permissions(&self.repo).await; - match result { - Ok(perms) => *self.permissions.lock().await = perms, - Err(error) => { - tracing::error!("Cannot reload permissions for {}: {error:?}", self.repo); - } - } - } -} - -#[async_trait] -impl PermissionResolver for TeamApiPermissionResolver { - async fn has_permission(&self, user_id: &UserId, permission: PermissionType) -> bool { - self.permissions - .lock() - .await - .has_permission(user_id, permission) - } - - async fn reload(&self) { - self.reload_permissions().await - } -} - pub struct UserPermissions { review_users: HashSet, try_users: HashSet, } impl UserPermissions { - fn has_permission(&self, user_id: &UserId, permission: PermissionType) -> bool { + pub fn new(review_users: HashSet, try_users: HashSet) -> Self { + Self { + review_users, + try_users, + } + } + pub fn has_permission(&self, user_id: &UserId, permission: PermissionType) -> bool { match permission { PermissionType::Review => self.review_users.contains(user_id), PermissionType::Try => self.try_users.contains(user_id), @@ -73,7 +30,7 @@ impl UserPermissions { } } -async fn load_permissions(repo: &GithubRepoName) -> anyhow::Result { +pub async fn load_permissions(repo: &GithubRepoName) -> anyhow::Result { tracing::info!("Reloading permissions for repository {repo}"); let review_users = load_users_from_team_api(repo.name(), PermissionType::Review) diff --git a/src/tests/event.rs b/src/tests/event.rs index 0cd2595a..ce3b3fcd 100644 --- a/src/tests/event.rs +++ b/src/tests/event.rs @@ -7,7 +7,7 @@ use crate::database::{WorkflowStatus, WorkflowType}; use crate::github::{CommitSha, GithubRepoName, GithubUser, PullRequestNumber}; use crate::tests::state::{default_merge_sha, default_repo_name}; -fn default_user() -> GithubUser { +pub fn default_user() -> GithubUser { GithubUser { id: UserId(1), username: "".to_string(), diff --git a/src/tests/mod.rs b/src/tests/mod.rs index efa948cb..f8f070bf 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -2,5 +2,4 @@ pub(crate) mod database; pub(crate) mod event; pub(crate) mod github; pub(crate) mod io; -pub(crate) mod permissions; pub(crate) mod state; diff --git a/src/tests/permissions.rs b/src/tests/permissions.rs deleted file mode 100644 index ba13d212..00000000 --- a/src/tests/permissions.rs +++ /dev/null @@ -1,47 +0,0 @@ -use std::sync::{Arc, Mutex}; - -use crate::permissions::{PermissionResolver, PermissionType}; -use axum::async_trait; -use octocrab::models::UserId; - -pub struct NoPermissions; - -#[async_trait] -impl PermissionResolver for NoPermissions { - async fn has_permission(&self, _user_id: &UserId, _permission: PermissionType) -> bool { - false - } - async fn reload(&self) {} -} - -pub struct AllPermissions; - -#[async_trait] -impl PermissionResolver for AllPermissions { - async fn has_permission(&self, _user_id: &UserId, _permission: PermissionType) -> bool { - true - } - async fn reload(&self) {} -} - -pub struct MockPermissions { - pub num_reload_called: i32, -} - -impl Default for MockPermissions { - fn default() -> Self { - Self { - num_reload_called: 0, - } - } -} - -#[async_trait] -impl PermissionResolver for Arc> { - async fn has_permission(&self, _user_id: &UserId, _permission: PermissionType) -> bool { - false - } - async fn reload(&self) { - self.lock().unwrap().num_reload_called += 1 - } -} diff --git a/src/tests/state.rs b/src/tests/state.rs index 7894d68e..97640f1d 100644 --- a/src/tests/state.rs +++ b/src/tests/state.rs @@ -1,6 +1,6 @@ use std::collections::{HashMap, HashSet}; use std::string::ToString; -use std::sync::{Arc, Mutex, RwLock}; +use std::sync::{Arc, Mutex}; use std::time::Duration; use arc_swap::ArcSwap; @@ -10,7 +10,7 @@ use octocrab::models::{RunId, UserId}; use url::Url; use super::database::MockedDBClient; -use super::permissions::AllPermissions; +use super::event::default_user; use crate::bors::event::{ BorsEvent, CheckSuiteCompleted, PullRequestComment, WorkflowCompleted, WorkflowStarted, }; @@ -22,7 +22,7 @@ use crate::github::{ CommitSha, GithubRepoName, GithubUser, LabelModification, LabelTrigger, PullRequest, }; use crate::github::{MergeError, PullRequestNumber}; -use crate::permissions::PermissionResolver; +use crate::permissions::UserPermissions; use crate::tests::database::create_test_db; use crate::tests::event::{ CheckSuiteCompletedBuilder, WorkflowCompletedBuilder, WorkflowStartedBuilder, @@ -187,13 +187,38 @@ impl RepoConfigBuilder { } } +#[derive(Builder)] +#[builder(pattern = "owned")] +pub struct Permissions { + #[builder(field(ty = "HashSet"))] + review_users: HashSet, + #[builder(field(ty = "HashSet"))] + try_users: HashSet, +} + +impl PermissionsBuilder { + pub fn create(self) -> UserPermissions { + let Permissions { + review_users, + try_users, + } = self.build().unwrap(); + UserPermissions::new(review_users, try_users) + } + + pub fn add_default_users(mut self) -> Self { + self.review_users.insert(default_user().id); + self.try_users.insert(default_user().id); + self + } +} + #[derive(Builder)] #[builder(pattern = "owned")] pub struct Client { #[builder(default = "default_repo_name()")] name: GithubRepoName, - #[builder(default = "Box::new(AllPermissions)")] - permission_resolver: Box, + #[builder(default = "PermissionsBuilder::default().add_default_users()")] + permissions: PermissionsBuilder, #[builder(default)] config: RepoConfigBuilder, #[builder(default)] @@ -204,7 +229,7 @@ impl ClientBuilder { pub async fn create_state(self) -> TestBorsState { let Client { name, - permission_resolver, + permissions, config, db, } = self.build().unwrap(); @@ -231,7 +256,7 @@ impl ClientBuilder { let repo_state = RepositoryState { repository: name.clone(), client: client.clone(), - permissions_resolver: permission_resolver, + permissions: ArcSwap::new(Arc::new(permissions.create())), config: ArcSwap::new(Arc::new(config.create())), }; let mut repos = HashMap::new(); From 54e18e3324a8eb7794959e8a79f846330a85752b Mon Sep 17 00:00:00 2001 From: vohoanglong0107 Date: Tue, 9 Apr 2024 05:51:50 +0000 Subject: [PATCH 38/57] refactor: separate global state(db) with per repo state --- src/bin/bors.rs | 3 +-- src/bors/context.rs | 8 +++++--- src/bors/handlers/mod.rs | 13 +++++++------ src/bors/mod.rs | 8 ++------ src/github/api/mod.rs | 28 +++++----------------------- src/tests/state.rs | 21 ++++++++------------- 6 files changed, 28 insertions(+), 53 deletions(-) diff --git a/src/bin/bors.rs b/src/bin/bors.rs index 7a8b8b0e..ae335c8c 100644 --- a/src/bin/bors.rs +++ b/src/bin/bors.rs @@ -80,9 +80,8 @@ fn try_main(opts: Opts) -> anyhow::Result<()> { let state = runtime.block_on(GithubAppState::load( opts.app_id.into(), opts.private_key.into_bytes().into(), - db, ))?; - let ctx = BorsContext::new(CommandParser::new(opts.cmd_prefix)); + let ctx = BorsContext::new(CommandParser::new(opts.cmd_prefix), Arc::new(db)); let (tx, gh_process) = create_bors_process(state, ctx); let refresh_tx = tx.clone(); diff --git a/src/bors/context.rs b/src/bors/context.rs index 1637e059..bd08c9e3 100644 --- a/src/bors/context.rs +++ b/src/bors/context.rs @@ -1,11 +1,13 @@ -use crate::bors::command::CommandParser; +use crate::{bors::command::CommandParser, database::DbClient}; +use std::sync::Arc; pub struct BorsContext { pub parser: CommandParser, + pub db: Arc, } impl BorsContext { - pub fn new(parser: CommandParser) -> Self { - Self { parser } + pub fn new(parser: CommandParser, db: Arc) -> Self { + Self { parser, db } } } diff --git a/src/bors/handlers/mod.rs b/src/bors/handlers/mod.rs index 2f594d1f..086051f3 100644 --- a/src/bors/handlers/mod.rs +++ b/src/bors/handlers/mod.rs @@ -30,6 +30,7 @@ pub async fn handle_bors_event( state: Arc>, ctx: Arc, ) -> anyhow::Result<()> { + let db = Arc::clone(&ctx.db); match event { BorsEvent::Comment(comment) => { // We want to ignore comments made by this bot @@ -38,7 +39,7 @@ pub async fn handle_bors_event( return Ok(()); } - if let Some((repo, db)) = get_repo_state(state, &comment.repository) { + if let Some(repo) = get_repo_state(state, &comment.repository) { let span = tracing::info_span!( "Comment", pr = format!("{}#{}", comment.repository, comment.pr_number), @@ -67,7 +68,7 @@ pub async fn handle_bors_event( } } BorsEvent::WorkflowStarted(payload) => { - if let Some((_, db)) = get_repo_state(state, &payload.repository) { + if let Some(_) = get_repo_state(state, &payload.repository) { let span = tracing::info_span!( "Workflow started", repo = payload.repository.to_string(), @@ -82,7 +83,7 @@ pub async fn handle_bors_event( } } BorsEvent::WorkflowCompleted(payload) => { - if let Some((repo, db)) = get_repo_state(state, &payload.repository) { + if let Some(repo) = get_repo_state(state, &payload.repository) { let span = tracing::info_span!( "Workflow completed", repo = payload.repository.to_string(), @@ -97,7 +98,7 @@ pub async fn handle_bors_event( } } BorsEvent::CheckSuiteCompleted(payload) => { - if let Some((repo, db)) = get_repo_state(state, &payload.repository) { + if let Some(repo) = get_repo_state(state, &payload.repository) { let span = tracing::info_span!( "Check suite completed", repo = payload.repository.to_string(), @@ -112,7 +113,7 @@ pub async fn handle_bors_event( } BorsEvent::Refresh => { let span = tracing::info_span!("Refresh"); - let (repos, db) = state.get_all_repos(); + let repos = state.get_all_repos(); futures::future::join_all(repos.into_iter().map(|repo| { let repo = Arc::clone(&repo); async { @@ -132,7 +133,7 @@ pub async fn handle_bors_event( fn get_repo_state( state: Arc>, repo: &GithubRepoName, -) -> Option<(Arc>, Arc)> { +) -> Option>> { match state.get_repo_state(repo) { Some(result) => Some(result), None => { diff --git a/src/bors/mod.rs b/src/bors/mod.rs index 4c546b36..8a443e9a 100644 --- a/src/bors/mod.rs +++ b/src/bors/mod.rs @@ -11,7 +11,6 @@ use octocrab::models::RunId; use crate::bors::event::PullRequestComment; use crate::config::RepositoryConfig; -use crate::database::DbClient; use crate::github::{CommitSha, GithubRepoName, MergeError, PullRequest, PullRequestNumber}; use crate::permissions::UserPermissions; pub use command::CommandParser; @@ -88,13 +87,10 @@ pub trait BorsState: Send + Sync { fn is_comment_internal(&self, comment: &PullRequestComment) -> bool; /// Get repository and database state for the given repository name. - fn get_repo_state( - &self, - repo: &GithubRepoName, - ) -> Option<(Arc>, Arc)>; + fn get_repo_state(&self, repo: &GithubRepoName) -> Option>>; /// Get all repositories. - fn get_all_repos(&self) -> (Vec>>, Arc); + fn get_all_repos(&self) -> Vec>>; /// Reload state of repositories due to some external change. async fn reload_repositories(&self) -> anyhow::Result<()>; diff --git a/src/github/api/mod.rs b/src/github/api/mod.rs index 6ae697ba..8d23e656 100644 --- a/src/github/api/mod.rs +++ b/src/github/api/mod.rs @@ -12,7 +12,6 @@ use client::GithubRepositoryClient; use crate::bors::event::PullRequestComment; use crate::bors::{BorsState, RepositoryClient, RepositoryState}; -use crate::database::{DbClient, SeaORMClient}; use crate::github::GithubRepoName; use crate::permissions::load_permissions; @@ -36,16 +35,11 @@ pub struct GithubAppState { app: App, client: Octocrab, repositories: ArcSwap, - db: Arc, } impl GithubAppState { /// Loads repositories managed by the Bors GitHub app with the given ID. - pub async fn load( - app_id: AppId, - private_key: SecretVec, - db: SeaORMClient, - ) -> anyhow::Result { + pub async fn load(app_id: AppId, private_key: SecretVec) -> anyhow::Result { let key = jsonwebtoken::EncodingKey::from_rsa_pem(private_key.expose_secret().as_ref()) .context("Could not encode private key")?; @@ -65,7 +59,6 @@ impl GithubAppState { app, client, repositories: ArcSwap::new(Arc::new(repositories)), - db: Arc::new(db), }) } } @@ -181,26 +174,15 @@ impl BorsState for GithubAppState { fn get_repo_state( &self, repo: &GithubRepoName, - ) -> Option<( - Arc>, - Arc, - )> { + ) -> Option>> { self.repositories .load() .get(repo) - .map(|repo| (Arc::clone(&repo), Arc::clone(&self.db) as Arc)) + .map(|repo| Arc::clone(&repo)) } - fn get_all_repos( - &self, - ) -> ( - Vec>>, - Arc, - ) { - ( - self.repositories.load().values().cloned().collect(), - Arc::clone(&self.db) as Arc, - ) + fn get_all_repos(&self) -> Vec>> { + self.repositories.load().values().cloned().collect() } /// Re-download information about repositories connected to this GitHub app. diff --git a/src/tests/state.rs b/src/tests/state.rs index 97640f1d..30906da5 100644 --- a/src/tests/state.rs +++ b/src/tests/state.rs @@ -66,7 +66,10 @@ impl TestBorsState { handle_bors_event( event, Arc::new(self.clone()), - Arc::new(BorsContext::new(CommandParser::new("@bors".to_string()))), + Arc::new(BorsContext::new( + CommandParser::new("@bors".to_string()), + Arc::clone(&self.db) as Arc, + )), ) .await .unwrap(); @@ -134,20 +137,12 @@ impl BorsState> for TestBorsState { comment.author == test_bot_user() } - fn get_repo_state( - &self, - repo: &GithubRepoName, - ) -> Option<(Arc, Arc)> { - self.repos - .get(repo) - .map(|repo| (Arc::clone(repo), Arc::clone(&self.db) as Arc)) + fn get_repo_state(&self, repo: &GithubRepoName) -> Option> { + self.repos.get(repo).map(|repo| Arc::clone(repo)) } - fn get_all_repos(&self) -> (Vec>, Arc) { - ( - self.repos.values().cloned().collect(), - Arc::clone(&self.db) as Arc, - ) + fn get_all_repos(&self) -> Vec> { + self.repos.values().cloned().collect() } async fn reload_repositories(&self) -> anyhow::Result<()> { From 7536c4e937e7d2ea8c375ae7c5cc82cbc3173151 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Fri, 19 Apr 2024 20:47:54 +0200 Subject: [PATCH 39/57] Fix tracing builder --- src/bin/bors.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/bin/bors.rs b/src/bin/bors.rs index ae335c8c..4180258d 100644 --- a/src/bin/bors.rs +++ b/src/bin/bors.rs @@ -122,9 +122,13 @@ fn try_main(opts: Opts) -> anyhow::Result<()> { fn main() { tracing_subscriber::fmt() - .with_max_level(tracing::Level::INFO) .with_target(false) - .with_env_filter(EnvFilter::from_default_env()) + .with_env_filter( + EnvFilter::builder() + .with_default_directive(tracing::Level::INFO.into()) + .from_env() + .expect("Cannot load RUST_LOG"), + ) .with_ansi(std::io::stdout().is_terminal()) .init(); From 20204572b4920b2ff8f242c07fc1e56e61fd0d0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Fri, 19 Apr 2024 21:00:42 +0200 Subject: [PATCH 40/57] Export only needed types and functions from the library. --- src/bin/bors.rs | 20 ++++++-------------- src/bors/mod.rs | 4 ++-- src/github/api/mod.rs | 6 +++--- src/github/server.rs | 10 ++++++++++ src/lib.rs | 19 +++++++++++++------ 5 files changed, 34 insertions(+), 25 deletions(-) diff --git a/src/bin/bors.rs b/src/bin/bors.rs index 4180258d..92d2e5a9 100644 --- a/src/bin/bors.rs +++ b/src/bin/bors.rs @@ -4,19 +4,15 @@ use std::sync::Arc; use std::time::Duration; use anyhow::Context; -use axum::routing::post; -use axum::Router; -use bors::bors::{BorsContext, CommandParser}; +use bors::{ + create_app, create_bors_process, BorsContext, BorsEvent, CommandParser, GithubAppState, + SeaORMClient, ServerState, WebhookSecret, +}; use clap::Parser; use sea_orm::Database; use tokio::task::LocalSet; -use tower::limit::ConcurrencyLimitLayer; use tracing_subscriber::EnvFilter; -use bors::bors::event::BorsEvent; -use bors::database::SeaORMClient; -use bors::github::server::{create_bors_process, github_webhook_handler, ServerState}; -use bors::github::{GithubAppState, WebhookSecret}; use migration::{Migrator, MigratorTrait}; /// How often should the bot check DB state, e.g. for handling timeouts. @@ -46,18 +42,14 @@ struct Opts { } async fn server(state: ServerState) -> anyhow::Result<()> { - let state = Arc::new(state); + let app = create_app(state); - let app = Router::new() - .route("/github", post(github_webhook_handler)) - .layer(ConcurrencyLimitLayer::new(100)) - .with_state(state); let addr = SocketAddr::from(([0, 0, 0, 0], 8080)); let listener = tokio::net::TcpListener::bind(addr) .await .context("Cannot create TCP/IP server socket")?; - axum::serve(listener, app.into_make_service()).await?; + axum::serve(listener, app).await?; Ok(()) } diff --git a/src/bors/mod.rs b/src/bors/mod.rs index 8a443e9a..9e4042b9 100644 --- a/src/bors/mod.rs +++ b/src/bors/mod.rs @@ -22,7 +22,7 @@ pub use handlers::handle_bors_event; pub trait RepositoryClient: Send + Sync { fn repository(&self) -> &GithubRepoName; - /// load repository config + /// Load repository config. async fn load_config(&self) -> anyhow::Result; /// Return the current SHA of the given branch. @@ -61,7 +61,7 @@ pub trait RepositoryClient: Send + Sync { /// Remove a set of labels from a PR. async fn remove_labels(&self, pr: PullRequestNumber, labels: &[String]) -> anyhow::Result<()>; - /// Get a workflow url + /// Get a workflow url. fn get_workflow_url(&self, run_id: RunId) -> String; } diff --git a/src/github/api/mod.rs b/src/github/api/mod.rs index 8d23e656..ffcc8f6b 100644 --- a/src/github/api/mod.rs +++ b/src/github/api/mod.rs @@ -18,9 +18,9 @@ use crate::permissions::load_permissions; pub mod client; pub(crate) mod operations; -type GHRepositoryState = RepositoryState; +type GithubRepositoryState = RepositoryState; -type RepositoryMap = HashMap>; +type RepositoryMap = HashMap>; fn base_github_html_url() -> &'static str { "https://github.com" @@ -127,7 +127,7 @@ pub async fn load_repositories(client: &Octocrab) -> anyhow::Result anyhow::Result { +) -> anyhow::Result { let Some(owner) = repo.owner.clone() else { return Err(anyhow::anyhow!("Repository {} has no owner", repo.name)); }; diff --git a/src/github/server.rs b/src/github/server.rs index a55dca4a..c3dd5481 100644 --- a/src/github/server.rs +++ b/src/github/server.rs @@ -7,9 +7,12 @@ use crate::utils::logging::LogError; use axum::extract::State; use axum::http::StatusCode; use axum::response::IntoResponse; +use axum::routing::post; +use axum::Router; use std::future::Future; use std::sync::Arc; use tokio::sync::mpsc; +use tower::limit::ConcurrencyLimitLayer; use tracing::Instrument; /// Shared server state for all axum handlers. @@ -33,6 +36,13 @@ impl ServerState { pub type ServerStateRef = Arc; +pub fn create_app(state: ServerState) -> Router { + Router::new() + .route("/github", post(github_webhook_handler)) + .layer(ConcurrencyLimitLayer::new(100)) + .with_state(Arc::new(state)) +} + /// Axum handler that receives a webhook and sends it to a webhook channel. pub async fn github_webhook_handler( State(state): State, diff --git a/src/lib.rs b/src/lib.rs index 9ff3f6ad..14e5b8d3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,10 +1,17 @@ //! This is the library of the bors bot. -pub mod bors; -pub mod config; -pub mod database; -pub mod github; -pub mod permissions; -pub mod utils; +mod bors; +mod config; +mod database; +mod github; +mod permissions; +mod utils; + +pub use bors::{event::BorsEvent, BorsContext, BorsState, CommandParser}; +pub use database::SeaORMClient; +pub use github::{ + server::{create_app, create_bors_process, ServerState}, + GithubAppState, WebhookSecret, +}; #[cfg(test)] mod tests; From 0c6703430dba635c9d50965b2806ac3992fa3a75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Fri, 19 Apr 2024 21:15:24 +0200 Subject: [PATCH 41/57] Add a few logs and comments --- src/bin/bors.rs | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/bin/bors.rs b/src/bin/bors.rs index 92d2e5a9..e11718ac 100644 --- a/src/bin/bors.rs +++ b/src/bin/bors.rs @@ -41,7 +41,9 @@ struct Opts { cmd_prefix: String, } -async fn server(state: ServerState) -> anyhow::Result<()> { +/// Starts a server that receives GitHub webhooks and generates events into a queue +/// that is then handled by the Bors process. +async fn webhook_server(state: ServerState) -> anyhow::Result<()> { let app = create_app(state); let addr = SocketAddr::from(([0, 0, 0, 0], 8080)); @@ -49,6 +51,8 @@ async fn server(state: ServerState) -> anyhow::Result<()> { .await .context("Cannot create TCP/IP server socket")?; + tracing::info!("Listening on 0.0.0.0:{}", listener.local_addr()?.port()); + axum::serve(listener, app).await?; Ok(()) } @@ -69,12 +73,14 @@ fn try_main(opts: Opts) -> anyhow::Result<()> { .block_on(initialize_db(&opts.db)) .context("Cannot initialize database")?; - let state = runtime.block_on(GithubAppState::load( - opts.app_id.into(), - opts.private_key.into_bytes().into(), - ))?; + let state = runtime + .block_on(GithubAppState::load( + opts.app_id.into(), + opts.private_key.into_bytes().into(), + )) + .context("Cannot load GitHub repository state")?; let ctx = BorsContext::new(CommandParser::new(opts.cmd_prefix), Arc::new(db)); - let (tx, gh_process) = create_bors_process(state, ctx); + let (tx, bors_process) = create_bors_process(state, ctx); let refresh_tx = tx.clone(); let refresh_process = async move { @@ -85,12 +91,12 @@ fn try_main(opts: Opts) -> anyhow::Result<()> { }; let state = ServerState::new(tx, WebhookSecret::new(opts.webhook_secret)); - let server_process = server(state); + let server_process = webhook_server(state); let fut = async move { tokio::select! { - () = gh_process => { - tracing::warn!("Github webhook process has ended"); + () = bors_process => { + tracing::warn!("Bors event handling process has ended"); Ok(()) }, res = refresh_process => { @@ -98,7 +104,7 @@ fn try_main(opts: Opts) -> anyhow::Result<()> { res } res = server_process => { - tracing::warn!("Server has ended: {res:?}"); + tracing::warn!("GitHub webhook listener has ended: {res:?}"); res } } @@ -126,7 +132,7 @@ fn main() { let opts = Opts::parse(); if let Err(error) = try_main(opts) { - eprintln!("Error: {error:?}"); + tracing::error!("Error: {error:?}"); std::process::exit(1); } } From a40c8ae96f7871ebac2744174681ad18edd26026 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Sat, 20 Apr 2024 09:57:18 +0200 Subject: [PATCH 42/57] Remove unneeded LocalSet --- src/bin/bors.rs | 6 +----- src/bors/handlers/mod.rs | 2 +- src/github/server.rs | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/bin/bors.rs b/src/bin/bors.rs index e11718ac..14510dd1 100644 --- a/src/bin/bors.rs +++ b/src/bin/bors.rs @@ -10,7 +10,6 @@ use bors::{ }; use clap::Parser; use sea_orm::Database; -use tokio::task::LocalSet; use tracing_subscriber::EnvFilter; use migration::{Migrator, MigratorTrait}; @@ -110,10 +109,7 @@ fn try_main(opts: Opts) -> anyhow::Result<()> { } }; - runtime.block_on(async move { - let set = LocalSet::new(); - set.run_until(fut).await.unwrap(); - }); + runtime.block_on(fut)?; Ok(()) } diff --git a/src/bors/handlers/mod.rs b/src/bors/handlers/mod.rs index 086051f3..c718b882 100644 --- a/src/bors/handlers/mod.rs +++ b/src/bors/handlers/mod.rs @@ -24,7 +24,7 @@ mod refresh; mod trybuild; mod workflow; -/// This function performs a single BORS event, it is the main execution function of the bot. +/// This function executes a single BORS event, it is the main execution function of the bot. pub async fn handle_bors_event( event: BorsEvent, state: Arc>, diff --git a/src/github/server.rs b/src/github/server.rs index c3dd5481..afe672b5 100644 --- a/src/github/server.rs +++ b/src/github/server.rs @@ -71,12 +71,12 @@ pub fn create_bors_process( let state: Arc> = Arc::new(state); let ctx = Arc::new(ctx); while let Some(event) = rx.recv().await { - tracing::trace!("Received event: {event:#?}"); let state = state.clone(); let ctx = ctx.clone(); tokio::spawn(async move { let span = tracing::info_span!("Event"); + tracing::debug!("Received event: {event:#?}"); if let Err(error) = handle_bors_event(event, state, ctx) .instrument(span.clone()) .await From 1f939c1039dfcedbb63ac6d699f06d8b7ff5442d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Sat, 20 Apr 2024 12:53:01 +0200 Subject: [PATCH 43/57] Temporarily disable concurrency of bors For now, bors does not perform any locking of per-repository GitHub API operations, which share a common resource (e.g. the try branches). This means that it is open to race conditions. Until such locking is introduced, we should handle commands serially. --- src/github/server.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/github/server.rs b/src/github/server.rs index afe672b5..0d4761c3 100644 --- a/src/github/server.rs +++ b/src/github/server.rs @@ -74,16 +74,14 @@ pub fn create_bors_process( let state = state.clone(); let ctx = ctx.clone(); - tokio::spawn(async move { - let span = tracing::info_span!("Event"); - tracing::debug!("Received event: {event:#?}"); - if let Err(error) = handle_bors_event(event, state, ctx) - .instrument(span.clone()) - .await - { - span.log_error(error); - } - }); + let span = tracing::info_span!("Event"); + tracing::debug!("Received event: {event:#?}"); + if let Err(error) = handle_bors_event(event, state, ctx) + .instrument(span.clone()) + .await + { + span.log_error(error); + } } }; (tx, service) From e6a3cd45274ea46462c6cc3c3db5130e4a1db4ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Sat, 20 Apr 2024 10:19:18 +0200 Subject: [PATCH 44/57] Rename architecture.md to design.md --- README.md | 2 +- docs/{architecture.md => design.md} | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename docs/{architecture.md => design.md} (98%) diff --git a/README.md b/README.md index 1083325d..8383878f 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Home of a (WIP) rewrite of the [`homu`](https://github.com/rust-lang/homu) bors implementation in Rust. Commands supported by the bot can be found [here](docs/commands.md). -Architecture of the bot can be found [here](docs/architecture.md). +Design of the bot is described [here](docs/design.md). If you want to help testing the bot, please ask around on the [`#t-infra`](https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra) stream on Rust Zulip. diff --git a/docs/architecture.md b/docs/design.md similarity index 98% rename from docs/architecture.md rename to docs/design.md index 88d97a92..e8947ab9 100644 --- a/docs/architecture.md +++ b/docs/design.md @@ -1,5 +1,5 @@ -# Architecture -This document briefly describes the architecture of bors. +# Bors design +This document briefly describes does the bors bot work. `bors` is a binary that launches (an `axum`) web server, which listens on a `/github` endpoint for webhooks related to a GitHub app attached to the bot. Once a webhook arrives, and it passes a filter of known webhooks, it is converted to From 308e0f45b7042e9877741ef1fd5fc5e58f6df3e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Sat, 20 Apr 2024 10:19:31 +0200 Subject: [PATCH 45/57] Add example rust-bors.toml file --- README.md | 19 +------------------ rust-bors.example.toml | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 18 deletions(-) create mode 100644 rust-bors.example.toml diff --git a/README.md b/README.md index 8383878f..f3e3df35 100644 --- a/README.md +++ b/README.md @@ -36,24 +36,7 @@ If you want to attach `bors` to a GitHub app, you should point its webhooks at ` ### How to add a repository to bors Here is a guide on how to add a repository so that this bot can be used on it: 1) Add a file named `rust-bors.toml` to the root of the main branch of the repository. The configuration struct that -describes the file can be found in `src/config.rs`. Here is an example configuration file: - ```toml - # Maximum duration of CI workflows before the are considered timed out. - # (Required) - timeout = 3600 - - # Labels that should be set on a PR after an event happens. - # "+