Merge pull request #622 from Artturin/updates2

This commit is contained in:
Cole Helbling 2022-11-13 07:56:19 -08:00 committed by GitHub
commit d56502e692
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 1061 additions and 666 deletions

1645
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -7,4 +7,4 @@ edition = "2018"
[dependencies] [dependencies]
ofborg = { path = "../ofborg" } ofborg = { path = "../ofborg" }
log = "0.3.8" log = "0.4.17"

View file

@ -1,4 +1,3 @@
#[macro_use]
extern crate log; extern crate log;
use std::env; use std::env;

View file

@ -6,26 +6,28 @@ build = "build.rs"
edition = "2018" edition = "2018"
[dependencies] [dependencies]
async-std = { version = "=1.6.0", features = ["unstable"] } async-std = { version = "=1.12.0", features = ["unstable"] }
chrono = "0.4.6" chrono = "0.4.22"
either = "1.4.0" either = "1.8.0"
fs2 = "0.4.2" fs2 = "0.4.3"
futures-util = "0.3.21" futures-util = "0.3.25"
hubcaps = { git = "https://github.com/grahamc/hubcaps.git" } hubcaps = { git = "https://github.com/grahamc/hubcaps.git" }
#hubcaps = { path = "../../../grahamc/hubcaps/" } # for testing patches #hubcaps = { path = "../../../grahamc/hubcaps/" } # for testing patches
hyper = "0.10.*" # to upgrade hyper, hubcaps has to be updated too
# newer hyper has hyper::StatusCode while hubcaps returns a hyper::status::StatusCode
hyper = "=0.10.*"
hyper-native-tls = "0.3.0" hyper-native-tls = "0.3.0"
lapin = "1.0.0" lapin = "2.1.1"
lru-cache = "0.1.1" lru-cache = "0.1.2"
md5 = "0.3.5" md5 = "0.7.0"
nom = "4.0.0-beta3" nom = "4.2.3"
regex = "1.5.4" regex = "1.7.0"
separator = "0.4.1" separator = "0.4.1"
serde = "1.0" serde = "1.0"
serde_derive = "1.0" serde_derive = "1.0"
serde_json = "1.0" serde_json = "1.0"
sys-info = "0.5.6" sys-info = "0.9.1"
tempfile = "2.2.0" tempfile = "3.3.0"
tracing = "0.1.13" tracing = "0.1.37"
tracing-subscriber = { version = "0.2.5", features = ["json"] } tracing-subscriber = { version = "0.3.16", features = ["json", "env-filter"] }
uuid = { version = "0.4", features = ["v4"] } uuid = { version = "1.2", features = ["v4"] }

View file

@ -182,7 +182,7 @@ impl Metric {
} }
fn events() -> Vec<MetricType> { fn events() -> Vec<MetricType> {
return vec![ vec![
Metric::ticker( Metric::ticker(
"StatCollectorLegacyEvent", "StatCollectorLegacyEvent",
"Number of received legacy events", "Number of received legacy events",
@ -346,7 +346,7 @@ fn events() -> Vec<MetricType> {
None None
), ),
*/ */
]; ]
} }
fn main() { fn main() {

View file

@ -64,14 +64,14 @@ pub fn parse_line(text: &str) -> Option<Vec<Instruction>> {
} }
} }
#[derive(PartialEq, Debug)] #[derive(PartialEq, Eq, Debug)]
pub enum Instruction { pub enum Instruction {
Build(Subset, Vec<String>), Build(Subset, Vec<String>),
Eval, Eval,
} }
#[allow(clippy::upper_case_acronyms)] #[allow(clippy::upper_case_acronyms)]
#[derive(Serialize, Deserialize, Debug, PartialEq)] #[derive(Serialize, Deserialize, Debug, PartialEq, Eq)]
pub enum Subset { pub enum Subset {
Nixpkgs, Nixpkgs,
NixOS, NixOS,

View file

@ -96,8 +96,7 @@ impl<'a, W: SimpleWorker + 'a> ConsumerExt<'a, W> for Channel {
FieldTable::default(), FieldTable::default(),
))?; ))?;
Ok(Box::pin(async move { Ok(Box::pin(async move {
while let Some(Ok(item)) = consumer.next().await { while let Some(Ok(deliver)) = consumer.next().await {
let (_channel, deliver) = item;
debug!(?deliver.delivery_tag, "consumed delivery"); debug!(?deliver.delivery_tag, "consumed delivery");
let content_type = deliver.properties.content_type(); let content_type = deliver.properties.content_type();
let job = worker let job = worker
@ -170,8 +169,7 @@ impl<'a, W: SimpleNotifyWorker + 'a + Send> ConsumerExt<'a, W> for NotifyChannel
))?; ))?;
let mut chan = self.0; let mut chan = self.0;
Ok(Box::pin(async move { Ok(Box::pin(async move {
while let Some(Ok(item)) = consumer.next().await { while let Some(Ok(deliver)) = consumer.next().await {
let (_channel, deliver) = item;
debug!(?deliver.delivery_tag, "consumed delivery"); debug!(?deliver.delivery_tag, "consumed delivery");
let mut receiver = ChannelNotificationReceiver { let mut receiver = ChannelNotificationReceiver {
channel: &mut chan, channel: &mut chan,
@ -234,7 +232,7 @@ async fn action_deliver(
&exch, &exch,
&key, &key,
BasicPublishOptions::default(), BasicPublishOptions::default(),
msg.content, &msg.content,
props, props,
) )
.await? .await?

View file

@ -8,7 +8,7 @@ pub struct IssueComment {
pub issue: Issue, pub issue: Issue,
} }
#[derive(Serialize, Deserialize, Debug, PartialEq)] #[derive(Serialize, Deserialize, Debug, PartialEq, Eq)]
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
pub enum IssueCommentAction { pub enum IssueCommentAction {
Created, Created,

View file

@ -21,19 +21,19 @@ pub struct BaseChange {
pub sha: ChangeWas, pub sha: ChangeWas,
} }
#[derive(Serialize, Deserialize, Debug, PartialEq)] #[derive(Serialize, Deserialize, Debug, PartialEq, Eq)]
pub struct ChangeWas { pub struct ChangeWas {
pub from: String, pub from: String,
} }
#[derive(Serialize, Deserialize, Debug, PartialEq)] #[derive(Serialize, Deserialize, Debug, PartialEq, Eq)]
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
pub enum PullRequestState { pub enum PullRequestState {
Open, Open,
Closed, Closed,
} }
#[derive(Serialize, Deserialize, Debug, PartialEq)] #[derive(Serialize, Deserialize, Debug, PartialEq, Eq)]
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
pub enum PullRequestAction { pub enum PullRequestAction {
Edited, Edited,

View file

@ -2,7 +2,7 @@ use crate::message::{Pr, Repo};
use hubcaps::checks::Conclusion; use hubcaps::checks::Conclusion;
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
pub enum BuildStatus { pub enum BuildStatus {
Skipped, Skipped,
Success, Success,

View file

@ -14,7 +14,7 @@ use std::process::{Command, Stdio};
use tempfile::tempfile; use tempfile::tempfile;
#[allow(clippy::upper_case_acronyms)] #[allow(clippy::upper_case_acronyms)]
#[derive(Clone, Copy, Debug, PartialEq)] #[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum File { pub enum File {
DefaultNixpkgs, DefaultNixpkgs,
ReleaseNixOS, ReleaseNixOS,
@ -95,7 +95,7 @@ impl fmt::Display for Operation {
} }
} }
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, PartialEq, Eq)]
pub struct Nix { pub struct Nix {
pub system: String, pub system: String,
remote: String, remote: String,
@ -348,8 +348,7 @@ impl Nix {
fn lines_from_file(file: fs::File) -> Vec<String> { fn lines_from_file(file: fs::File) -> Vec<String> {
BufReader::new(file) BufReader::new(file)
.lines() .lines()
.filter(|line| line.is_ok()) .filter_map(|line| line.ok())
.map(|line| line.unwrap())
.filter(|msg| !is_user_setting_warning(msg)) .filter(|msg| !is_user_setting_warning(msg))
.collect() .collect()
} }

View file

@ -43,7 +43,7 @@ impl SysEvents for RabbitMq<lapin::Channel> {
&String::from("stats"), &String::from("stats"),
"", "",
BasicPublishOptions::default(), BasicPublishOptions::default(),
serde_json::to_string(&EventMessage { &serde_json::to_string(&EventMessage {
sender: self.identity.clone(), sender: self.identity.clone(),
events: vec![event], events: vec![event],
}) })

View file

@ -16,7 +16,7 @@ pub enum System {
X8664Linux, X8664Linux,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub struct Stdenvs { pub struct Stdenvs {
nix: nix::Nix, nix: nix::Nix,
co: PathBuf, co: PathBuf,

View file

@ -91,10 +91,10 @@ impl worker::SimpleWorker for EvaluationFilterWorker {
pr: pr_msg, pr: pr_msg,
}; };
return vec![ vec![
worker::publish_serde_action(None, Some("mass-rebuild-check-jobs".to_owned()), &msg), worker::publish_serde_action(None, Some("mass-rebuild-check-jobs".to_owned()), &msg),
worker::Action::Ack, worker::Action::Ack,
]; ]
} }
} }

View file

@ -6,7 +6,7 @@ pub struct Response {}
pub type Actions = Vec<Action>; pub type Actions = Vec<Action>;
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub enum Action { pub enum Action {
Ack, Ack,
NackRequeue, NackRequeue,
@ -14,7 +14,7 @@ pub enum Action {
Publish(Box<QueueMsg>), Publish(Box<QueueMsg>),
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub struct QueueMsg { pub struct QueueMsg {
pub exchange: Option<String>, pub exchange: Option<String>,
pub routing_key: Option<String>, pub routing_key: Option<String>,