-
Notifications
You must be signed in to change notification settings - Fork 332
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
feat(sync): Addition of the sync command to the deploy pipeline #2997
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of petty changes in the review. Majorly, I think the flow should be,
- Sync npmjs version to all of the package.json (have a map of these like now)
- Perform increment command and update the map above with changed package versions
- Now, do syncDependency on changed packages alone
- Perform npm publish on changed packages alone
Right now, it doesn't do Step 1 I believe.
@InteractiveTimmy - Please correct me if am wrong.
/** | ||
* Configuration Object for this increment Command configuration. | ||
*/ | ||
config: CONSTANTS.CONFIG, | ||
|
||
/** | ||
* Handles incrementing packages based on the provided Options from a | ||
* Commands class instance. | ||
* | ||
* @param options - Options provided from the CLI interface. | ||
* @returns - Promise that resolves once the process is complete. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the comments here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated this. Will push this in the next commit
@mkesavan13 can you elaborate on this one? Not able to understand this point. What would this map look like? I agree that if the increment is done after sync, we might have a situation such as this: After increment However, in the package.json of @webex/package-b - dependency of @webex/package-a would still be 2.59.0 while publishing? @InteractiveTimmy am I correct? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some changes needed around the pipeline changes and the syncing of the dependencies
, devDependencies
, etc not being needed.
If you find that when just adding the version
key:value to all packages, the packed sub-package still doesn't have the correct versions, please reach out to me.
.github/workflows/deploy.yml
Outdated
@@ -171,7 +171,7 @@ jobs: | |||
key: dist-${{ env.rid }} | |||
|
|||
- name: Synchronize Packages | |||
run: yarn | |||
run: yarn package-tools sync --tag ${GITHUB_REF##*/} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A caveat for yarn workspaces in GitHub Actions is that we will need to run yarn
as well as yarn package-tools sync --tag ${GITHUB_REF##*/}
. Since each job
on GitHub Actions starts with a fresh instance, it needs to align all local packages after uncaching dependencies. Example:
run: |
yarn
yarn package-tools sync --tag ${GITHUB_REF##*/}
yarn
must be ran once first on any job that needs to use yarn in a workspaces environment [after uncaching]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed this
* | ||
* @returns - Promse that resolves to this Package instance. | ||
*/ | ||
public syncDependency(deps: Record<string, string>, devDeps: boolean = false): Promise<this> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
syncDependencies
may not be needed. when we run yarn npm publish
on a sub-package using yarn workspaces it looks for the version
key:value in the package.json
for all dependent packages automatically and writes them for us. We should only need to put the correct and current version
key:value into each sub-packages package.json
, and not touch the dependencies list within each package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought so too. But I was confused if semantic-release did this for us all this while or the yarn npm publish
Thanks for the clarification @InteractiveTimmy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@InteractiveTimmy @mkesavan13 I've removed syncDependency based on the discussion
@sreenara - To respond to your comment and Since @InteractiveTimmy mentioned that the dependent package versions will be changed by 1. Sync npmjs version to all of the package.json
2. Perform increment command
3. syncDependency on changed packages alone
4. Perform npm publish on changed packages alone
@InteractiveTimmy - Please correct me if something is wrong. Thank you. |
I've made changes in the code as per our discussion. Agreed, we don't need syncDependency any more. |
@InteractiveTimmy While doing a yarn pack on the sub-package @webex/plugin-meetings, the legacy packages are getting nulled to 0.0.0 because we don't have folders for them in the repo. How do we handle this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Elegant implementation. Just one minor change.
Also just out of curiosity, aren't we implementing the publish step as well as part of this ticket? @sreenara @InteractiveTimmy
|
||
const tag = options.tag.split('/').pop(); | ||
|
||
console.log('sreenara ', Yarn); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this console log be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
@mkesavan13 We can do that as part of the freezing of the master branch and using next from then. |
|
||
/** | ||
* Dependencies of the package | ||
*/ | ||
dependencies: Record<string, string>; | ||
|
||
/** | ||
* Developer dependencies of the package | ||
*/ | ||
devDependencies: Record<string, string>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe these are needed, please remove. Let me know if I'm missing where they are used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@InteractiveTimmy they aren't being used any more. Have removed them.
? options.packages.includes(pack.name) | ||
: true))) | ||
.then((packs) => Promise.all(packs.map((pack) => pack.inspect()))) | ||
.then((packs) => Promise.all(packs.map((pack) => pack.syncVersion()))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small change needed: syncVersion
was designed to synchronize a branch/release tag to the latest
tag version [keeps all feature branches in line with master/main/latest
]. You should not need this call at all, since inspect()
performs the remote-registry check on NPMJS and prepares the version stored in memory for the apply()
command, which saves the memory-stored version to the disk.
Feel free to remove line 62 all together.
Some Notes
In the case that we are attempting to inspect
a package for either the sync
or increment
commands:
- If the NPMJS package exists, but the tag does not
- We use the latest version with an amended new tag
- If the NPMJS package does not exist
- We throw an error and halt all additional pipeline steps for publishing/incrementing
We will be generating a publish workflow for new packages at a later time, this is outside of the scope of this pull request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@InteractiveTimmy I've removed the line that does the syncVersion. You're right, that's not needed.
Any ideas about the issue with the legacy packages that don't have folders which get nulled to 0.0.0?
As discussed over Webex, these will get fixed during the first publish |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
COMPLETES #SPARK-449508
This pull request addresses
In order to allow for packages to be published with all of the correct versions of their dependencies, a new @webex/package-tools command must be introduced and injected into the deploy pipeline that effectively collects and stores all package versions for a specific branch/release on all packages prior to publishing.
by making the following changes
This PR creates the
sync
command which takes in 2 argumentsdeploy.yml
has also been modified to run the sync command before incrementing the versions of the packages using theincrement
command.Change Type
The following scenarios where tested
Running
yarn package-tools sync --tag next
yarn package-tools increment --packages @webex/plugin-meetings
@webex/plugin-meetings/package.json
Before:
After:
I certified that
I have read and followed contributing guidelines
I discussed changes with code owners prior to submitting this pull request
I have not skipped any automated checks
All existing and new tests passed
I have updated the documentation accordingly
Make sure to have followed the contributing guidelines before submitting.