Skip to content

fix: Untested summary job masks gh query failures - #308

Closed
andrewwhitecdw wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
andrewwhitecdw:tests/build-docs-untested-summary-job-masks-gh-query
Closed

fix: Untested summary job masks gh query failures#308
andrewwhitecdw wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
andrewwhitecdw:tests/build-docs-untested-summary-job-masks-gh-query

Conversation

@andrewwhitecdw

Copy link
Copy Markdown
Contributor

This PR addresses the following issue in .github/workflows/build_docs.yml: Untested summary job masks gh query failures.

Changes

  • .github/workflows/build_docs.yml: Untested summary job masks gh query failures.

Details

--- a/.github/workflows/build_docs.yml
+++ b/.github/workflows/build_docs.yml
@@ -1,14 +1,6 @@
-    steps:
-      - name: Result
-        run: |
-          FAILED_JOBS=$(gh run view $GITHUB_RUN_ID --json jobs --jq '[.jobs[] | select(.status == "completed" and .conclusion != "success")] | length') || echo 0
-
-          if [ "${FAILED_JOBS:-0}" -eq 0 ] || [ "$SKIPPING_IS_ALLOWED" == "true" ]; then
-              echo "✅ All previous jobs completed successfully"
-              exit 0
-          else
-              echo "❌ Found $FAILED_JOBS failed job(s)"
-              # Show which jobs failed
-              gh run view $GITHUB_RUN_ID --json jobs --jq '.jobs[] | select(.status == "completed" and .conclusion != "success") | .name'
-              exit 1
-          fi
+    steps:
+      - name: Result
+        run: ./.github/scripts/summarize_failed_jobs.sh
+        env:
+          GITHUB_RUN_ID: ${{ github.run_id }}
+          SKIPPING_IS_ALLOWED: ${{ vars.SKIPPING_IS_ALLOWED }}

Tests

  • tests/test_summarize_failed_jobs.py
diff --git a/tests/test_summarize_failed_jobs.py b/tests/test_summarize_failed_jobs.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/test_summarize_failed_jobs.py
@@ -0,0 +1,68 @@
+import os
+import subprocess
+import tempfile
+import textwrap
+from pathlib import Path
+
+SCRIPT = Path(__file__).parent.parent / ".github" / "scripts" / "summarize_failed_jobs.sh"
+
+
+def _run(script_body: str, *, skipping_allowed: str = "", run_id: str = "123") -> subprocess.CompletedProcess:
+    with tempfile.TemporaryDirectory() as tmp:
+        gh = Path(tmp) / "gh"
+        gh.write_text(textwrap.dedent(script_body).strip() + "\n")
+        gh.chmod(0o755)
+        env = {
+            **os.environ,
+            "PATH": f"{tmp}{os.pathsep}{os.environ['PATH']}",
+            "GITHUB_RUN_ID": run_id,
+            "SKIPPING_IS_ALLOWED": skipping_allowed,
+        }
+        return subprocess.run(
+            ["bash", str(SCRIPT)],
+            env=env,
+            capture_output=True,
+            text=True,
+        )
+
+
+def test_exits_zero_when_no_failed_jobs():
+    result = _run("#!/bin/bash\nprintf '%s' '0'")
+    assert result.returncode == 0
+    assert "✅" in result.stdout
+
+
+def test_exits_one_when_failed_jobs_exist():
+    result = _run("#!/bin/bash\nprintf '%s' '2'")
+    assert result.returncode == 1
+    assert "Found 2 failed job(s)" in result.stdout
+
+
+def test_exits_zero_when_skipping_allowed():
+    result = _run("#!/bin/bash\nprintf '%s' '2'", skipping_allowed="true")
+    assert result.returncode == 0
+    assert "✅" in result.stdout
+
+
+def test_fails_loudly_when_gh_query_fails():
+    result = _run("#!/bin/bash\nexit 1\n")
+    assert result.returncode != 0

Contributor guidelines

Per this repo's CONTRIBUTING.md:

  • All commits are signed off (Signed-off-by trailer, DCO).

Signed-off-by: Andrew White <andrewh@cdw.com>
@andrewwhitecdw

Copy link
Copy Markdown
Contributor Author

Closing after multiple repair attempts: original patch no longer applies or auditor feedback remains unaddressed.

@andrewwhitecdw
andrewwhitecdw deleted the tests/build-docs-untested-summary-job-masks-gh-query branch August 2, 2026 23:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant