Skip to content

[codex] Redirect dependency commands into Docker#5

Merged
AlwinGarside merged 14 commits into
mainfrom
codex/fix-run-dependency-resolution-in-Docker-container
May 12, 2026
Merged

[codex] Redirect dependency commands into Docker#5
AlwinGarside merged 14 commits into
mainfrom
codex/fix-run-dependency-resolution-in-Docker-container

Conversation

@AlwinGarside
Copy link
Copy Markdown
Contributor

Summary

  • redirect dependency-affecting Composer commands through Docker Compose
  • replay raw Composer argv inside the configured service before host execution
  • document command scope and add unit/integration coverage

Root Cause

Composer script events were redirected, but dependency commands such as composer install still ran on the host. That meant dependency resolution and platform requirement checks used the host PHP environment instead of the configured container.

Impact

install, update, require, remove, and reinstall now execute inside the target Docker Compose service when docker-composer is enabled. Existing script redirection, disable flags, inside-container bypass, exclusions, and service mapping behavior remain in place.

Validation

  • composer style-fix
  • composer stan
  • composer test

Comment thread tests/Unit/DockerComposeCommandBuilderTest.php Outdated
Comment thread tests/Unit/DockerComposeCommandBuilderTest.php Outdated
@AlwinGarside AlwinGarside marked this pull request as ready for review May 10, 2026 08:04
@AlwinGarside AlwinGarside self-assigned this May 10, 2026
@AlwinGarside AlwinGarside requested a review from Copilot May 10, 2026 08:51
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR extends empaphy/docker-composer so dependency-affecting Composer commands (e.g., install, update) are executed inside the configured Docker Compose service, ensuring dependency resolution and platform checks match the container environment.

Changes:

  • Add a pre-command-run listener to redirect key dependency commands into Docker Compose before host execution.
  • Add command-building support to replay raw Composer argv inside the container while stripping host-only --working-dir/-d tokens.
  • Update docs and add unit + integration coverage for command redirection and token recovery across Symfony Console versions.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/DockerComposerPlugin.php Registers a command listener and redirects selected dependency commands into Docker Compose.
src/DockerComposeCommandBuilder.php Builds docker compose exec/run commands for Composer commands, replays raw argv, strips host working-dir flags.
tests/Unit/DockerComposerPluginTest.php Adds unit coverage for command redirection paths and fall-through scenarios.
tests/Unit/DockerComposeCommandBuilderTest.php Adds coverage for raw token recovery + working-dir stripping behavior.
tests/Integration/DockerComposerIntegrationTest.php Adds integration assertion that composer install redirects when plugin is installed.
tests/Unit/Mocks/LegacyTokenInput.php Test helper to emulate legacy/raw token storage behavior.
tests/Unit/Mocks/InvalidLegacyTokenInput.php Test helper to validate rejection of malformed legacy token payloads.
README.md Documents expanded scope to include dependency commands.
AGENTS.md Minor wording/formatting adjustments.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/DockerComposerPlugin.php
Comment thread src/DockerComposerPlugin.php Outdated
Copy link
Copy Markdown

Copilot AI left a comment

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 12 out of 12 changed files in this pull request and generated 2 comments.

Comment thread composer.json Outdated
Comment thread src/DockerComposeCommandBuilder.php
@AlwinGarside AlwinGarside force-pushed the codex/fix-run-dependency-resolution-in-Docker-container branch from 22d5cbc to 60bfebc Compare May 11, 2026 15:48
@AlwinGarside AlwinGarside requested a review from Copilot May 12, 2026 06:49
Copy link
Copy Markdown

Copilot AI left a comment

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 13 out of 13 changed files in this pull request and generated 2 comments.

Comment thread composer.json Outdated
Comment thread src/DockerComposeCommandBuilder.php
@AlwinGarside AlwinGarside force-pushed the codex/fix-run-dependency-resolution-in-Docker-container branch from fb9ffcd to 2ccf5f4 Compare May 12, 2026 16:39
Run dependency-affecting Composer commands in the configured Docker Compose service before host Composer begins solving or installing.

This preserves container platform requirements for install, update, require, remove, and reinstall while keeping existing script redirection behavior.
Recover raw Composer command tokens from legacy Symfony Console input storage when getRawTokens is unavailable.

This keeps dependency command redirection compatible with older Composer and Symfony versions used by CI while preserving argument replay semantics.
Avoid assuming Unix shell quoting in the Docker command failure assertion.

Windows CI escapes command output differently, so the test now verifies the command terms without depending on quote style.
Add unit coverage for Composer command argument replay fallbacks, working-dir stripping, command fallthrough guards, and service-mapping command redirects.

This protects the Docker dependency-command redirect behavior and raises the reported line coverage on the affected files.
Add targeted coverage for malformed legacy command tokens, command fallthrough without configuration, and lazy command runner creation.

This brings the affected Docker command redirect files to 100% line coverage and removes an unreachable notice guard now proven by onCommand control flow.
@AlwinGarside AlwinGarside force-pushed the codex/fix-run-dependency-resolution-in-Docker-container branch from 2ccf5f4 to 645d355 Compare May 12, 2026 16:46
@AlwinGarside AlwinGarside requested a review from Copilot May 12, 2026 16:56
Copy link
Copy Markdown

Copilot AI left a comment

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 13 out of 16 changed files in this pull request and generated 1 comment.

Files not reviewed (3)
  • .idea/docker-composer.iml: Language not supported
  • .idea/php.xml: Language not supported
  • .idea/runConfigurations/Unit_Tests.xml: Language not supported

Comment thread AGENTS.md Outdated
Move legacy input test helpers into dedicated mock files so the command builder test declares only its test case.

Keeps behavior unchanged while addressing PR feedback about mixed file responsibilities.
Only register the dependency command listener when the Composer pre-command event API is available.

Also clarifies missing-service warnings for Composer commands so output no longer describes them as scripts.
Add a Symfony-style raw token input double and unit coverage for Composer command replay through getRawTokens().

This addresses PR feedback and protects command token replacement plus host working-directory stripping for current Symfony Console inputs.
@AlwinGarside AlwinGarside force-pushed the codex/fix-run-dependency-resolution-in-Docker-container branch from 645d355 to cd263a1 Compare May 12, 2026 17:18
@AlwinGarside AlwinGarside requested a review from Copilot May 12, 2026 17:27
Copy link
Copy Markdown

Copilot AI left a comment

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 13 out of 16 changed files in this pull request and generated 1 comment.

Files not reviewed (3)
  • .idea/docker-composer.iml: Language not supported
  • .idea/php.xml: Language not supported
  • .idea/runConfigurations/Unit_Tests.xml: Language not supported

Comment thread tests/Integration/DockerComposerIntegrationTest.php
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 12, 2026

Code Coverage Summary (ubuntu)

Code Coverage

Package Line Rate Branch Rate Health
ComposerProcessRunner.php 100% 100%
DockerComposeCommandBuilder.php 100% 100%
DockerComposerConfig.php 100% 100%
DockerComposerPlugin.php 100% 100%
EnvironmentContainerDetector.php 100% 100%
Summary 100% (448 / 448) 100% (0 / 0)

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 12, 2026

Code Coverage Summary (windows)

Code Coverage

Package Line Rate Branch Rate Health
ComposerProcessRunner.php 100% 100%
DockerComposeCommandBuilder.php 100% 100%
DockerComposerConfig.php 100% 100%
DockerComposerPlugin.php 100% 100%
EnvironmentContainerDetector.php 100% 100%
Summary 100% (448 / 448) 100% (0 / 0)

Copy link
Copy Markdown

Copilot AI left a comment

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 16 out of 19 changed files in this pull request and generated no new comments.

Files not reviewed (3)
  • .idea/docker-composer.iml: Language not supported
  • .idea/php.xml: Language not supported
  • .idea/runConfigurations/Unit_Tests.xml: Language not supported

@AlwinGarside AlwinGarside merged commit f4ceab7 into main May 12, 2026
29 checks passed
@AlwinGarside AlwinGarside deleted the codex/fix-run-dependency-resolution-in-Docker-container branch May 12, 2026 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants