Skip to content

Commit 8fedff4

Browse files
committed
parallelize weekly check
1 parent 403bcbd commit 8fedff4

File tree

3 files changed

+74
-7
lines changed

3 files changed

+74
-7
lines changed

.github/workflows/weekly.yml

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ on:
22
schedule:
33
- cron: '0 0 * * 5'
44
workflow_dispatch:
5+
inputs:
6+
targets:
7+
required: false
8+
description: 'check these space or comma separated targets, supports wildcard *'
59

610
name: Check
711

@@ -10,21 +14,54 @@ env:
1014
CARGO_HTTP_CHECK_REVOKE: false
1115

1216
jobs:
17+
generate-matrix:
18+
runs-on: ubuntu-latest
19+
outputs:
20+
matrix: ${{ steps.generate-matrix.outputs.matrix }}
21+
steps:
22+
- uses: actions/checkout@v3
23+
- uses: ./.github/actions/setup-rust
24+
25+
- name: Generate matrix
26+
id: generate-matrix
27+
run: |
28+
cargo xtask ci-job target-matrix --author "[gha]" --message "check" --weekly
29+
env:
30+
TARGETS: ${{ inputs.targets }}
1331
weekly:
14-
name: Check All Targets - No Cache
32+
name: Check target - No Cache (${{ matrix.pretty }},${{ matrix.os }})
1533
timeout-minutes: 1440
16-
runs-on: ubuntu-latest
34+
runs-on: ${{ matrix.os }}
35+
needs: generate-matrix
36+
strategy:
37+
fail-fast: false
38+
matrix:
39+
include: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
1740
steps:
1841
- uses: actions/checkout@v3
1942
- uses: ./.github/actions/setup-rust
2043
- name: Set up Docker Buildx
44+
if: runner.os == 'Linux'
2145
uses: docker/setup-buildx-action@v2
2246
- name: Build xtask
2347
run: cargo build -p xtask
48+
- name: Prepare Meta
49+
id: prepare-meta
50+
timeout-minutes: 60
51+
run: cargo xtask ci-job prepare-meta "${TARGET}${SUB:+.$SUB}"
52+
env:
53+
TARGET: ${{ matrix.target }}
54+
SUB: ${{ matrix.sub }}
55+
shell: bash
2456
- name: Build Docker image
2557
id: build-docker-image
26-
run: cargo xtask build-docker-image -v --no-cache --no-output --from-ci --no-fastfail --tag weekly
27-
timeout-minutes: 1440
58+
if: steps.prepare-meta.outputs.has-image
59+
timeout-minutes: 120
60+
run: cargo xtask build-docker-image --no-cache --no-output -v "${TARGET}${SUB:+.$SUB}" --tag weekly
61+
env:
62+
TARGET: ${{ matrix.target }}
63+
SUB: ${{ matrix.sub }}
64+
shell: bash
2865
wiki:
2966
name: Ensure wiki is valid
3067
runs-on: ubuntu-latest

xtask/src/ci.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ pub enum CiJob {
3131
message: String,
3232
#[clap(long, env = "COMMIT_AUTHOR")]
3333
author: String,
34+
// check is being run as part of a weekly check
35+
#[clap(long)]
36+
weekly: bool,
3437
},
3538
}
3639

@@ -114,8 +117,12 @@ pub fn ci(args: CiJob, metadata: CargoMetadata) -> cross::Result<()> {
114117
}
115118
}
116119
}
117-
CiJob::TargetMatrix { message, author } => {
118-
target_matrix::run(message, author)?;
120+
CiJob::TargetMatrix {
121+
message,
122+
author,
123+
weekly,
124+
} => {
125+
target_matrix::run(message, author, weekly)?;
119126
}
120127
}
121128
Ok(())

xtask/src/ci/target_matrix.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,28 @@ use serde::{Deserialize, Serialize};
77

88
use crate::util::{get_matrix, gha_output, gha_print, CiTarget, ImageTarget};
99

10-
pub(crate) fn run(message: String, author: String) -> Result<(), color_eyre::Report> {
10+
pub(crate) fn run(message: String, author: String, weekly: bool) -> Result<(), color_eyre::Report> {
1111
let mut matrix: Vec<CiTarget> = get_matrix().clone();
1212
let (prs, mut app) = if author == "bors[bot]" {
1313
process_bors_message(&message)?
14+
} else if weekly {
15+
let app = TargetMatrixArgs {
16+
target: std::env::var("TARGETS")
17+
.unwrap_or_default()
18+
.split(' ')
19+
.flat_map(|s| s.split(','))
20+
.filter(|s| !s.is_empty())
21+
.map(|s| s.to_owned())
22+
.collect(),
23+
std: None,
24+
cpp: None,
25+
dylib: None,
26+
run: None,
27+
runners: vec![],
28+
none: false,
29+
has_image: true,
30+
};
31+
(vec![], app)
1432
} else {
1533
(vec![], TargetMatrixArgs::default())
1634
};
@@ -146,6 +164,8 @@ struct TargetMatrixArgs {
146164
runners: Vec<String>,
147165
#[clap(long)]
148166
none: bool,
167+
#[clap(long)]
168+
has_image: bool,
149169
}
150170

151171
impl TargetMatrixArgs {
@@ -158,6 +178,9 @@ impl TargetMatrixArgs {
158178
std::mem::take(matrix);
159179
return;
160180
}
181+
if self.has_image {
182+
matrix.retain(|t| t.to_image_target().has_ci_image());
183+
}
161184
if !self.target.is_empty() {
162185
matrix.retain(|m| {
163186
let matrix_target = m.to_image_target();

0 commit comments

Comments
 (0)