Skip to content

Commit 6ae5c8d

Browse files
authoredMar 14, 2025
Rollup merge of #136911 - Kobzol:ci-helper-link, r=marcoieni
Add documentation URL to selected jobs This PR adds the possibility to attach URLs to selected CI jobs, which are then printed at the end of the CI log when a failure happens in that job. The motivation is to allow contributors to find how to fix the specific jobs more quickly. This was proposed on [Zulip](https://rust-lang.zulipchat.com/#narrow/channel/242791-t-infra/topic/Automatic.20useful.20links.20when.20a.20particular.20CI.20job.20fails.3F). An example output can be seen [here](https://github.com/rust-lang/rust/actions/runs/13836290091/job/38712112523?pr=136911). r? `@ghost`
2 parents 459352a + 0c6d24e commit 6ae5c8d

File tree

6 files changed

+28
-3
lines changed

6 files changed

+28
-3
lines changed
 

‎.github/workflows/ci.yml

+15-2
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ jobs:
6868
timeout-minutes: 360
6969
env:
7070
CI_JOB_NAME: ${{ matrix.name }}
71+
CI_JOB_DOC_URL: ${{ matrix.doc_url }}
7172
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
7273
# commit of PR sha or commit sha. `GITHUB_SHA` is not accurate for PRs.
7374
HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
@@ -190,8 +191,20 @@ jobs:
190191
CARGO_INCREMENTAL=0 CARGO_TARGET_DIR=../../../build/citool cargo build
191192
192193
- name: run the build
193-
# Redirect stderr to stdout to avoid reordering the two streams in the GHA logs.
194-
run: src/ci/scripts/run-build-from-ci.sh 2>&1
194+
run: |
195+
set +e
196+
# Redirect stderr to stdout to avoid reordering the two streams in the GHA logs.
197+
src/ci/scripts/run-build-from-ci.sh 2>&1
198+
STATUS=$?
199+
set -e
200+
201+
if [[ "$STATUS" -ne 0 && -n "$CI_JOB_DOC_URL" ]]; then
202+
echo "****************************************************************************"
203+
echo "To find more information about this job, visit the following URL:"
204+
echo "$CI_JOB_DOC_URL"
205+
echo "****************************************************************************"
206+
fi
207+
exit ${STATUS}
195208
env:
196209
AWS_ACCESS_KEY_ID: ${{ env.CACHES_AWS_ACCESS_KEY_ID }}
197210
AWS_SECRET_ACCESS_KEY: ${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.CACHES_AWS_ACCESS_KEY_ID)] }}

‎src/ci/citool/src/jobs.rs

+5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ pub struct Job {
2424
/// Free additional disk space in the job, by removing unused packages.
2525
#[serde(default)]
2626
pub free_disk: Option<bool>,
27+
/// Documentation link to a resource that could help people debug this CI job.
28+
pub doc_url: Option<String>,
2729
}
2830

2931
impl Job {
@@ -103,6 +105,8 @@ struct GithubActionsJob {
103105
continue_on_error: Option<bool>,
104106
#[serde(skip_serializing_if = "Option::is_none")]
105107
free_disk: Option<bool>,
108+
#[serde(skip_serializing_if = "Option::is_none")]
109+
doc_url: Option<String>,
106110
}
107111

108112
/// Skip CI jobs that are not supposed to be executed on the given `channel`.
@@ -188,6 +192,7 @@ fn calculate_jobs(
188192
env,
189193
continue_on_error: job.continue_on_error,
190194
free_disk: job.free_disk,
195+
doc_url: job.doc_url,
191196
}
192197
})
193198
.collect();

‎src/ci/citool/tests/jobs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ try-job: dist-i686-msvc"#,
4040
fn pr_jobs() {
4141
let stdout = get_matrix("pull_request", "commit", "refs/heads/pr/1234");
4242
insta::assert_snapshot!(stdout, @r#"
43-
jobs=[{"name":"mingw-check","full_name":"PR - mingw-check","os":"ubuntu-24.04","env":{"PR_CI_JOB":1},"free_disk":true},{"name":"mingw-check-tidy","full_name":"PR - mingw-check-tidy","os":"ubuntu-24.04","env":{"PR_CI_JOB":1},"continue_on_error":true,"free_disk":true}]
43+
jobs=[{"name":"mingw-check","full_name":"PR - mingw-check","os":"ubuntu-24.04","env":{"PR_CI_JOB":1},"free_disk":true},{"name":"mingw-check-tidy","full_name":"PR - mingw-check-tidy","os":"ubuntu-24.04","env":{"PR_CI_JOB":1},"continue_on_error":true,"free_disk":true,"doc_url":"https://foo.bar"}]
4444
run_type=pr
4545
"#);
4646
}

‎src/ci/citool/tests/test-jobs.yml

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ pr:
7575
<<: *job-linux-4c
7676
- name: mingw-check-tidy
7777
continue_on_error: true
78+
doc_url: https://foo.bar
7879
<<: *job-linux-4c
7980

8081
# Jobs that run when you perform a try build (@bors try)

‎src/ci/github-actions/jobs.yml

+2
Original file line numberDiff line numberDiff line change
@@ -267,11 +267,13 @@ auto:
267267
# nightly features to compile, and this job would fail if
268268
# executed on beta and stable.
269269
only_on_channel: nightly
270+
doc_url: https://rustc-dev-guide.rust-lang.org/tests/fuchsia.html
270271
<<: *job-linux-8c
271272

272273
# Tests integration with Rust for Linux.
273274
# Builds stage 1 compiler and tries to compile a few RfL examples with it.
274275
- name: x86_64-rust-for-linux
276+
doc_url: https://rustc-dev-guide.rust-lang.org/tests/rust-for-linux.html
275277
<<: *job-linux-4c
276278

277279
- name: x86_64-gnu

‎src/ci/run.sh

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ if [ -n "$CI_JOB_NAME" ]; then
66
echo "[CI_JOB_NAME=$CI_JOB_NAME]"
77
fi
88

9+
if [ -n "$CI_JOB_DOC_URL" ]; then
10+
echo "[CI_JOB_DOC_URL=$CI_JOB_DOC_URL]"
11+
fi
12+
913
if [ "$NO_CHANGE_USER" = "" ]; then
1014
if [ "$LOCAL_USER_ID" != "" ]; then
1115
id -u user &>/dev/null || useradd --shell /bin/bash -u $LOCAL_USER_ID -o -c "" -m user

0 commit comments

Comments
 (0)
Please sign in to comment.