Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation URL to selected jobs #136911

Merged
merged 4 commits into from
Mar 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -190,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)] }}
Expand Down
5 changes: 5 additions & 0 deletions src/ci/citool/src/jobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ pub struct Job {
/// Free additional disk space in the job, by removing unused packages.
#[serde(default)]
pub free_disk: Option<bool>,
/// Documentation link to a resource that could help people debug this CI job.
pub doc_url: Option<String>,
}

impl Job {
Expand Down Expand Up @@ -103,6 +105,8 @@ struct GithubActionsJob {
continue_on_error: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
free_disk: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
doc_url: Option<String>,
}

/// Skip CI jobs that are not supposed to be executed on the given `channel`.
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/ci/citool/tests/jobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
"#);
}
Expand Down
1 change: 1 addition & 0 deletions src/ci/citool/tests/test-jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/ci/github-actions/jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this because I want to also add the URL to the comments posted by Rust Log Analyzer. This log entry should help RLA figure out what is the documentation URL.

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
Expand Down
Loading