@@ -35,6 +35,7 @@ impl TargetMatrix {
35
35
pub ( crate ) fn run ( & self ) -> Result < ( ) , color_eyre:: Report > {
36
36
let mut matrix: Vec < CiTarget > = get_matrix ( ) . clone ( ) ;
37
37
let mut is_default_try = false ;
38
+ let pr: Option < String > ;
38
39
let ( prs, mut app) = match self {
39
40
TargetMatrix {
40
41
merge_group : Some ( ref_) ,
@@ -72,7 +73,13 @@ impl TargetMatrix {
72
73
is_default_try = process_try_comment. 0 ;
73
74
( vec ! [ pr. as_ref( ) ] , process_try_comment. 1 )
74
75
}
75
- _ => ( vec ! [ ] , TargetMatrixArgs :: default ( ) ) ,
76
+ _ => {
77
+ pr = current_pr ( ) ;
78
+ (
79
+ pr. iter ( ) . map ( |s| s. as_str ( ) ) . collect ( ) ,
80
+ TargetMatrixArgs :: default ( ) ,
81
+ )
82
+ }
76
83
} ;
77
84
78
85
// 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<(),
147
154
} ) ?
148
155
{
149
156
app. none = true ;
150
- app. tests . push ( "none" . to_owned ( ) ) ;
157
+ app. tests = vec ! [ "none" . to_owned( ) ] ;
151
158
}
152
159
Ok ( ( ) )
153
160
}
@@ -205,6 +212,16 @@ fn process_merge_group(ref_: &str) -> cross::Result<&str> {
205
212
. ok_or_else ( || eyre:: eyre!( "merge group ref must include \" pr-<num>-<sha>\" " ) )
206
213
}
207
214
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
+
208
225
/// Returns app to use for matrix on try comment, boolean is used to determine if its a try without arguments
209
226
fn process_try_comment ( message : & str ) -> cross:: Result < ( bool , TargetMatrixArgs ) > {
210
227
for line in message. lines ( ) {
@@ -384,7 +401,6 @@ impl TargetMatrixArgs {
384
401
_ => self . tests . clone ( ) ,
385
402
} ;
386
403
tests. retain ( |p| p != "all" ) ;
387
- tests. retain ( |p| p != "none" ) ;
388
404
serde_json:: to_value ( Ser ( tests) )
389
405
}
390
406
}
0 commit comments