@@ -13,6 +13,8 @@ use build_helper::git::{GitConfig, get_closest_upstream_commit};
1313use build_helper:: stage0_parser:: { Stage0Config , parse_stage0_file} ;
1414use termcolor:: WriteColor ;
1515
16+ use crate :: diagnostics:: { DiagCtx , RunningCheck } ;
17+
1618macro_rules! static_regex {
1719 ( $re: literal) => { {
1820 static RE : :: std:: sync:: LazyLock <:: regex:: Regex > =
@@ -66,7 +68,9 @@ pub struct CiInfo {
6668}
6769
6870impl CiInfo {
69- pub fn new ( bad : & mut bool ) -> Self {
71+ pub fn new ( diag_ctx : DiagCtx ) -> Self {
72+ let mut check = diag_ctx. start_check ( "CI history" ) ;
73+
7074 let stage0 = parse_stage0_file ( ) ;
7175 let Stage0Config { nightly_branch, git_merge_commit_email, .. } = stage0. config ;
7276
@@ -79,11 +83,14 @@ impl CiInfo {
7983 let base_commit = match get_closest_upstream_commit ( None , & info. git_config ( ) , info. ci_env ) {
8084 Ok ( Some ( commit) ) => Some ( commit) ,
8185 Ok ( None ) => {
82- info. error_if_in_ci ( "no base commit found" , bad ) ;
86+ info. error_if_in_ci ( "no base commit found" , & mut check ) ;
8387 None
8488 }
8589 Err ( error) => {
86- info. error_if_in_ci ( & format ! ( "failed to retrieve base commit: {error}" ) , bad) ;
90+ info. error_if_in_ci (
91+ & format ! ( "failed to retrieve base commit: {error}" ) ,
92+ & mut check,
93+ ) ;
8794 None
8895 }
8996 } ;
@@ -98,12 +105,11 @@ impl CiInfo {
98105 }
99106 }
100107
101- pub fn error_if_in_ci ( & self , msg : & str , bad : & mut bool ) {
108+ pub fn error_if_in_ci ( & self , msg : & str , check : & mut RunningCheck ) {
102109 if self . ci_env . is_running_in_ci ( ) {
103- * bad = true ;
104- eprintln ! ( "tidy check error: {msg}" ) ;
110+ check. error ( msg) ;
105111 } else {
106- eprintln ! ( "tidy check warning: {msg}. Some checks will be skipped." ) ;
112+ check . warning ( format ! ( "{msg}. Some checks will be skipped." ) ) ;
107113 }
108114 }
109115}
0 commit comments