Skip to content

[PhpUnitBridge] Declare relative path for phpunit-bridge repository #40879

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

Closed
wants to merge 1 commit into from

Conversation

Toilal
Copy link

@Toilal Toilal commented Apr 20, 2021

Q A
Branch? 5.x for features
Bug fix? no
New feature? yes
Deprecations? no
Tickets Fix #37099
License MIT
Doc PR ---

I'm not sure it's a bugfix or a minor feature, please tell me if I need to rebase this on 4.4 branch.

When running symfony from a docker container with a volume mapped to the host, it may cause issues when symlinks are generated from container root, as absolute links.

For composer to generate a relative symlink, declaration of the path repository should be relative. Anyway, it seems better to configure this repository with relative, i.e. to avoid breaking the link when moving the project directory around the filesystem.

This change compute the relative path before invoking composer to configure phpunit-bridge repository.

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 5.x branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@Toilal Toilal changed the title minor #37099 [PHPUnit-Bridge] Declare relative path for phpunit-bridge repository [PHPUnit-Bridge] Declare relative path for phpunit-bridge repository Apr 20, 2021
@Toilal Toilal force-pushed the phpunit-bridge-relative-path-5-x branch from e850602 to f0a95e6 Compare April 20, 2021 08:37
@Toilal Toilal force-pushed the phpunit-bridge-relative-path-5-x branch from f0a95e6 to b1a83c6 Compare April 20, 2021 08:48
@carsonbot
Copy link

Hey!

I think @gennadigennadigennadi has recently worked with this code. Maybe they can help review this?

Cheers!

Carsonbot

@nicolas-grekas nicolas-grekas added this to the 5.x milestone Apr 22, 2021
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

LGTM for 5.4

@@ -180,4 +180,5 @@ To get the diff between two versions, go to https://github.com/symfony/symfony/c
* feature #38596 [BrowserKit] Add jsonRequest function to the browser-kit client (alexander-schranz)
* feature #38998 [Messenger][SQS] Make sure one can enable debug logs (Nyholm)
* feature #38974 [Intl] deprecate polyfills in favor of symfony/polyfill-intl-icu (nicolas-grekas)
* feature #37099 [PhpUnitBridge] Declare relative path for phpunit-bridge repository (toilal)
Copy link
Member

Choose a reason for hiding this comment

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

should be removed (will be added later while releasing)

$from = is_dir($from) ? rtrim($from, '\/').'/' : $from;
$to = is_dir($to) ? rtrim($to, '\/').'/' : $to;
$from = str_replace('\\', '/', $from);
$to = str_replace('\\', '/', $to);
Copy link
Member

Choose a reason for hiding this comment

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

all \ above should be replaced by \DIRECTORY_SEPARATOR

$passthruOrFail("$COMPOSER require --no-update symfony/phpunit-bridge \"*@dev\"");
$passthruOrFail("$COMPOSER config repositories.phpunit-bridge path ".escapeshellarg(str_replace('/', \DIRECTORY_SEPARATOR, $path)));
$passthruOrFail("$COMPOSER config repositories.phpunit-bridge path ".escapeshellarg(str_replace('/', \DIRECTORY_SEPARATOR, $relativePath)));
Copy link
Member

Choose a reason for hiding this comment

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

we don't need the str_replace anymore, do we?

@nicolas-grekas nicolas-grekas changed the title [PHPUnit-Bridge] Declare relative path for phpunit-bridge repository Declare relative path for phpunit-bridge repository Sep 8, 2021
@carsonbot carsonbot changed the title Declare relative path for phpunit-bridge repository [PhpUnitBridge] Declare relative path for phpunit-bridge repository Sep 8, 2021
@fabpot
Copy link
Member

fabpot commented Oct 19, 2021

@Toilal Do you have time to take comments into accounts?

@nicolas-grekas
Copy link
Member

Closing in favor of #43799, thanks for raising the issue.

nicolas-grekas added a commit that referenced this pull request Oct 28, 2021
…its path relative (nicolas-grekas)

This PR was merged into the 4.4 branch.

Discussion
----------

[PhpUnitBridge] fix symlink to bridge in docker by making its path relative

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #40879
| License       | MIT
| Doc PR        | -

This is a simpler and less generic version of #40879 that should fit the goal:

> When running symfony from a docker container with a volume mapped to the host, it may cause issues when symlinks are generated from container root, as absolute links.

> For composer to generate a relative symlink, declaration of the path repository should be relative.

Commits
-------

3672ee2 [PhpUnitBridge] fix symlink to bridge in docker by making its path relative
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[PHPUnit-Bridge] symlink phpunit-bridge with relative paths?
4 participants