summaryrefslogtreecommitdiff
path: root/ofborg/tickborg/src/message
diff options
context:
space:
mode:
authorMehmet Samet Duman <yongdohyun@projecttick.org>2026-04-04 23:00:30 +0300
committerMehmet Samet Duman <yongdohyun@projecttick.org>2026-04-04 23:00:30 +0300
commit71ffb442e5f8072c6e0a974df9ae085bcf0e5d2a (patch)
treed336b1d64747aeebb1a80c2e7c4e9b5d24253751 /ofborg/tickborg/src/message
parentf96ea38d595162813a460f80f84e20f8d7f241bc (diff)
downloadProject-Tick-71ffb442e5f8072c6e0a974df9ae085bcf0e5d2a.tar.gz
Project-Tick-71ffb442e5f8072c6e0a974df9ae085bcf0e5d2a.zip
NOISSUE update bootstrap script paths in documentation for Linux and Windows
remove unnecessary badges from README add example environment configuration for Ofborg create production configuration for Ofborg correct RabbitMQ host in example configuration add push event handling in GitHub webhook receiver implement push filter task for handling push events extend build job structure to include push event information enhance build result structure to accommodate push event data add push event data handling in various message processing tasks update log message collector to prevent 404 errors on log links add push filter task to task module Signed-off-by: Mehmet Samet Duman <yongdohyun@projecttick.org>
Diffstat (limited to 'ofborg/tickborg/src/message')
-rw-r--r--ofborg/tickborg/src/message/buildjob.rs44
-rw-r--r--ofborg/tickborg/src/message/buildresult.rs22
-rw-r--r--ofborg/tickborg/src/message/common.rs11
-rw-r--r--ofborg/tickborg/src/message/mod.rs2
4 files changed, 75 insertions, 4 deletions
diff --git a/ofborg/tickborg/src/message/buildjob.rs b/ofborg/tickborg/src/message/buildjob.rs
index b09eae58bf..c4cc61d1fa 100644
--- a/ofborg/tickborg/src/message/buildjob.rs
+++ b/ofborg/tickborg/src/message/buildjob.rs
@@ -1,5 +1,5 @@
use crate::commentparser::Subset;
-use crate::message::{Pr, Repo};
+use crate::message::{Pr, PushTrigger, Repo};
#[derive(serde::Serialize, serde::Deserialize, Debug)]
pub struct BuildJob {
@@ -10,6 +10,9 @@ pub struct BuildJob {
pub request_id: String,
pub logs: Option<ExchangeQueue>, // (Exchange, Routing Key)
pub statusreport: Option<ExchangeQueue>, // (Exchange, Routing Key)
+ /// If set, this build was triggered by a push event, not a PR.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub push: Option<PushTrigger>,
}
#[derive(serde::Serialize, serde::Deserialize, Debug)]
@@ -42,8 +45,47 @@ impl BuildJob {
logs: Some(logs.unwrap_or((Some("logs".to_owned()), Some(logbackrk)))),
statusreport: Some(statusreport.unwrap_or((Some("build-results".to_owned()), None))),
request_id,
+ push: None,
}
}
+
+ /// Create a build job triggered by a push event.
+ pub fn new_push(
+ repo: Repo,
+ push: PushTrigger,
+ attrs: Vec<String>,
+ request_id: String,
+ ) -> BuildJob {
+ let logbackrk = format!(
+ "{}.push.{}",
+ repo.full_name.to_lowercase(),
+ push.branch.replace('/', "-")
+ );
+
+ // Fill pr with push info so downstream consumers (comment poster, etc.)
+ // can still use pr.head_sha for commit statuses / check runs.
+ let pr = Pr {
+ number: 0,
+ head_sha: push.head_sha.clone(),
+ target_branch: Some(push.branch.clone()),
+ };
+
+ BuildJob {
+ repo,
+ pr,
+ subset: None,
+ attrs,
+ logs: Some((Some("logs".to_owned()), Some(logbackrk))),
+ statusreport: Some((Some("build-results".to_owned()), None)),
+ request_id,
+ push: Some(push),
+ }
+ }
+
+ /// Returns true if this build was triggered by a push event.
+ pub fn is_push(&self) -> bool {
+ self.push.is_some()
+ }
}
pub fn from(data: &[u8]) -> Result<BuildJob, serde_json::error::Error> {
diff --git a/ofborg/tickborg/src/message/buildresult.rs b/ofborg/tickborg/src/message/buildresult.rs
index 122edacae3..de482f64da 100644
--- a/ofborg/tickborg/src/message/buildresult.rs
+++ b/ofborg/tickborg/src/message/buildresult.rs
@@ -1,4 +1,4 @@
-use crate::message::{Pr, Repo};
+use crate::message::{Pr, PushTrigger, Repo};
use hubcaps::checks::Conclusion;
@@ -48,6 +48,7 @@ pub struct LegacyBuildResult {
pub status: BuildStatus,
pub skipped_attrs: Option<Vec<String>>,
pub attempted_attrs: Option<Vec<String>>,
+ pub push: Option<PushTrigger>,
}
#[derive(serde::Serialize, serde::Deserialize, Debug)]
@@ -70,6 +71,8 @@ pub enum BuildResult {
status: BuildStatus,
skipped_attrs: Option<Vec<String>>,
attempted_attrs: Option<Vec<String>>,
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ push: Option<PushTrigger>,
},
Legacy {
repo: Repo,
@@ -82,6 +85,8 @@ pub enum BuildResult {
status: Option<BuildStatus>,
skipped_attrs: Option<Vec<String>>,
attempted_attrs: Option<Vec<String>>,
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ push: Option<PushTrigger>,
},
}
@@ -100,6 +105,7 @@ impl BuildResult {
ref request_id,
ref attempted_attrs,
ref skipped_attrs,
+ ref push,
..
} => LegacyBuildResult {
repo: repo.to_owned(),
@@ -111,6 +117,7 @@ impl BuildResult {
status: self.status(),
attempted_attrs: attempted_attrs.to_owned(),
skipped_attrs: skipped_attrs.to_owned(),
+ push: push.to_owned(),
},
BuildResult::V1 {
ref repo,
@@ -121,6 +128,7 @@ impl BuildResult {
ref request_id,
ref attempted_attrs,
ref skipped_attrs,
+ ref push,
..
} => LegacyBuildResult {
repo: repo.to_owned(),
@@ -132,6 +140,7 @@ impl BuildResult {
status: self.status(),
attempted_attrs: attempted_attrs.to_owned(),
skipped_attrs: skipped_attrs.to_owned(),
+ push: push.to_owned(),
},
}
}
@@ -143,6 +152,17 @@ impl BuildResult {
}
}
+ pub fn push(&self) -> Option<PushTrigger> {
+ match self {
+ BuildResult::Legacy { push, .. } => push.to_owned(),
+ BuildResult::V1 { push, .. } => push.to_owned(),
+ }
+ }
+
+ pub fn is_push(&self) -> bool {
+ self.push().is_some()
+ }
+
pub fn status(&self) -> BuildStatus {
match *self {
BuildResult::Legacy {
diff --git a/ofborg/tickborg/src/message/common.rs b/ofborg/tickborg/src/message/common.rs
index c8fcd16ea2..75b5dec04f 100644
--- a/ofborg/tickborg/src/message/common.rs
+++ b/ofborg/tickborg/src/message/common.rs
@@ -6,9 +6,18 @@ pub struct Repo {
pub clone_url: String,
}
-#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)]
+#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
pub struct Pr {
pub target_branch: Option<String>,
pub number: u64,
pub head_sha: String,
}
+
+/// Information about a push event trigger (direct push to a branch).
+#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
+pub struct PushTrigger {
+ pub head_sha: String,
+ pub branch: String,
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub before_sha: Option<String>,
+}
diff --git a/ofborg/tickborg/src/message/mod.rs b/ofborg/tickborg/src/message/mod.rs
index 03551cd1ce..8621f45668 100644
--- a/ofborg/tickborg/src/message/mod.rs
+++ b/ofborg/tickborg/src/message/mod.rs
@@ -4,4 +4,4 @@ pub mod buildresult;
mod common;
pub mod evaluationjob;
-pub use self::common::{Pr, Repo};
+pub use self::common::{Pr, PushTrigger, Repo};