Repository navigation
devops: publish npm packages in dependency order and wait for them to go live - #43933
Conversation
… go live `npm publish` exiting 0 only means the registry accepted the package; it is processed asynchronously and may show up minutes later, or never. playwright-core@1.65.0 was accepted but never went live, while playwright@1.65.0 and the other packages that pin it were published and tagged @latest, so installs failed on the missing dependency. - List public packages in dependency order (playwright-core first). - Before publishing a package, wait until the workspace packages it depends on are available on the registry. - At the end, fail the job if any published package did not become available within 15 minutes.
| for package in ${PACKAGE_PATHS}; do | ||
| name=$(node -p "require('${package}/package.json').name") | ||
| # Never publish (and tag) a package until the workspace packages it depends on are installable. | ||
| for dep in $(node -p "Object.keys(require('${package}/package.json').dependencies || {}).join(' ')"); do |
There was a problem hiding this comment.
Why not just loop over packages and "publish + ensure" for each package, instead of checking the dependencies later on?
There was a problem hiding this comment.
Agreed, done. It's slower, since we now wait out each package's processing time one after another (55–188 s each in the 1.65.0 run), but much simpler.
| * Packages at the same depth keep their declaration order. | ||
| * @returns {PWPackage[]} | ||
| */ | ||
| publicPackagesInDependencyOrder() { |
There was a problem hiding this comment.
I think this could be done in ~5 lines 😄
There was a problem hiding this comment.
Done 🙂
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
d29ee76
into
microsoft:main
Test results for "MCP"5194 passed, 616 skipped Merge workflow run. |
Test results for "tests 1"Warning The triggering workflow run ended with status 1 flaky23522 passed, 705 skipped Merge workflow run. |
| this._packages.filter(p => p.name === dep).forEach(visit); | ||
| ordered.add(pkg); | ||
| }; | ||
| this._packages.forEach(visit); |
There was a problem hiding this comment.
This is just for me to understand (hope it's not annoying), but why not filter out private packages before visiting them all? I'm sure I'm missing something here :)
Anyway love Playwright -- Thank you
… and wait for them to go live
Summary
npm publishexiting 0 only means the registry accepted the package: it is processed asynchronously ("Your package is being processed and may take a few minutes to become available") and may show up minutes later, or never. In the 1.65.0 release run,playwright-core@1.65.0was accepted but never went live, whileplaywright,@playwright/testand the browser packages that pin it exactly were published and tagged@latest, so installs failed on the missing dependency. The workspace list also hadplaywrightbeforeplaywright-core.Changes
utils/workspace.js:--list-public-package-pathslists packages in dependency order (playwright-corefirst).utils/publish_all_packages.sh: after publishing each package, wait until it is available on the registry (npm view <name>@<version>, polled every 15s for up to 15 minutes) before publishing the next one; fail the job if it never shows up.With this, a package that never goes live fails the job before anything after it is published, so
@latestnever points at an uninstallable version. In the 1.65.0 run, packages took 55–188s to go live after being accepted, so runs get roughly 13 minutes slower.Testing
Ran the publish loop against a stubbed
npmthat reports packages as available only after a few polls:playwright-corenever available: onlyplaywright-corepublished, exit 1playwright-chromiumnever available: publishing stops after it, exit 1