Skip to content

The agent that grows with you

ci(clean-worktree): run only when every earlier step passed

Teknium4eba3ebed151
diff --git a/.github/actions/check-clean-worktree/action.yml b/.github/actions/check-clean-worktree/action.yml
index 47d5cd995dc..388397361af 100644
--- a/.github/actions/check-clean-worktree/action.yml
+++ b/.github/actions/check-clean-worktree/action.yml
@@ -4,10 +4,11 @@ description: >-
files in the checkout. Tests and CI steps must write under their own temp
dirs (pytest's tmp_path, the HERMES_HOME fixture, $RUNNER_TEMP), not into the
repo: stray files from test runs have reached main more than once. Run it as
- the last step of a job, after the checkout exists:
+ the last step of a job, after the checkout exists, with no `if:` (the default
+ success() keeps it off jobs where an earlier step failed and may have left its
+ own temp files):
- name: Check the checkout is clean
- if: always() && !cancelled()
uses: ./.github/actions/check-clean-worktree
inputs:
diff --git a/.github/workflows/js-tests.yml b/.github/workflows/js-tests.yml
index df308ae6bc5..c8da4799ae1 100644
--- a/.github/workflows/js-tests.yml
+++ b/.github/workflows/js-tests.yml
@@ -90,6 +90,7 @@ jobs:
run: node .github/scripts/run-workspace-checks.mjs
- name: Check the checkout is clean
# Last step of every job (tests/ci/test_clean_worktree_check.py): a test or CI step that
- # leaves an untracked or modified file in the checkout is reported here.
- if: always() && !cancelled()
+ # leaves an untracked or modified file in the checkout is reported here. Runs only when
+ # every earlier step passed: a step that failed midway can leave its own temp files
+ # (a half-extracted download, a worktree its later cleanup never removed).
uses: ./.github/actions/check-clean-worktree
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index a5ed3bbf847..9b399ebc0a9 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -127,8 +127,9 @@ jobs:
- name: Check the checkout is clean
# Last step of every job (tests/ci/test_clean_worktree_check.py): a test or CI step that
- # leaves an untracked or modified file in the checkout is reported here.
- if: always() && !cancelled()
+ # leaves an untracked or modified file in the checkout is reported here. Runs only when
+ # every earlier step passed: a step that failed midway can leave its own temp files
+ # (a half-extracted download, a worktree its later cleanup never removed).
uses: ./.github/actions/check-clean-worktree
ruff-blocking:
@@ -164,8 +165,9 @@ jobs:
- name: Check the checkout is clean
# Last step of every job (tests/ci/test_clean_worktree_check.py): a test or CI step that
- # leaves an untracked or modified file in the checkout is reported here.
- if: always() && !cancelled()
+ # leaves an untracked or modified file in the checkout is reported here. Runs only when
+ # every earlier step passed: a step that failed midway can leave its own temp files
+ # (a half-extracted download, a worktree its later cleanup never removed).
uses: ./.github/actions/check-clean-worktree
code-health:
@@ -198,8 +200,9 @@ jobs:
- name: Check the checkout is clean
# Last step of every job (tests/ci/test_clean_worktree_check.py): a test or CI step that
- # leaves an untracked or modified file in the checkout is reported here.
- if: always() && !cancelled()
+ # leaves an untracked or modified file in the checkout is reported here. Runs only when
+ # every earlier step passed: a step that failed midway can leave its own temp files
+ # (a half-extracted download, a worktree its later cleanup never removed).
uses: ./.github/actions/check-clean-worktree
windows-footguns:
@@ -297,6 +300,7 @@ jobs:
python scripts/ci/check_public_surface.py --base "origin/${{ github.base_ref }}" --head origin/pr-head
- name: Check the checkout is clean
# Last step of every job (tests/ci/test_clean_worktree_check.py): a test or CI step that
- # leaves an untracked or modified file in the checkout is reported here.
- if: always() && !cancelled()
+ # leaves an untracked or modified file in the checkout is reported here. Runs only when
+ # every earlier step passed: a step that failed midway can leave its own temp files
+ # (a half-extracted download, a worktree its later cleanup never removed).
uses: ./.github/actions/check-clean-worktree
diff --git a/.github/workflows/tests-os.yml b/.github/workflows/tests-os.yml
index 796fbb1ff12..d38a4a675f8 100644
--- a/.github/workflows/tests-os.yml
+++ b/.github/workflows/tests-os.yml
@@ -197,8 +197,9 @@ jobs:
- name: Check the checkout is clean
# Last step of every job (tests/ci/test_clean_worktree_check.py): a test or CI step that
- # leaves an untracked or modified file in the checkout is reported here.
- if: always() && !cancelled()
+ # leaves an untracked or modified file in the checkout is reported here. Runs only when
+ # every earlier step passed: a step that failed midway can leave its own temp files
+ # (a half-extracted download, a worktree its later cleanup never removed).
uses: ./.github/actions/check-clean-worktree
install-update-e2e:
@@ -279,6 +280,7 @@ jobs:
exit 1
- name: Check the checkout is clean
# Last step of every job (tests/ci/test_clean_worktree_check.py): a test or CI step that
- # leaves an untracked or modified file in the checkout is reported here.
- if: always() && !cancelled()
+ # leaves an untracked or modified file in the checkout is reported here. Runs only when
+ # every earlier step passed: a step that failed midway can leave its own temp files
+ # (a half-extracted download, a worktree its later cleanup never removed).
uses: ./.github/actions/check-clean-worktree
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 1804c249410..cf70c79a369 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -127,8 +127,9 @@ jobs:
- name: Check the checkout is clean
# Last step of every job (tests/ci/test_clean_worktree_check.py): a test or CI step that
- # leaves an untracked or modified file in the checkout is reported here.
- if: always() && !cancelled()
+ # leaves an untracked or modified file in the checkout is reported here. Runs only when
+ # every earlier step passed: a step that failed midway can leave its own temp files
+ # (a half-extracted download, a worktree its later cleanup never removed).
uses: ./.github/actions/check-clean-worktree
e2e:
@@ -217,8 +218,9 @@ jobs:
- name: Check the checkout is clean
# Last step of every job (tests/ci/test_clean_worktree_check.py): a test or CI step that
- # leaves an untracked or modified file in the checkout is reported here.
- if: always() && !cancelled()
+ # leaves an untracked or modified file in the checkout is reported here. Runs only when
+ # every earlier step passed: a step that failed midway can leave its own temp files
+ # (a half-extracted download, a worktree its later cleanup never removed).
uses: ./.github/actions/check-clean-worktree
e2e-upgrade-plan:
@@ -258,8 +260,9 @@ jobs:
- name: Check the checkout is clean
# Last step of every job (tests/ci/test_clean_worktree_check.py): a test or CI step that
- # leaves an untracked or modified file in the checkout is reported here.
- if: always() && !cancelled()
+ # leaves an untracked or modified file in the checkout is reported here. Runs only when
+ # every earlier step passed: a step that failed midway can leave its own temp files
+ # (a half-extracted download, a worktree its later cleanup never removed).
uses: ./.github/actions/check-clean-worktree
e2e-upgrade:
@@ -389,6 +392,7 @@ jobs:
NOUS_API_KEY: ""
- name: Check the checkout is clean
# Last step of every job (tests/ci/test_clean_worktree_check.py): a test or CI step that
- # leaves an untracked or modified file in the checkout is reported here.
- if: always() && !cancelled()
+ # leaves an untracked or modified file in the checkout is reported here. Runs only when
+ # every earlier step passed: a step that failed midway can leave its own temp files
+ # (a half-extracted download, a worktree its later cleanup never removed).
uses: ./.github/actions/check-clean-worktree
diff --git a/tests/ci/test_clean_worktree_check.py b/tests/ci/test_clean_worktree_check.py
index 0947513c4b5..465b206096e 100644
--- a/tests/ci/test_clean_worktree_check.py
+++ b/tests/ci/test_clean_worktree_check.py
@@ -45,8 +45,10 @@ def test_every_checkout_job_ends_with_the_clean_worktree_step():
if last.get("uses") != USES:
problems.append(f"{label}: last step is {last.get('name') or last.get('uses')!r}")
continue
- if str(last.get("if", "")).replace(" ", "") != "always()&&!cancelled()":
- problems.append(f"{label}: needs `if: always() && !cancelled()`, has {last.get('if')!r}")
+ if "if" in last:
+ # Default success(): after a failed step the job is red already, and that step may
+ # have left temp files its own later cleanup would remove (false positives).
+ problems.append(f"{label}: runs with `if: {last['if']}`; leave `if:` off")
if "mode" in (last.get("with") or {}):
problems.append(f"{label}: passes `mode`; the action's default is the only switch")
checkout = next(s for s in steps if str(s.get("uses", "")).startswith("actions/checkout@"))