Skip to content

Commit

Permalink
github-comment-filter: Adapt new config
Browse files Browse the repository at this point in the history
  • Loading branch information
dasJ committed Dec 26, 2024
1 parent 725b990 commit 7e4e24d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
11 changes: 8 additions & 3 deletions ofborg/src/bin/github-comment-filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::env;
use std::error::Error;

use async_std::task;
use tracing::info;
use tracing::{error, info};

use ofborg::config;
use ofborg::easyamqp::{self, ChannelExt, ConsumerExt};
Expand All @@ -14,10 +14,15 @@ fn main() -> Result<(), Box<dyn Error>> {

let arg = env::args()
.nth(1)
.expect("usage: github-comment-filter <config>");
.unwrap_or_else(|| panic!("usage: {} <config>", std::env::args().next().unwrap()));
let cfg = config::load(arg.as_ref());

let conn = easylapin::from_config(&cfg.rabbitmq)?;
let Some(filter_cfg) = config::load(arg.as_ref()).github_comment_filter else {
error!("No comment filter configuration found!");
panic!();
};

let conn = easylapin::from_config(&filter_cfg.rabbitmq)?;
let mut chan = task::block_on(conn.create_channel())?;

chan.declare_exchange(easyamqp::ExchangeConfig {
Expand Down
10 changes: 10 additions & 0 deletions ofborg/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ pub struct Config {
pub github_webhook_receiver: Option<GithubWebhookConfig>,
/// Configuration for the evaluation filter
pub evaluation_filter: Option<EvaluationFilter>,
/// Configuration for the GitHub comment filter
pub github_comment_filter: Option<GithubCommentFilter>,
pub runner: RunnerConfig,
pub feedback: FeedbackConfig,
pub checkout: CheckoutConfig,
Expand Down Expand Up @@ -49,6 +51,14 @@ pub struct EvaluationFilter {
pub rabbitmq: RabbitMqConfig,
}

/// Configuration for the GitHub comment filter
#[derive(Serialize, Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct GithubCommentFilter {
/// RabbitMQ broker to connect to
pub rabbitmq: RabbitMqConfig,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct FeedbackConfig {
pub full_logs: bool,
Expand Down

0 comments on commit 7e4e24d

Please sign in to comment.