From 3cf1a68280586e97173a33047af1ffdecedff078 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Thu, 13 Mar 2025 14:46:35 +0100 Subject: [PATCH 1/4] Add `doc_url` attribute to CI jobs --- src/ci/citool/src/jobs.rs | 5 +++++ src/ci/citool/tests/jobs.rs | 2 +- src/ci/citool/tests/test-jobs.yml | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ci/citool/src/jobs.rs b/src/ci/citool/src/jobs.rs index 45a188fb234a1..0de8b740227d7 100644 --- a/src/ci/citool/src/jobs.rs +++ b/src/ci/citool/src/jobs.rs @@ -24,6 +24,8 @@ pub struct Job { /// Free additional disk space in the job, by removing unused packages. #[serde(default)] pub free_disk: Option, + /// Documentation link to a resource that could help people debug this CI job. + pub doc_url: Option, } impl Job { @@ -103,6 +105,8 @@ struct GithubActionsJob { continue_on_error: Option, #[serde(skip_serializing_if = "Option::is_none")] free_disk: Option, + #[serde(skip_serializing_if = "Option::is_none")] + doc_url: Option, } /// Skip CI jobs that are not supposed to be executed on the given `channel`. @@ -188,6 +192,7 @@ fn calculate_jobs( env, continue_on_error: job.continue_on_error, free_disk: job.free_disk, + doc_url: job.doc_url, } }) .collect(); diff --git a/src/ci/citool/tests/jobs.rs b/src/ci/citool/tests/jobs.rs index 1d81d58f89311..788f5e7e4f661 100644 --- a/src/ci/citool/tests/jobs.rs +++ b/src/ci/citool/tests/jobs.rs @@ -40,7 +40,7 @@ try-job: dist-i686-msvc"#, fn pr_jobs() { let stdout = get_matrix("pull_request", "commit", "refs/heads/pr/1234"); insta::assert_snapshot!(stdout, @r#" - 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}] + 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"}] run_type=pr "#); } diff --git a/src/ci/citool/tests/test-jobs.yml b/src/ci/citool/tests/test-jobs.yml index 56b9ced20719e..ff4d1772f59b9 100644 --- a/src/ci/citool/tests/test-jobs.yml +++ b/src/ci/citool/tests/test-jobs.yml @@ -75,6 +75,7 @@ pr: <<: *job-linux-4c - name: mingw-check-tidy continue_on_error: true + doc_url: https://foo.bar <<: *job-linux-4c # Jobs that run when you perform a try build (@bors try) From aab643f4a75c41f45ad70855a2fb52d27a07225f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Thu, 13 Mar 2025 14:46:46 +0100 Subject: [PATCH 2/4] Fill `doc_url` for Rust for Linux and Fuchsia jobs --- src/ci/github-actions/jobs.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ci/github-actions/jobs.yml b/src/ci/github-actions/jobs.yml index eba55338ff826..d8c3625af2861 100644 --- a/src/ci/github-actions/jobs.yml +++ b/src/ci/github-actions/jobs.yml @@ -267,11 +267,13 @@ auto: # nightly features to compile, and this job would fail if # executed on beta and stable. only_on_channel: nightly + doc_url: https://rustc-dev-guide.rust-lang.org/tests/fuchsia.html <<: *job-linux-8c # Tests integration with Rust for Linux. # Builds stage 1 compiler and tries to compile a few RfL examples with it. - name: x86_64-rust-for-linux + doc_url: https://rustc-dev-guide.rust-lang.org/tests/rust-for-linux.html <<: *job-linux-4c - name: x86_64-gnu From 611764417bd35f631a6384ec0acd88fbc37cdb9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Thu, 13 Mar 2025 14:48:18 +0100 Subject: [PATCH 3/4] Output job doc URL to allow Rust Log Analyzer to access it --- .github/workflows/ci.yml | 1 + src/ci/run.sh | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f166e0c0b416e..98fac74245033 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -68,6 +68,7 @@ jobs: timeout-minutes: 360 env: CI_JOB_NAME: ${{ matrix.name }} + CI_JOB_DOC_URL: ${{ matrix.doc_url }} CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse # commit of PR sha or commit sha. `GITHUB_SHA` is not accurate for PRs. HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }} diff --git a/src/ci/run.sh b/src/ci/run.sh index b874f71832d73..5bb64492033fe 100755 --- a/src/ci/run.sh +++ b/src/ci/run.sh @@ -6,6 +6,10 @@ if [ -n "$CI_JOB_NAME" ]; then echo "[CI_JOB_NAME=$CI_JOB_NAME]" fi +if [ -n "$CI_JOB_DOC_URL" ]; then + echo "[CI_JOB_DOC_URL=$CI_JOB_DOC_URL]" +fi + if [ "$NO_CHANGE_USER" = "" ]; then if [ "$LOCAL_USER_ID" != "" ]; then id -u user &>/dev/null || useradd --shell /bin/bash -u $LOCAL_USER_ID -o -c "" -m user From 0c6d24e373aafc84b9a8b4a00724d7f71b340419 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Thu, 13 Mar 2025 14:50:37 +0100 Subject: [PATCH 4/4] Print job doc URL on job failure --- .github/workflows/ci.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 98fac74245033..96c0955e871b8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -191,8 +191,20 @@ jobs: CARGO_INCREMENTAL=0 CARGO_TARGET_DIR=../../../build/citool cargo build - name: run the build - # Redirect stderr to stdout to avoid reordering the two streams in the GHA logs. - run: src/ci/scripts/run-build-from-ci.sh 2>&1 + run: | + set +e + # Redirect stderr to stdout to avoid reordering the two streams in the GHA logs. + src/ci/scripts/run-build-from-ci.sh 2>&1 + STATUS=$? + set -e + + if [[ "$STATUS" -ne 0 && -n "$CI_JOB_DOC_URL" ]]; then + echo "****************************************************************************" + echo "To find more information about this job, visit the following URL:" + echo "$CI_JOB_DOC_URL" + echo "****************************************************************************" + fi + exit ${STATUS} env: AWS_ACCESS_KEY_ID: ${{ env.CACHES_AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.CACHES_AWS_ACCESS_KEY_ID)] }}