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

[fei6062.releaseprotections] Update prepublish checks to add SNAPSHOT_RELEASE support #2412

Merged
merged 7 commits into from
Dec 20, 2024

Conversation

somewhatabstract
Copy link
Member

Summary:

This brings over the latest updates from Perseus, and edits them for Wonder Blocks. The changes are:

  1. New prepublishOnly script in each package that blocks publishing non-snapshot packages when publishing snapshots
  2. Updates 'publish-snapshot.sh' to set the SNAPSHOT_RELEASE env var
  3. Updates pre-publish-check-ci.js and pre-publish-utils.js files to TypeScript
  4. Makes pre-publish-check-ci.ts executable
  5. Adds a check to pre-publish-check-ci.ts to ensure that each public package has the prepublishOnly script
  6. Updates pre-publish-utils.ts and pre-publish-check-ci.ts to perform all checks before erroring, instead of quitting on the first failure. This is a quality of life change to make it easier on devs having to update multiple packages to conform

Long term, might be nice to have a wonder-stuff-cli or something that can encapsulate this stuff across our packages.

This change adds initial protection against accidentally publishing release package versions under a snapshot tag. It protects both automated runs and runs done by a user locally.

The next PR will add workflow changes to block the snapshot publish jobs from running when there is a release workflow in progress. This adds an additional layer of protection and also provides a nicer dev experience by adding a useful PR comment on why it failed.

Methodology:

I diffed the Perseus and Wonder Blocks scripts to work out what was different, then updated things to TS. I then modified the publish script and workflows, as necessary. Finally, I used Copilot Edits in VSCode to update the package.json files with the new prepublishOnly script.

Issue: FEI-6062

Test plan:

This stuff is working in Perseus already. I've tested the new executable nature of the pre-publish checks, and verified the SNAPSHOT_RELEASE behavior for packages by running SNAPSHOT_RELEASE=1 yarn run prepublishOnly in a few packages.

@somewhatabstract somewhatabstract self-assigned this Dec 20, 2024
@somewhatabstract somewhatabstract requested a review from a team December 20, 2024 19:35
Copy link

changeset-bot bot commented Dec 20, 2024

🦋 Changeset detected

Latest commit: cdd7188

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 31 packages
Name Type
@khanacademy/wonder-blocks-progress-spinner Patch
@khanacademy/wonder-blocks-birthday-picker Patch
@khanacademy/wonder-blocks-labeled-field Patch
@khanacademy/wonder-blocks-search-field Patch
@khanacademy/wonder-blocks-testing-core Patch
@khanacademy/wonder-blocks-breadcrumbs Patch
@khanacademy/wonder-blocks-icon-button Patch
@khanacademy/wonder-blocks-typography Patch
@khanacademy/wonder-blocks-accordion Patch
@khanacademy/wonder-blocks-clickable Patch
@khanacademy/wonder-blocks-dropdown Patch
@khanacademy/wonder-blocks-popover Patch
@khanacademy/wonder-blocks-testing Patch
@khanacademy/wonder-blocks-theming Patch
@khanacademy/wonder-blocks-toolbar Patch
@khanacademy/wonder-blocks-tooltip Patch
@khanacademy/wonder-blocks-banner Patch
@khanacademy/wonder-blocks-button Patch
@khanacademy/wonder-blocks-layout Patch
@khanacademy/wonder-blocks-switch Patch
@khanacademy/wonder-blocks-timing Patch
@khanacademy/wonder-blocks-tokens Patch
@khanacademy/wonder-blocks-modal Patch
@khanacademy/wonder-blocks-cell Patch
@khanacademy/wonder-blocks-core Patch
@khanacademy/wonder-blocks-data Patch
@khanacademy/wonder-blocks-form Patch
@khanacademy/wonder-blocks-grid Patch
@khanacademy/wonder-blocks-icon Patch
@khanacademy/wonder-blocks-link Patch
@khanacademy/wonder-blocks-pill Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@khan-actions-bot
Copy link
Contributor

khan-actions-bot commented Dec 20, 2024

Gerald

Required Reviewers
  • @Khan/wonder-blocks for changes to package.json, yarn.lock, .changeset/good-stingrays-bow.md, .changeset/perfect-pens-pay.md, .github/workflows/node-ci-lint.yml, .github/workflows/node-ci-pr.yml, packages/wonder-blocks-accordion/package.json, packages/wonder-blocks-banner/package.json, packages/wonder-blocks-birthday-picker/package.json, packages/wonder-blocks-breadcrumbs/package.json, packages/wonder-blocks-button/package.json, packages/wonder-blocks-cell/package.json, packages/wonder-blocks-clickable/package.json, packages/wonder-blocks-core/package.json, packages/wonder-blocks-data/package.json, packages/wonder-blocks-dropdown/package.json, packages/wonder-blocks-form/package.json, packages/wonder-blocks-grid/package.json, packages/wonder-blocks-icon/package.json, packages/wonder-blocks-icon-button/package.json, packages/wonder-blocks-labeled-field/package.json, packages/wonder-blocks-layout/package.json, packages/wonder-blocks-link/package.json, packages/wonder-blocks-modal/package.json, packages/wonder-blocks-pill/package.json, packages/wonder-blocks-popover/package.json, packages/wonder-blocks-progress-spinner/package.json, packages/wonder-blocks-search-field/package.json, packages/wonder-blocks-switch/package.json, packages/wonder-blocks-testing/package.json, packages/wonder-blocks-testing-core/package.json, packages/wonder-blocks-theming/package.json, packages/wonder-blocks-timing/package.json, packages/wonder-blocks-tokens/package.json, packages/wonder-blocks-toolbar/package.json, packages/wonder-blocks-tooltip/package.json, packages/wonder-blocks-typography/package.json, utils/publish/package-pre-publish-check.sh, utils/publish/pre-publish-check-ci.ts, utils/publish/pre-publish-utils.ts, utils/publish/publish-snapshot.sh

Don't want to be involved in this pull request? Comment #removeme and we won't notify you of further changes.

Copy link
Contributor

github-actions bot commented Dec 20, 2024

Size Change: 0 B

Total Size: 96.3 kB

ℹ️ View Unchanged
Filename Size
packages/wonder-blocks-accordion/dist/es/index.js 3.77 kB
packages/wonder-blocks-banner/dist/es/index.js 1.53 kB
packages/wonder-blocks-birthday-picker/dist/es/index.js 1.77 kB
packages/wonder-blocks-breadcrumbs/dist/es/index.js 887 B
packages/wonder-blocks-button/dist/es/index.js 4.04 kB
packages/wonder-blocks-cell/dist/es/index.js 2.01 kB
packages/wonder-blocks-clickable/dist/es/index.js 3.06 kB
packages/wonder-blocks-core/dist/es/index.js 2.88 kB
packages/wonder-blocks-data/dist/es/index.js 6.24 kB
packages/wonder-blocks-dropdown/dist/es/index.js 19.1 kB
packages/wonder-blocks-form/dist/es/index.js 6.2 kB
packages/wonder-blocks-grid/dist/es/index.js 1.36 kB
packages/wonder-blocks-icon-button/dist/es/index.js 2.95 kB
packages/wonder-blocks-icon/dist/es/index.js 871 B
packages/wonder-blocks-labeled-field/dist/es/index.js 72 B
packages/wonder-blocks-layout/dist/es/index.js 1.82 kB
packages/wonder-blocks-link/dist/es/index.js 2.28 kB
packages/wonder-blocks-modal/dist/es/index.js 5.42 kB
packages/wonder-blocks-pill/dist/es/index.js 1.65 kB
packages/wonder-blocks-popover/dist/es/index.js 4.85 kB
packages/wonder-blocks-progress-spinner/dist/es/index.js 1.52 kB
packages/wonder-blocks-search-field/dist/es/index.js 1.36 kB
packages/wonder-blocks-switch/dist/es/index.js 1.92 kB
packages/wonder-blocks-testing-core/dist/es/index.js 3.74 kB
packages/wonder-blocks-testing/dist/es/index.js 1.07 kB
packages/wonder-blocks-theming/dist/es/index.js 693 B
packages/wonder-blocks-timing/dist/es/index.js 1.8 kB
packages/wonder-blocks-tokens/dist/es/index.js 2.36 kB
packages/wonder-blocks-toolbar/dist/es/index.js 905 B
packages/wonder-blocks-tooltip/dist/es/index.js 6.99 kB
packages/wonder-blocks-typography/dist/es/index.js 1.23 kB

compressed-size-action

Copy link
Contributor

github-actions bot commented Dec 20, 2024

A new build was pushed to Chromatic! 🚀

https://5e1bf4b385e3fb0020b7073c-lvssletngb.chromatic.com/

Chromatic results:

Metric Total
Captured snapshots 372
Tests with visual changes 0
Total stories 507
Inherited (not captured) snapshots [TurboSnap] 0
Tests on the build 372

Copy link
Contributor

github-actions bot commented Dec 20, 2024

npm Snapshot: Published

🎉 Good news!! We've packaged up the latest commit from this PR (275c143) and published all packages with changesets to npm.

You can install the packages in webapp by running:

./services/static/dev/tools/deploy_wonder_blocks.js --tag="PR2412"

Packages can also be installed manually by running:

yarn add @khanacademy/wonder-blocks-<package-name>@PR2412

@somewhatabstract
Copy link
Member Author

The changeset error is too sensitive. These changes don't need releasing.

Copy link
Member Author

Choose a reason for hiding this comment

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

note: This isn't a big a change as it's making out.

Copy link
Member Author

Choose a reason for hiding this comment

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

note: This isn't as big a change as it's making out.

Comment on lines +22 to +23
// Get the root folder; use the LICENSE file as our root anchor.
const rootDir = ancesdir(__dirname, "LICENSE");
Copy link
Member Author

Choose a reason for hiding this comment

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

note: Other than making it so all checks are run before exiting (this is copied from Perseus and tested), this is the biggest change that isn't in Perseus - using ancesdir to locate the root directory rather than hard-coding it. This way it'll work if the file gets moved around.

Copy link
Member

@jandrade jandrade left a comment

Choose a reason for hiding this comment

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

Looks good! 🚀

@somewhatabstract somewhatabstract merged commit 11a0f5c into main Dec 20, 2024
14 checks passed
@somewhatabstract somewhatabstract deleted the fei6062.releaseprotections.1 branch December 20, 2024 22:12
Copy link

codecov bot commented Dec 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 0.00%. Comparing base (53b4197) to head (cdd7188).
Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@     Coverage Diff      @@
##   main   #2412   +/-   ##
============================
============================

Continue to review full report in Codecov by Sentry.

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

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.

3 participants