Skip to content

Commit 9e9bf35

Browse files
authored
improve tests (#1433)
fixes issue introduced in #1431
2 parents 188b17e + c7ed407 commit 9e9bf35

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,5 +449,5 @@ jobs:
449449
./codecov -F $name ${pr:+-P ${pr}} -f $file --sha ${sha_rev} -n $name;
450450
done
451451
env:
452-
pr: ${{ steps.pr-number.outputs.pr || '' }}
452+
pr: ${{ steps.pr-number.outputs.pr }}
453453
artifacts: ${{ runner.temp }}/artifacts

xtask/src/ci/target_matrix.rs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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
209226
fn 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

Comments
 (0)