CLI-1853: Force-add docroot/autoload_runtime.php to push:artifact scaffold files#2021
Conversation
Drupal 11.4 introduced docroot/autoload_runtime.php as a Symfony Runtime bootstrap entry point, generated by core-composer-scaffold. Because this file is typically gitignored, `git add -A` alone does not include it in push:artifact builds, causing 500 errors on deployed sites. Add docroot/autoload_runtime.php to the scaffoldFiles list alongside docroot/autoload.php, but only when the file actually exists in the artifact directory. The file_exists guard ensures backwards compatibility with Drupal < 11.4 repos where the file is not generated. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2021 +/- ##
=========================================
Coverage 92.49% 92.49%
- Complexity 1994 1995 +1
=========================================
Files 123 123
Lines 7236 7238 +2
=========================================
+ Hits 6693 6695 +2
Misses 543 543 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Try the dev build for this PR: https://acquia-cli.s3.amazonaws.com/build/pr/2021/acli.phar |
There was a problem hiding this comment.
Pull request overview
Ensures push:artifact artifacts include Drupal 11.4’s docroot/autoload_runtime.php (Symfony Runtime bootstrap) even when it’s gitignored, preventing missing-bootstrap deploy failures.
Changes:
- Conditionally include
docroot/autoload_runtime.phpin the force-add scaffold list when the file exists. - Extend
PushArtifactCommandTestscaffolding/mocks to optionally create/expect the runtime file. - Add a new test intended to cover the Drupal
< 11.4(runtime file absent) scenario.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/Command/Push/PushArtifactCommand.php | Adds conditional inclusion of docroot/autoload_runtime.php to the scaffold force-add list. |
| tests/phpunit/src/Commands/Push/PushArtifactCommandTest.php | Updates mocks to simulate presence/absence of autoload_runtime.php and adds a new test case. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Would it be better to read The contents of that gitignore mostly duplicate what's already in That way when some other critical file gets added in Drupal 12, we don't have to go through this exercise again. |
It could be, but I think it'll be problematic in scenarios where someone would have added so in that case, Also even if was, someone might have added few things to docroot that they wouldn't want to be added to the artifact. e.g. So these are few edge cases where things can get wrongly added to or missed from the deployed artifact. |
|
@danepowell - Can you review this and please approve once looks good. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (2)
tests/phpunit/src/Commands/Push/PushArtifactCommandTest.php:204
- The
setUpPushArtifact(...)call uses several positional boolean arguments, which makes it easy to misread/mis-order (especially now that$hasAutoloadRuntimewas added). Using named arguments here will make the intent of this test much clearer.
$this->setUpPushArtifact($localMachineHelper, $environments[0]->vcs->path, [$environments[0]->vcs->url], 'master:master', true, true, false, true, false);
tests/phpunit/src/Commands/Push/PushArtifactCommandTest.php:405
- In the Drupal < 11.4 branch (
$hasAutoloadRuntime === false), the test currently relies on implicit failures ifgit add -f docroot/autoload_runtime.phpis called. Adding an explicitshouldNotBeCalled()expectation makes the test's intent clearer and will fail with a more direct message if this regresses.
} else {
// Simulate Drupal < 11.4 where autoload_runtime.php is absent.
@unlink($runtimeFile);
}
|
@copilot can you rerun the CI , i see codecov is running from long time |
Summary
Drupal 11.4 introduced
docroot/autoload_runtime.phpas a Symfony Runtime bootstrap entry point, generated bydrupal/core-composer-scaffold. Because this file is typically listed indocroot/.gitignore,git add -Adoes not pick it up duringpush:artifactbuilds. This causes HTTP 500 errors on deployed sites because the bootstrap file is missing from the artifact.Changes:
docroot/autoload_runtime.phpto thescaffoldFiles()hardcoded list alongsidedocroot/autoload.php, using afile_existsguard so it is only force-added when present (backwards compatible with Drupal < 11.4).mockGitAddCommit()inPushArtifactCommandTestto accept a$hasAutoloadRuntimeflag that creates the file on disk (triggering thefile_existscheck) and adds the corresponding mock expectation.testPushArtifactWithoutAutoloadRuntimeto cover the Drupal < 11.4 case (file absent,git add -fnot called).Root cause
scaffoldFiles()atPushArtifactCommand.phpexplicitly force-addsdocroot/autoload.php(and other core scaffold files) becausegit add -Arespects.gitignore. The same pattern is needed forautoload_runtime.php, which Drupal 11.4 added as a new scaffold file that is gitignored by default.Test plan
php vendor/bin/phpunit tests/phpunit/src/Commands/Push/PushArtifactCommandTest.php— all 10 tests passacli push:artifactagainst a Drupal 11.4 site — verifyautoload_runtime.phpis committed to the artifact branchFixes: CLI-1853
🤖 Generated with Claude Code