-
Notifications
You must be signed in to change notification settings - Fork 36
Description
Describe the bug
The current entrypoint.php script does not return a non-zero exit code when a failure occurs internally (such as a Git authentication error, failed chdir, or missing .git directory). This leads to CI jobs (e.g., GitHub Actions, GitLab CI) reporting success even when the monorepo split clearly failed.
Steps to reproduce
- Run the splitter with an invalid Git token (e.g., incorrect or missing token in environment variable).
- Observe that
git clonefails and errors likeAuthentication failedorNo such file or directoryappear. - Despite the failure, the script finishes and returns a
0exit code. - The CI job incorrectly reports success.
Example output
Here is a real-world log extract (GitLab CI), using an intentionally invalid token to simulate an auth error:
$ php /splitter/entrypoint.php [NOTE] Resolving configuration... [NOTE] Cloning "https://gitlab.com/company/project-path.git" repository to "/tmp/monorepo_split/clone_directory" directory [NOTE] Running: git clone -- https://oauth2:[MASKED]@gitlab.com/company/project-path.git /tmp/monorepo_split/clone_directory Cloning into '/tmp/monorepo_split/clone_directory'... remote: HTTP Basic: Access denied. If a password was provided for Git authentication, the password was incorrect or you're required to use a token instead of a password. If a token was provided, it was either incorrect, expired, or improperly scoped. See https://gitlab.com/help/topics/git/troubleshooting_git.md#error-on-git-fetch-http-basic-access-denied fatal: Authentication failed for 'https://gitlab.com/company/project-path.git/' Warning: chdir(): No such file or directory (errno 2) in /splitter/entrypoint.php on line 39 [NOTE] Trying to checkout main branch Switched to a new branch 'main' [NOTE] Cleaning destination repository of old files cp: can't stat '/tmp/monorepo_split/clone_directory/.git': No such file or directory Command failed Cleaning up project directory and file based variables 00:02 Job succeeded
Despite multiple errors (Authentication failed, chdir(): No such file, cp: can't stat), the script finishes with a success status, causing the CI job to incorrectly report success.
Expected behavior
The script should:
- Return a non-zero exit code when an internal command fails.
- Fail fast when a
git clone, file operation, or directory change fails.
Why it matters
This breaks reliability in CI/CD workflows. Downstream tasks may proceed under the false assumption that the split operation succeeded, potentially propagating incorrect states or triggering deployments.
Related
- This issue is a regression from PR #38, which added proper exit handling but was reverted without further discussion.
- Comment: Revert "Fail pipeline when git push errors" #38 (comment)
Proposed solution
Reintroduce exit code handling with exit(1) (or appropriate non-zero codes) when:
git cloneor other shell commands fail (e.g., usingproc_openor checking return values)- Exceptions are thrown or fatal conditions are encountered
- Any operation that makes the split incomplete or invalid