Skip to content

ci: fix restore-mtime exit code when last file is deleted on macos runners#6268

Merged
desmondcheongzx merged 3 commits intomainfrom
ci/fix-restore-mtime-exit-code
Feb 21, 2026
Merged

ci: fix restore-mtime exit code when last file is deleted on macos runners#6268
desmondcheongzx merged 3 commits intomainfrom
ci/fix-restore-mtime-exit-code

Conversation

@desmondcheongzx
Copy link
Copy Markdown
Collaborator

@desmondcheongzx desmondcheongzx commented Feb 20, 2026

GitHub Actions shell: bash runs with set -eo pipefail. The [ -f "$file" ] && touch_epoch pattern returns exit code 1 when the file doesn't exist on disk (deleted in a later commit), and if this happens on the last iteration of the while loop, pipefail propagates that exit code and kills the step.

Switch to if/then/fi so a non-existent file is a no-op with exit code 0.

Verified with a temporary smoke-test job on both ubuntu-latest (11s) and macos-latest (54s) that confirmed mtimes are correctly restored on both platforms.

Fixes the restore-mtime failures seen on macOS runners in #6264.

GitHub Actions shell: bash runs with set -eo pipefail. The previous
[ -f ] && touch_epoch pattern returns exit code 1 when the test fails
(file doesn't exist), and if this happens on the last iteration of the
while loop, pipefail propagates that exit code and kills the step.

Switch to if/then/fi so a non-existent file is a no-op with exit code 0.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@desmondcheongzx desmondcheongzx requested a review from a team as a code owner February 20, 2026 23:49
@github-actions github-actions Bot added the ci label Feb 20, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Feb 20, 2026

Greptile Summary

This PR fixes a critical CI issue where the restore-mtime action was failing on macOS runners when the last file processed in the loop was deleted in a later commit.

The root cause is that GitHub Actions runs bash scripts with set -eo pipefail, which means any command returning a non-zero exit code will terminate the script. The original pattern [ -f "$file" ] && touch_epoch returns exit code 1 when the file doesn't exist, and when this occurs on the last iteration of the while loop, pipefail propagates that exit code and kills the step.

The fix replaces the shorthand && pattern with an explicit if/then/fi block, ensuring that non-existent files are handled as a no-op with exit code 0 instead of causing the script to fail.

  • Changed from: [ -f "$file" ] && touch_epoch "$ts" "$file"
  • Changed to: if [ -f "$file" ]; then touch_epoch "$ts" "$file"; fi

This is a correct and safe fix that maintains the same logical behavior while preventing spurious CI failures.

Confidence Score: 5/5

  • This PR is safe to merge with no risk
  • The change is a straightforward bug fix that correctly addresses a shell scripting edge case. The fix transforms a pattern that can fail ([ -f ] &&) into an equivalent pattern that always succeeds (if [ -f ]; then ... fi). This maintains the exact same logical behavior while preventing spurious exit code failures. The change is minimal, well-documented, and directly addresses the reported issue in PR ci: cache workspace crates and share rust caches across all workflows #6264.
  • No files require special attention

Important Files Changed

Filename Overview
.github/actions/restore-mtime/action.yaml Fixed shell script exit code handling by replacing && pattern with explicit if/then/fi to prevent pipeline failures when files don't exist

Last reviewed commit: 7f096bb

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@desmondcheongzx desmondcheongzx changed the title ci: fix restore-mtime exit code when last file is deleted ci: fix restore-mtime exit code when last file is deleted on macos runners Feb 20, 2026
desmondcheongzx and others added 2 commits February 20, 2026 15:56
Add a lightweight job that runs restore-mtime on both Linux and macOS,
then verifies that file mtimes are actually restored to pre-checkout
timestamps. This confirms the BSD touch fallback and the pipefail fix
work correctly on both platforms.

TODO: Remove this job once verified.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Both Linux and macOS passed the smoke test. Remove the temporary job.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.44%. Comparing base (8cb880d) to head (bf183b0).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #6268      +/-   ##
==========================================
- Coverage   73.44%   73.44%   -0.01%     
==========================================
  Files        1003     1003              
  Lines      133436   133156     -280     
==========================================
- Hits        98005    97794     -211     
+ Misses      35431    35362      -69     

see 23 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@desmondcheongzx desmondcheongzx merged commit 9e943df into main Feb 21, 2026
37 checks passed
@desmondcheongzx desmondcheongzx deleted the ci/fix-restore-mtime-exit-code branch February 21, 2026 04:32
gavin9402 pushed a commit to gavin9402/Daft that referenced this pull request Apr 7, 2026
…nners (Eventual-Inc#6268)

GitHub Actions `shell: bash` runs with `set -eo pipefail`. The `[ -f
"$file" ] && touch_epoch` pattern returns exit code 1 when the file
doesn't exist on disk (deleted in a later commit), and if this happens
on the last iteration of the while loop, `pipefail` propagates that exit
code and kills the step.

Switch to `if/then/fi` so a non-existent file is a no-op with exit code
0.

Verified with a temporary smoke-test job on both `ubuntu-latest` (11s)
and `macos-latest` (54s) that confirmed mtimes are correctly restored on
both platforms.

Fixes the restore-mtime failures seen on macOS runners in Eventual-Inc#6264.

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant