Problem
When running checkout
on a PR-triggered workflow, I get this unhelpful error:
bash: cd: myproj: No such file or directory
Revision: 53efa4c0626c054a9c305dfe40dc929a95f1142f not found .... Exiting
After doing some digging, it seems that the underlying git clone
is failing, due to some intermittent network failures with GitHub. If I repeatedly run git clone
directly, I sometimes see:
Cloning into 'myproj'...
kex_exchange_identification: read: Connection reset by peer
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
In other words, the root cause is apparently GitHub in this case (it is dropping the connection). However, Semaphore's checkout
is hiding this error, because stderr for the git clone
command is sent to /dev/null
, like this:
|
git clone --depth $SEMAPHORE_GIT_DEPTH $SEMAPHORE_GIT_URL $SEMAPHORE_GIT_DIR 2>/dev/null |
Instead, checkout
assumes that the clone succeeded (it doesn't check the exit status), and tries to change into the cloned directory, which doesn't exist. So the error the user sees in this case is:
bash: cd: myproj: No such file or directory
Desired behavior
checkout
should abort when a git clone
operation fails, and show a helpful error message; ideally the stderr output of the underlying failed git command.
- In addition, ideally
checkout
would provide a retry mechanism to gracefully recover from intermittent connection failures. Or the documentation should explain how retry
and checkout
can be used together (a naive retry checkout
doesn't work).