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

Node 16 upgrade and peer dependency cleanup #250

Merged
merged 31 commits into from
Apr 14, 2022

Conversation

adamstankiewicz
Copy link
Member

@adamstankiewicz adamstankiewicz commented Apr 5, 2022

Description

  • Moves from Node 12 ➡️ Node 16, as we now rely on NPM workspaces! 🚀
  • Resolves the majority of our peer dependency issues, at least the ones that block an npm install on Node 16+.
    • As a result, most dependencies installed in the root package.json were instead distributed to each individual package as necessary. The tradeoff is we lose having a single source-of-truth of common "global" dependencies like @edx/frontend-platform, but this is OK and was a premature optimization (i.e., we only have 3 packages).
  • Updates .nvmrc to include 16 🎉
  • Moves away from relying on lerna bootstrap, which is a command that is a little magical ✨:
    • It does a combination of installing packages, creating/updating package-lock.json, and creating symlinks between packages in this monorepo to allow importing by the module name, e.g. import { useEnterpriseConfig } from '@edx/frontend-enterprise-utils';.
    • The symlinking behavior was causing discrepancies between local environments and CI, so instead, we will now rely on running npm install ourselves via lerna exec -- npm install to avoid this symlinking wizardry altogether 🧙
    • I think this also may be a step towards using NPM workspaces in the future? Adopts NPM workspaces! 😄

Testing

Using @edx/frontend-enterprise-utils via a module.config.js override in frontend-component-header-edx seemingly led to good results (related PR):

image

Additionally, all 3 packages (@edx/frontend-enterprise-utils, @edx/frontend-enterprise-catalog-search, and @edx/frontend-enterprise-logistration) are used by frontend-app-admin-portal. In a test via module.config.js, the application seems to run no problem 💪

image

The Other stuff

Merge checklist:

  • Evaluate how your changes will impact existing consumers (e.g., frontend-app-learner-portal-enterprise, frontend-app-admin-portal, and frontend-app-enterprise-public-catalog). Will consumers safely be able to upgrade to this change without any breaking changes?
  • Ensure your commit message follows the semantic-release conventional commit message format. If your changes include a breaking change, ensure your commit message is explicitly marked as a BREAKING CHANGE so the NPM package is released as such.
  • Once CI is passing, verify the package versions that Lerna will increment to in the Github Action CI workflow logs.
    • Note: This may be found in the "Preview Updated Versions (dry run)" step in the Github Action CI workflow logs.

Post merge:

  • Verify Lerna created a release commit (e.g., chore(release): publish) that incremented versions in relevant package.json and CHANGELOG files, and created Git tags for those versions.
  • Run the Publish from package.json Github Action workflow to publish these new package versions to NPM.
    • This may be triggered by clicking the "Run workflow" option for the master branch.
  • Verify the new package versions were published to NPM (i.e., npm view <package_name> versions --json).
    • Note: There may be a slight delay between when the workflow finished and when NPM reports the package version as being published. If it doesn't appear right away in the above command, try again in a few minutes.

@adamstankiewicz adamstankiewicz force-pushed the astankiewicz/utils-update-only branch from 65dd2b5 to 7b696a3 Compare April 5, 2022 18:32
@adamstankiewicz adamstankiewicz changed the title fix: resolve most peer deps warnings in utils package fix: resolve some peer dependency warnings Apr 5, 2022
@long74100 long74100 force-pushed the astankiewicz/utils-update-only branch from 8344c30 to f0e21f4 Compare April 5, 2022 21:25
@codecov
Copy link

codecov bot commented Apr 6, 2022

Codecov Report

Merging #250 (465f67f) into master (938dfdc) will decrease coverage by 0.40%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #250      +/-   ##
==========================================
- Coverage   76.31%   75.90%   -0.41%     
==========================================
  Files          33       33              
  Lines         591      606      +15     
  Branches      137      152      +15     
==========================================
+ Hits          451      460       +9     
- Misses        126      132       +6     
  Partials       14       14              
Impacted Files Coverage Δ
packages/logistration/src/LoginRedirect.jsx 100.00% <100.00%> (ø)
packages/catalog-search/src/FacetListBase.jsx 71.05% <0.00%> (-5.42%) ⬇️
packages/catalog-search/src/SearchBox.jsx 94.64% <0.00%> (-1.66%) ⬇️
packages/utils/src/learnerPortalLinks.js 0.00% <0.00%> (ø)
packages/catalog-search/src/data/utils.js 100.00% <0.00%> (ø)
packages/catalog-search/src/SearchContext.jsx 100.00% <0.00%> (ø)
packages/catalog-search/src/SearchPagination.jsx 100.00% <0.00%> (ø)
packages/catalog-search/src/CurrentRefinements.jsx 81.57% <0.00%> (+0.49%) ⬆️
...ages/catalog-search/src/LearningTypeRadioFacet.jsx 88.88% <0.00%> (+0.65%) ⬆️
packages/catalog-search/src/SearchHeader.jsx 91.66% <0.00%> (+0.75%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 938dfdc...465f67f. Read the comment docs.

@adamstankiewicz adamstankiewicz changed the title fix: resolve some peer dependency warnings Node 16 upgrade and peer dependency cleanup Apr 6, 2022
npm whoami
- name: Install and Setup Dependencies
run: |
npm install
Copy link
Contributor

Choose a reason for hiding this comment

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

interesting we need to run two install commands?

Copy link
Member Author

Choose a reason for hiding this comment

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

The first is installing node modules at the root directory (e.g, to install Lerna itself).

The second is to run npm install in all packages. So technically it's 4 installs 🤪

Copy link
Contributor

Choose a reason for hiding this comment

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

ah I see, makes sense now, thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

more the (merrier) 🤣

@adamstankiewicz adamstankiewicz force-pushed the astankiewicz/utils-update-only branch from c5e4a19 to 80c581e Compare April 13, 2022 16:59
- name: Setup Nodejs
uses: actions/setup-node@v3
with:
node-version: 16
Copy link
Member Author

@adamstankiewicz adamstankiewicz Apr 13, 2022

Choose a reason for hiding this comment

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

This repository is now relying on NPM workspaces. As such, it is not compatible with Node 12 or Node 14, as NPM workspaces require npm v7+, so we will only run against Node 16.

Comment on lines +41 to +42
git switch -c "actual-branch-not-detached-head"
lerna version --allow-branch actual-branch-not-detached-head --no-git-tag-version --no-changelog --no-push --yes
Copy link
Member Author

Choose a reason for hiding this comment

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

By changing the on from "push" to "pull_request" ensures this workflow is only run when necessary, but in doing so, the checkout is in a detached HEAD state, so we need to force switch to an attached branch for the version dry-run command to work.

BREAKING CHANGE: The Open edX platform is collectively moving towards Node 16. By doing so in this repository, we can now use NPM workspaces in place of Lerna in many places. Lerna is still used for publishing to NPM, updating CHANGELOGs and package.json files upon released. But NPM workspace commands can now be used instead of Lerna commands for the developer experience, which is more performant, easier to reason about, and natively supported by NPM.
# pulls all commits (needed for lerna / semantic release to correctly version)
fetch-depth: 0
# pulls all tags (needed for lerna / semantic release to correctly version)
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm curious as to why this run directive is the start of it's own sequence and not part of the "Checkout" sequence?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think you can combine run in the same sequence that has a uses. I attempted to move the run directive in the "Checkout" sequence but the CI workflow wasn't running due to an incorrect configuration. I moved it back to its standalone step, but gave it a name, too.

@adamstankiewicz adamstankiewicz merged commit d4e3caf into master Apr 14, 2022
@adamstankiewicz adamstankiewicz deleted the astankiewicz/utils-update-only branch April 14, 2022 16:42
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.

5 participants