diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 71fb11192b..b3fd86ed8a 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -1620,7 +1620,8 @@ jobs: mkdir -p consolidated cargo xtask e2e-report \ --artifacts-dir e2e-artifacts \ - --html-out consolidated/index.html >> "$GITHUB_STEP_SUMMARY" + --html-out consolidated/index.html > consolidated/support-matrix.md + cat consolidated/support-matrix.md >> "$GITHUB_STEP_SUMMARY" - name: Upload consolidated report if: always() @@ -1628,3 +1629,69 @@ jobs: with: name: e2e-consolidated-report-nightly path: consolidated/ + + # Publishes the consolidated nightly matrix to the repo wiki so the latest + # support matrix is readable without opening a run's artifacts. The page is + # overwritten each night; the run link, commit and date in its header say + # which run it came from. Main-branch runs only, so a dispatch from another + # branch cannot overwrite the page, and never from an empty or cancelled run. + publish-e2e-wiki: + name: Publish E2E support matrix to wiki + runs-on: ubuntu-latest + timeout-minutes: 10 + permissions: + contents: write + needs: e2e-report-nightly + if: ${{ !cancelled() && needs.e2e-report-nightly.result == 'success' && github.repository == 'ROCm/rocm-cli' && github.ref == 'refs/heads/main' }} + concurrency: + group: publish-e2e-wiki + cancel-in-progress: false + steps: + - name: Download consolidated nightly report + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: e2e-consolidated-report-nightly + path: consolidated + + - name: Push page to the wiki + env: + GH_TOKEN: ${{ github.token }} + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + COMMIT_URL: ${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }} + run: | + set -euo pipefail + # An empty consolidation exits 0 upstream; publish only when the + # matrix table is present, so any degenerate output (empty file, + # reworded message) leaves the last good page in place. + if ! grep -q '^| Platform | OS |' consolidated/support-matrix.md; then + echo "::warning::No platform table in the consolidated report; leaving the wiki page unchanged." + exit 0 + fi + page=E2E-Support-Matrix.md + { + echo "# E2E support matrix (latest nightly)" + echo + echo "_Overwritten by the nightly workflow; do not edit by hand._" + echo + echo "- Run: [${GITHUB_RUN_NUMBER}](${RUN_URL})" + echo "- Commit: [\`${GITHUB_SHA::12}\`](${COMMIT_URL})" + echo "- Date: $(date -u +'%Y-%m-%d %H:%M UTC')" + echo + cat consolidated/support-matrix.md + } > "/tmp/${page}" + + wiki="https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.wiki.git" + # GitHub creates the wiki's git repo only when the first page is + # saved in the web UI, so a never-used wiki cannot be cloned or + # pushed to. Fail with the prerequisite rather than a bare 128. + if ! git clone --depth 1 "$wiki" wiki; then + echo "::error::Cannot clone the wiki. If this is the first run, enable the wiki in repo settings and create its first page once in the web UI (GitHub does not create the wiki git repo until then); otherwise it may be a transient network failure, so re-run the job." + exit 1 + fi + cp "/tmp/${page}" "wiki/${page}" + cd wiki + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add "$page" + git commit -m "Update E2E support matrix from nightly run ${GITHUB_RUN_NUMBER}" + git push origin HEAD diff --git a/docs/ci-hardware-testing.md b/docs/ci-hardware-testing.md index b59ba8f45b..f94da3e85a 100644 --- a/docs/ci-hardware-testing.md +++ b/docs/ci-hardware-testing.md @@ -153,6 +153,14 @@ included. Each joins its platforms' reports — including partial or failed runs — by scenario id into one HTML report and GitHub step summary. +On `main`, the `publish-e2e-wiki` job in `nightly.yml` also copies the +consolidated nightly matrix to the `E2E-Support-Matrix` page of the repository +wiki, overwriting it each night (the page header names the run, commit and +date). It skips cancelled runs and runs that consolidated no platforms. One-time +setup: enable the wiki and save its first page in the GitHub web UI, because +GitHub does not create the wiki's git repository until then and the job fails +with that explanation until it exists. + The lane artifacts are named canonically (`e2e-report`, `e2e-gpu-report`, `e2e-gpu-rad3-report`, `e2e-gpu-mi350p-report`, `e2e-gpu-strix-ubuntu-report`, `e2e-gpu-strix-windows-report`, `e2e-gpu-strix-wsl-report`) in `ci.yml` and diff --git a/xtask/src/workflow_contract.rs b/xtask/src/workflow_contract.rs index ef9d9e24da..cb6f594d75 100644 --- a/xtask/src/workflow_contract.rs +++ b/xtask/src/workflow_contract.rs @@ -1704,6 +1704,128 @@ esac } } + #[test] + fn nightly_publishes_the_consolidated_matrix_to_the_wiki() { + let nightly = read_workflow("nightly.yml"); + let report = normalized_whitespace(job_block(&nightly, "e2e-report-nightly")); + assert!( + report.contains("--html-out consolidated/index.html > consolidated/support-matrix.md"), + "the consolidated report job must redirect the markdown matrix into \ + consolidated/support-matrix.md for the wiki job" + ); + assert!( + report.contains("cat consolidated/support-matrix.md >> \"$GITHUB_STEP_SUMMARY\""), + "the nightly step summary must still receive the matrix" + ); + let publish = job_block(&nightly, "publish-e2e-wiki"); + assert_eq!( + job_scalar(publish, "needs"), + "e2e-report-nightly", + "the wiki job must publish the consolidated report, so it must wait for it" + ); + let condition = job_scalar(publish, "if"); + for required in [ + "!cancelled()", + "needs.e2e-report-nightly.result == 'success'", + "github.repository == 'ROCm/rocm-cli'", + "github.ref == 'refs/heads/main'", + ] { + assert!( + condition.contains(required), + "the wiki job's `if:` must require `{required}`: {condition}" + ); + } + assert!( + !condition.contains("always()"), + "always() would publish from a cancelled run: {condition}" + ); + let permissions = job_mapping(publish, "permissions"); + assert_eq!( + permissions.get("contents").map(String::as_str), + Some("write"), + "pushing to the wiki needs contents: write on this job" + ); + let script = normalized_whitespace(publish); + assert!( + script.contains("name: e2e-consolidated-report-nightly") + && script.contains(".wiki.git"), + "the wiki job must download the nightly consolidated artifact and push to the wiki repo" + ); + assert!( + script.contains("git push origin HEAD"), + "the wiki job must push the page" + ); + assert!( + script.contains("if ! git clone --depth 1 \"$wiki\" wiki; then") + && script.contains("exit 1 fi"), + "a failed wiki clone must fail the job with the prerequisite, not be ignored" + ); + assert!( + script + .contains("if ! grep -q '^| Platform | OS |' consolidated/support-matrix.md; then") + && script.contains("leaving the wiki page unchanged"), + "an empty consolidation must leave the last good page in place" + ); + assert!( + !publish.contains("git init"), + "no `git init` fallback: it cannot create a remote wiki" + ); + } + + /// Runs the publish job's real empty-report guard against the generator's + /// real empty output, so rewording either side (or breaking the guard's + /// exit) is caught by behavior rather than by pinning strings. + #[cfg(unix)] + #[test] + fn wiki_publish_guard_stops_on_the_generators_empty_output() { + let nightly = read_workflow("nightly.yml"); + let publish = job_block(&nightly, "publish-e2e-wiki"); + let lines: Vec<&str> = publish.lines().collect(); + let start = lines + .iter() + .position(|l| { + l.trim_start() + .starts_with("if ! grep -q '^| Platform | OS |'") + }) + .expect("publish job has the empty-report guard"); + let end = start + + lines[start..] + .iter() + .position(|l| l.trim() == "fi") + .expect("guard is closed by fi"); + let guard = lines[start..=end].join("\n"); + + let run = |matrix: &str| -> String { + let tmp = tempfile::tempdir().unwrap(); + let dir = tmp.path(); + std::fs::create_dir_all(dir.join("consolidated")).unwrap(); + std::fs::write(dir.join("consolidated/support-matrix.md"), matrix).unwrap(); + let script = format!("set -euo pipefail\n{guard}\necho REACHED_PUBLISH\n"); + let out = std::process::Command::new("bash") + .arg("-c") + .arg(script) + .current_dir(dir) + .output() + .expect("run bash"); + assert!(out.status.success(), "guard script failed: {out:?}"); + String::from_utf8_lossy(&out.stdout).into_owned() + }; + + let empty = e2e_report::consolidated_summary_markdown(&[]); + assert!( + !run(&empty).contains("REACHED_PUBLISH"), + "the generator's empty output must stop the publish" + ); + assert!( + !run("").contains("REACHED_PUBLISH"), + "a zero-byte matrix must not be published" + ); + assert!( + run("## E2E consolidated report\n\n| Platform | OS |\n").contains("REACHED_PUBLISH"), + "a matrix with platforms must reach the publish step" + ); + } + #[test] fn dispatchable_wsl_nightly_run_has_the_full_nightly_job_budget() { let self_hosted = read_workflow("e2e-selfhosted.yml");