Skip to content

CLI-1853: Force-add docroot/autoload_runtime.php to push:artifact scaffold files#2021

Open
amangrover90 wants to merge 1 commit into
acquia:mainfrom
amangrover90:CLI-1853-push-artifact-autoload-runtime
Open

CLI-1853: Force-add docroot/autoload_runtime.php to push:artifact scaffold files#2021
amangrover90 wants to merge 1 commit into
acquia:mainfrom
amangrover90:CLI-1853-push-artifact-autoload-runtime

Conversation

@amangrover90

Copy link
Copy Markdown

Summary

Drupal 11.4 introduced docroot/autoload_runtime.php as a Symfony Runtime bootstrap entry point, generated by drupal/core-composer-scaffold. Because this file is typically listed in docroot/.gitignore, git add -A does not pick it up during push:artifact builds. This causes HTTP 500 errors on deployed sites because the bootstrap file is missing from the artifact.

Changes:

  • Add docroot/autoload_runtime.php to the scaffoldFiles() hardcoded list alongside docroot/autoload.php, using a file_exists guard so it is only force-added when present (backwards compatible with Drupal < 11.4).
  • Update mockGitAddCommit() in PushArtifactCommandTest to accept a $hasAutoloadRuntime flag that creates the file on disk (triggering the file_exists check) and adds the corresponding mock expectation.
  • Add testPushArtifactWithoutAutoloadRuntime to cover the Drupal < 11.4 case (file absent, git add -f not called).

Root cause

scaffoldFiles() at PushArtifactCommand.php explicitly force-adds docroot/autoload.php (and other core scaffold files) because git add -A respects .gitignore. The same pattern is needed for autoload_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 pass
  • Manually run acli push:artifact against a Drupal 11.4 site — verify autoload_runtime.php is committed to the artifact branch
  • Run against a Drupal < 11.4 site — verify no errors and the file is not force-added

Fixes: CLI-1853

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings July 14, 2026 10:43
@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.49%. Comparing base (0d9c5db) to head (d2f5bff).

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #2021   +/-   ##
=========================================
  Coverage     92.49%   92.49%           
- Complexity     1991     1992    +1     
=========================================
  Files           123      123           
  Lines          7232     7234    +2     
=========================================
+ Hits           6689     6691    +2     
  Misses          543      543           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

Copy link
Copy Markdown

Try the dev build for this PR: https://acquia-cli.s3.amazonaws.com/build/pr/2021/acli.phar

curl -OL https://acquia-cli.s3.amazonaws.com/build/pr/2021/acli.phar
chmod +x acli.phar

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.php in the force-add scaffold list when the file exists.
  • Extend PushArtifactCommandTest scaffolding/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.

Comment on lines +402 to +405
} else {
// Simulate Drupal < 11.4 where autoload_runtime.php is absent.
@unlink($runtimeFile);
}
$runtimeFile = Path::join($artifactDir, 'docroot', 'autoload_runtime.php');
if ($hasAutoloadRuntime) {
// Simulate Drupal 11.4+ where autoload_runtime.php is generated.
@mkdir(Path::join($artifactDir, 'docroot'), 0777, true);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we should do this

$this->mockRequest('getApplicationByUuid', $applications[0]->uuid);
$environments = $this->mockRequest('getApplicationEnvironments', $applications[0]->uuid);
$localMachineHelper = $this->mockLocalMachineHelper();
$this->setUpPushArtifact($localMachineHelper, $environments[0]->vcs->path, [$environments[0]->vcs->url], 'master:master', true, true, false, true, false);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The setUpPushArtifact() call in the new test has 9 positional args, 5 of them booleans. It's unreadable:
can we do it this way

$this->setUpPushArtifact(
    localMachineHelper: $localMachineHelper,
    vcsPath: $environments[0]->vcs->path,
    vcsUrls: [$environments[0]->vcs->url],
    destGitRef: 'master:master',
    push: false,
    hasAutoloadRuntime: false,
);

Comment on lines +460 to +464
// autoload_runtime.php was introduced in Drupal 11.4 as the Symfony
// Runtime bootstrap entry point. It is not in core's file-mapping so
// it must be force-added like autoload.php, but only when present —
// Drupal < 11.4 does not generate this file.
if (file_exists(Path::join($artifactDir, 'docroot', 'autoload_runtime.php'))) {
@deepakmishra2 deepakmishra2 added the breaking change Requires change record label Jul 14, 2026
@danepowell

Copy link
Copy Markdown
Collaborator

Would it be better to read docroot/.gitignore and force commit everything from there instead?

The contents of that gitignore mostly duplicate what's already in docroot/core/composer.json drupal-scaffold with the exception of autoload.php and autoload_runtime.php.

That way when some other critical file gets added in Drupal 12, we don't have to go through this exercise again.

@amangrover90

Copy link
Copy Markdown
Author

Would it be better to read docroot/.gitignore and force commit everything from there instead?

The contents of that gitignore mostly duplicate what's already in docroot/core/composer.json drupal-scaffold with the exception of autoload.php and autoload_runtime.php.

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 docroot/.gitignore to be not overridden in drupal-scaffold extras:

 "extra": {
        "drupal-scaffold": {
            "gitignore": false,
            },
            "locations": {
                "web-root": "docroot/"
            }
        },

so in that case, docroot/.gitignore might not be updated by scaffolding so it won't be the reliable source of truth for the files to be committed.

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. docroot/scripts which they would have added to the docroot/.gitignore and wouldn't want to add this to the artifact when running acli command locally.

So these are few edge cases where things can get wrongly added to or missed from the deployed artifact.

@deepakmishra2 deepakmishra2 added bug Something isn't working and removed breaking change Requires change record labels Jul 15, 2026
@danepowell danepowell self-requested a review July 15, 2026 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants