Skip to content

Conversation

@oskosk
Copy link
Contributor

@oskosk oskosk commented May 28, 2019

When bundling the plugin, we remove packages so symlinks are not working there.

This will allow us to work locally with symlinked packages, but rely on the environment variable COMPOSER_MIRROR_PATH_REPOS for build scripts

Is this a new feature or does it add/remove features to an existing part of Jetpack?

The latter

Testing instructions:

  1. check this branch
  2. Remove the vendor directory
  3. run COMPOSER_MIRROR_PATH_REPOS=1 composer install and confirm the jetpack-logo package is mirroed instead of symlinked.

Proposed changelog entry for your changes:

  • None needed

@oskosk oskosk requested a review from a team May 28, 2019 19:32
@jetpackbot
Copy link
Collaborator

jetpackbot commented May 28, 2019

Thank you for the great PR description!

When this PR is ready for review, please apply the [Status] Needs Review label. If you are an a11n, please have someone from your team review the code if possible. The Jetpack team will also review this PR and merge it to be included in the next Jetpack release.

Scheduled Jetpack release: June 4, 2019.
Scheduled code freeze: May 28, 2019

Generated by 🚫 dangerJS against 915ce04

@oskosk oskosk force-pushed the update/dont-symlink-packages branch 2 times, most recently from c961853 to f445ba5 Compare May 28, 2019 20:15
lezama
lezama previously approved these changes May 28, 2019
lezama
lezama previously approved these changes May 28, 2019
@oskosk oskosk force-pushed the update/dont-symlink-packages branch from 72307d1 to 8d45e75 Compare May 28, 2019 21:48
@oskosk oskosk changed the title Build: Do not symlink Jetpack Logo package for now Build: Do not declare symlink strategy for the Jetpack Logo package May 28, 2019
lezama
lezama previously approved these changes May 28, 2019
"name": "automattic/jetpack-logo",
"description": "A logo for Jetpack",
"type": "library",
"version": "1.0.0",
Copy link
Member

@simison simison May 29, 2019

Choose a reason for hiding this comment

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

Note:

When you add a hardcoded version to a VCS, the version will conflict with tag names. Composer will not be able to determine the version number.

via https://getcomposer.org/doc/02-libraries.md#library-versioning (edited)

and

The version of the package. In most cases this is not required and should be omitted

Specifying the version yourself will most likely end up creating problems at some point due to human error.

via

https://getcomposer.org/doc/04-schema.md#version

In the publishing scripts, you might actually want to validate that this isn't here.

Copy link
Member

@tyxla tyxla left a comment

Choose a reason for hiding this comment

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

COMPOSER_MIRROR_PATH_REPOS=1 is a nice find 👍 I'd advise against declaring version in composer.json, but we need to change the stability constraint in the main composer.json. I'll handle that.

"type": "path",
"url": "./packages/logo",
"options": {
"symlink": true
Copy link
Member

Choose a reason for hiding this comment

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

👍

"name": "automattic/jetpack-logo",
"description": "A logo for Jetpack",
"type": "library",
"version": "1.0.0",
Copy link
Member

Choose a reason for hiding this comment

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

By all means, I'd prefer not having to specify this. After all, currently we only need it so composer locally can find the package and symlink/mirror it. Let's avoid that by setting a lower minimum stability for the package (as we don't care about stability - we'll always use the local package). That can happen by specifying @dev as the version/stability constraint.

}
yarn --cwd $TARGET_DIR cache clean
yarn --cwd $TARGET_DIR run build
COMPOSER_MIRROR_PATH_REPOS=1 yarn --cwd $TARGET_DIR run build
Copy link
Member

Choose a reason for hiding this comment

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

👍 This seems to work well for me:

  • Installing automattic/jetpack-logo (dev-update/dont-symlink-packages): Mirroring from ./packages/logo

while without it for local dev I properly get:

  • Installing automattic/jetpack-logo (dev-update/dont-symlink-packages): Symlinking from ./packages/logo

{
"name": "automattic/jetpack-logo",
"version": "1.0.0",
"version": "dev-update/dont-symlink-packages",
Copy link
Member

Choose a reason for hiding this comment

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

@oskosk we'll need to build a new composer.lock when in the master branch to avoid this reference.

@tyxla
Copy link
Member

tyxla commented May 29, 2019

I've just:

  • Removed the version again from the logo package composer.json
  • Updated the stability constraint for the logo package to @dev so Composer wouldn't care about a particular version.
  • Rebuilt the composer.lock (although it'll need another rebuild on master)

Seems to work well for me both in dev and prod, but it's worth getting some @Automattic/jetpack-crew 👀 to test it better.

@tyxla tyxla mentioned this pull request May 29, 2019
Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

This seems to be working now. 🚢 it!

Maybe in a next PR we could consider removing COMPOSER_MIRROR_PATH_REPOS=1 composer install --working-dir $TARGET_DIR altogether, as @oskosk suggested, since we do run composer install later on as part of yarn build.

@jeherve jeherve added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review This PR is ready for review. labels May 29, 2019
Copy link
Member

@tyxla tyxla left a comment

Choose a reason for hiding this comment

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

Tests well for me 👍

@oskosk oskosk merged commit 003372a into master May 29, 2019
@oskosk oskosk deleted the update/dont-symlink-packages branch May 29, 2019 11:34
@matticbot matticbot removed the [Status] Ready to Merge Go ahead, you can push that green button! label May 29, 2019
jeherve pushed a commit that referenced this pull request May 29, 2019
…12480)

* Do not declare symlink strategy

* Update bundling scripts to rely on COMPOSER_MIRROR_PATH_REPOS

* Lower stability constraint of logo package

* Update composer.lock

* Add COMPOSER_MIRROR_PATH_REPOS=1 to composer install too

* Fix composer install in build jetpack script
@jeherve
Copy link
Member

jeherve commented May 29, 2019

Cherry-picked to branch-7.4 in f008508

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.

8 participants