@@ -35,6 +35,7 @@ impl TargetMatrix {
3535 pub ( crate ) fn run ( & self ) -> Result < ( ) , color_eyre:: Report > {
3636 let mut matrix: Vec < CiTarget > = get_matrix ( ) . clone ( ) ;
3737 let mut is_default_try = false ;
38+ let pr: Option < String > ;
3839 let ( prs, mut app) = match self {
3940 TargetMatrix {
4041 merge_group : Some ( ref_) ,
@@ -72,7 +73,13 @@ impl TargetMatrix {
7273 is_default_try = process_try_comment. 0 ;
7374 ( vec ! [ pr. as_ref( ) ] , process_try_comment. 1 )
7475 }
75- _ => ( vec ! [ ] , TargetMatrixArgs :: default ( ) ) ,
76+ _ => {
77+ pr = current_pr ( ) ;
78+ (
79+ pr. iter ( ) . map ( |s| s. as_str ( ) ) . collect ( ) ,
80+ TargetMatrixArgs :: default ( ) ,
81+ )
82+ }
7683 } ;
7784
7885 // only apply ci labels on prs and `/ci try`,
@@ -147,7 +154,7 @@ fn apply_has_no_ci_tests(prs: &[&str], app: &mut TargetMatrixArgs) -> Result<(),
147154 } ) ?
148155 {
149156 app. none = true ;
150- app. tests . push ( "none" . to_owned ( ) ) ;
157+ app. tests = vec ! [ "none" . to_owned( ) ] ;
151158 }
152159 Ok ( ( ) )
153160}
@@ -205,6 +212,16 @@ fn process_merge_group(ref_: &str) -> cross::Result<&str> {
205212 . ok_or_else ( || eyre:: eyre!( "merge group ref must include \" pr-<num>-<sha>\" " ) )
206213}
207214
215+ fn current_pr ( ) -> Option < String > {
216+ // gh pr view --json number --template "{{.number}}"
217+ let stdout = Command :: new ( "gh" )
218+ . args ( [ "pr" , "view" , "--json" , "number" ] )
219+ . run_and_get_stdout ( & mut Verbosity :: Quiet . into ( ) )
220+ . ok ( ) ?;
221+ let pr_info: serde_json:: Value = serde_json:: from_str ( & stdout) . ok ( ) ?;
222+ pr_info. get ( "number" ) . map ( |n| n. to_string ( ) )
223+ }
224+
208225/// Returns app to use for matrix on try comment, boolean is used to determine if its a try without arguments
209226fn process_try_comment ( message : & str ) -> cross:: Result < ( bool , TargetMatrixArgs ) > {
210227 for line in message. lines ( ) {
@@ -384,7 +401,6 @@ impl TargetMatrixArgs {
384401 _ => self . tests . clone ( ) ,
385402 } ;
386403 tests. retain ( |p| p != "all" ) ;
387- tests. retain ( |p| p != "none" ) ;
388404 serde_json:: to_value ( Ser ( tests) )
389405 }
390406}
0 commit comments