From e32b76f8a919925c46d4b993b5da64a90b9a2b61 Mon Sep 17 00:00:00 2001 From: Kexy Biscuit Date: Fri, 19 Jul 2024 22:26:48 +0800 Subject: [PATCH] feat: add text representing success or not In addition to the emoji, adding text helps searching in Telegram. --- server/src/formatter.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/server/src/formatter.rs b/server/src/formatter.rs index dcd84f4..9fdf4e7 100644 --- a/server/src/formatter.rs +++ b/server/src/formatter.rs @@ -4,6 +4,8 @@ use std::borrow::Cow; pub const SUCCESS: &str = "✅️"; pub const FAILED: &str = "❌"; +pub const SUCCESS_TEXT: &str = "successfully"; +pub const FAILED_TEXT: &str = "unsuccessfully"; pub fn to_html_new_pipeline_summary( pipeline_id: i32, @@ -54,7 +56,7 @@ pub fn to_html_build_result( } = job_ok; format!( - r#"{} Job completed on {} ({}) + r#"{} Job {} completed on {} ({}) Job: {} Pipeline: {} @@ -70,6 +72,7 @@ pub fn to_html_build_result( {}"#, if success { SUCCESS } else { FAILED }, + if success { SUCCESS_TEXT } else { FAILED_TEXT }, worker_hostname, worker_arch, format!( @@ -130,8 +133,9 @@ pub fn to_markdown_build_result( } = job_ok; format!( - "{} Job completed on {} \\({}\\)\n\n**Job**: {}\n**Pipeline**: {}\n**Enqueue time**: {}\n**Time elapsed**: {}s\n{}{}**Architecture**: {}\n**Package\\(s\\) to build**: {}\n**Package\\(s\\) successfully built**: {}\n**Package\\(s\\) failed to build**: {}\n**Package\\(s\\) not built due to previous build failure**: {}\n\n{}\n", + "{} Job {} completed on {} \\({}\\)\n\n**Job**: {}\n**Pipeline**: {}\n**Enqueue time**: {}\n**Time elapsed**: {}s\n{}{}**Architecture**: {}\n**Package\\(s\\) to build**: {}\n**Package\\(s\\) successfully built**: {}\n**Package\\(s\\) failed to build**: {}\n**Package\\(s\\) not built due to previous build failure**: {}\n\n{}\n", if success { SUCCESS } else { FAILED }, + if success { SUCCESS_TEXT } else { FAILED_TEXT }, worker_hostname, worker_arch, format!("[#{}](https://buildit.aosc.io/jobs/{})", job.id, job.id), @@ -223,5 +227,5 @@ fn test_format_html_build_result() { let s = to_html_build_result(&pipeline, &job, &job_ok, worker_hostname, worker_arch, true); - assert_eq!(s, "✅\u{fe0f} Job completed on Yerus (amd64)\n\nJob: #1\nPipeline: #1\nEnqueue time: 1970-01-01 00:01:01 UTC\nTime elapsed: 888s\nGit commit: 34acef16\nGit branch: fd-9.0.0\nGitHub PR: #4992\nArchitecture: amd64\nPackage(s) to build: fd, fd2\nPackage(s) successfully built: fd\nPackage(s) failed to build: None\nPackage(s) not built due to previous build failure: \n\nBuild Log >>") + assert_eq!(s, "✅\u{fe0f} Job successfully completed on Yerus (amd64)\n\nJob: #1\nPipeline: #1\nEnqueue time: 1970-01-01 00:01:01 UTC\nTime elapsed: 888s\nGit commit: 34acef16\nGit branch: fd-9.0.0\nGitHub PR: #4992\nArchitecture: amd64\nPackage(s) to build: fd, fd2\nPackage(s) successfully built: fd\nPackage(s) failed to build: None\nPackage(s) not built due to previous build failure: \n\nBuild Log >>") }