Skip to content

Commit 1b8a917

Browse files
Merge #1091
1091: improve weekly checks and push the resulting images r=Alexhuszagh a=Emilgardis since the maximum timeout for workflows is not enough, we need to use the same strategy as our normal ci flow also adds the ability to filter targets to run <img width="366" alt="image" src="https://user-images.githubusercontent.com/1502855/197333979-2ad4616e-50ff-4b9a-aea1-dfdef518fe3c.png"> this pr also pushes the results so that the cache is renewed, making the images not stagnate Co-authored-by: Emil Gardström <[email protected]>
2 parents 530e3c9 + 1a3698c commit 1b8a917

File tree

3 files changed

+136
-7
lines changed

3 files changed

+136
-7
lines changed

.github/workflows/weekly.yml

Lines changed: 103 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,116 @@ 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+
49+
- name: Prepare Meta
50+
id: prepare-meta
51+
timeout-minutes: 60
52+
run: cargo xtask ci-job prepare-meta "${TARGET}${SUB:+.$SUB}"
53+
env:
54+
TARGET: ${{ matrix.target }}
55+
SUB: ${{ matrix.sub }}
56+
shell: bash
57+
- name: Docker Meta
58+
if: steps.prepare-meta.outputs.has-image
59+
id: docker-meta
60+
uses: docker/metadata-action@v4
61+
with:
62+
images: |
63+
name=${{ steps.prepare-meta.outputs.image }}
64+
labels: |
65+
${{ fromJSON(steps.prepare-meta.outputs.labels) }}
66+
2467
- name: Build Docker image
2568
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
69+
if: steps.prepare-meta.outputs.has-image
70+
timeout-minutes: 120
71+
run: cargo xtask build-docker-image --no-cache -v "${TARGET}${SUB:+.$SUB}"
72+
env:
73+
TARGET: ${{ matrix.target }}
74+
SUB: ${{ matrix.sub }}
75+
shell: bash
76+
- name: Set Docker image for test
77+
if: steps.prepare-meta.outputs.has-image
78+
run: |
79+
TARGET_VAR="cross_target_${TARGET//-/_}_image"
80+
echo "${TARGET_VAR^^}=${IMAGE}" | tee -a "${GITHUB_ENV}"
81+
env:
82+
TARGET: ${{ matrix.target }}
83+
IMAGE: ${{ steps.build-docker-image.outputs.image }}
84+
shell: bash
85+
- name: Test Image
86+
if: steps.prepare-meta.outputs.has-image && steps.prepare-meta.outputs.test-variant == 'default'
87+
run: ./ci/test.sh
88+
env:
89+
TARGET: ${{ matrix.target }}
90+
CPP: ${{ matrix.cpp }}
91+
DYLIB: ${{ matrix.dylib }}
92+
STD: ${{ matrix.std }}
93+
BUILD_STD: ${{ matrix.build-std }}
94+
RUN: ${{ matrix.run }}
95+
RUNNERS: ${{ matrix.runners }}
96+
shell: bash
97+
98+
- name: Test Zig Image
99+
if: steps.prepare-meta.outputs.has-image && steps.prepare-meta.outputs.test-variant == 'zig'
100+
run: ./ci/test-zig-image.sh
101+
shell: bash
102+
103+
- name: Test Cross Image
104+
if: steps.prepare-meta.outputs.has-image && steps.prepare-meta.outputs.test-variant == 'cross'
105+
run: ./ci/test-cross-image.sh
106+
env:
107+
TARGET: 'aarch64-unknown-linux-gnu'
108+
IMAGE: 'ghcr.io/cross-rs/aarch64-unknown-linux-gnu:main'
109+
shell: bash
110+
111+
- name: Login to GitHub Container Registry
112+
if: steps.prepare-meta.outputs.has-image && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
113+
uses: docker/login-action@v1
114+
with:
115+
registry: ghcr.io
116+
username: ${{ github.actor }}
117+
password: ${{ secrets.GITHUB_TOKEN }}
118+
119+
- name: Push
120+
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
121+
run: cargo xtask build-docker-image -v --push "${TARGET}${SUB:+.$SUB}"
122+
env:
123+
TARGET: ${{ matrix.target }}
124+
SUB: ${{ matrix.sub }}
125+
LABELS: ${{ steps.docker-meta.outputs.labels }}
126+
shell: bash
28127
wiki:
29128
name: Ensure wiki is valid
30129
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)