Skip to content

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

Merged
deepakmishra2 merged 3 commits into
acquia:mainfrom
amangrover90:CLI-1853-push-artifact-autoload-runtime
Jul 23, 2026
Merged

CLI-1853: Force-add docroot/autoload_runtime.php to push:artifact scaffold files#2021
deepakmishra2 merged 3 commits into
acquia:mainfrom
amangrover90:CLI-1853-push-artifact-autoload-runtime

Conversation

@amangrover90

Copy link
Copy Markdown
Contributor

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 (12da23f) to head (be52b4e).

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.
📢 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 thread tests/phpunit/src/Commands/Push/PushArtifactCommandTest.php
Comment thread tests/phpunit/src/Commands/Push/PushArtifactCommandTest.php
Comment thread tests/phpunit/src/Commands/Push/PushArtifactCommandTest.php
Comment thread src/Command/Push/PushArtifactCommand.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
Contributor 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
@deepakmishra2

Copy link
Copy Markdown
Contributor

@danepowell - Can you review this and please approve once looks good.

Comment thread src/Command/Push/PushArtifactCommand.php
@vishalkhode1
vishalkhode1 self-requested a review July 22, 2026 07:50

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

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 $hasAutoloadRuntime was 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 if git add -f docroot/autoload_runtime.php is called. Adding an explicit shouldNotBeCalled() 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);
        }

Comment thread src/Command/Push/PushArtifactCommand.php

@deepakmishra2 deepakmishra2 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.

LGTM

@deepakmishra2
deepakmishra2 enabled auto-merge (squash) July 23, 2026 09:36
@deepakmishra2
deepakmishra2 disabled auto-merge July 23, 2026 09:36
@deepakmishra2

Copy link
Copy Markdown
Contributor

@copilot can you rerun the CI , i see codecov is running from long time

@deepakmishra2
deepakmishra2 merged commit b3ac77e into acquia:main Jul 23, 2026
15 checks passed
@amangrover90
amangrover90 deleted the CLI-1853-push-artifact-autoload-runtime branch July 24, 2026 06:07
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.

6 participants