Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT] Isolating bin dependencies. #1716

Closed

Conversation

oleg-andreyev
Copy link
Contributor

Reduce conflicts with dev-packages by moving bin dependencies into separate composer.json

@@ -0,0 +1,6 @@
{
"require-dev": {
"phpunit/phpunit": "^9.5.26",
Copy link
Member

Choose a reason for hiding this comment

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

PHPUnit runs in the same process than our code so it cannot have different dependencies.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will work fine, external tools and their dependencies should not affect application/lib dependencies. Had many occasions that phpunit dependency example symfony/process conflicts with app/lib dependencies and had to upgrade phpunit first.

Copy link
Member

Choose a reason for hiding this comment

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

That's the reason they must be compatible: when running tests, PHPUnit will run the tested code inside its own process. And as PHP cannot load 2 definitions of a class, your code will run against the Process class of the PHPUnit dependency instead of using its own dependency, which will break.

Isolating tools is possible when the tool does not execute your own code in its process.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right , phpunit is probably an exception , other tools like psalm could be moved as they don't autoload code

Copy link
Member

Choose a reason for hiding this comment

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

And that's why I reported the issue for PHPUnit, not for Psalm

Copy link
Contributor Author

Choose a reason for hiding this comment

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

reverted phpunit.

- name: Install dependencies
run: |
composer update
composer bin all install
Copy link
Member

Choose a reason for hiding this comment

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

why installing all ? The psalm bin needs to be installed only for the psalm job.

@@ -73,6 +73,11 @@ jobs:
ini-values: "zend.assertions=1"
extensions: "pdo_sqlite"

- name: Install dependencies
run: |
composer update
Copy link
Member

Choose a reason for hiding this comment

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

this should not be done here.

Instead, you need to move the command running composer bin * later in the workflow, after the step Install dependencies with Composer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Composer usually complains that composer.lock is missing and performs update internally

Copy link
Member

Choose a reason for hiding this comment

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

and that's the whole issue: you perform the install or update before the steps that modify the composer.json to change what will get installed.

@oleg-andreyev
Copy link
Contributor Author

This is a Draft or RFC is you wish

@ostrolucky
Copy link
Member

We will consider doing this when a need arises. I'm well aware of composer-bin-plugin and it is quite useful in projects, but I am not aware of any libraries using it. I don't think we should spearhead usage of it, especially since current transition to Symfony 7 goes smooth I would say, which is a proof this isn't worth making our setup more complicated and non-standard for contributors. I have compared installed set of dependencies with and without your PR and I can't see important differences there either.

@greg0ire
Copy link
Member

greg0ire commented Oct 25, 2023

I am not aware of any libraries using it.

We do in sql-formatter since doctrine/sql-formatter#55, but because the need arose.

@ostrolucky ostrolucky closed this Oct 25, 2023
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.

4 participants