ci: add npm compatibility smoke test#282
Merged
Merged
Conversation
Adds a smoke test that validates packages are compatible with npm before merge. The test: 1. Packs each package and validates no yarn-specific protocols leak into tarballs 2. Installs packages using npm (not yarn) to catch incompatibilities 3. Verifies packages load correctly and exports are available Triggers on PRs that modify: - packages/*/package.json - yarn.lock - lerna.json
This commit introduces a yarn workspace protocol that will fail the smoke test. This demonstrates that the smoke test correctly catches npm-incompatible syntax. This commit will be reverted in the next commit.
dab7b11 to
6c22671
Compare
This reverts the intentional workspace:^ change to show that the smoke test passes when packages use npm-compatible version specifiers.
This ensures the smoke test runs when the workflow itself is modified, not just when package files change.
9af71c8 to
76ccdda
Compare
dd-oleksii
approved these changes
May 15, 2026
Comment on lines
+41
to
+56
| # Extract and inspect the tarball (use package name for deterministic match) | ||
| PKG_NAME=$(node -p "require('./package.json').name.replace('@datadog/', 'datadog-')") | ||
| PKG_VERSION=$(node -p "require('./package.json').version") | ||
| TARBALL="/tmp/tarballs/${PKG_NAME}-${PKG_VERSION}.tgz" | ||
| tar -xzf "$TARBALL" -C /tmp | ||
|
|
||
| # Check for any yarn-specific protocols in the packed package.json | ||
| if grep -E '"(workspace|patch|portal|link):' /tmp/package/package.json; then | ||
| echo "❌ Found yarn-specific protocol in $pkg_dir" | ||
| cat /tmp/package/package.json | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "✅ No yarn-specific protocols in $pkg_dir" | ||
| rm -rf /tmp/package | ||
| cd - > /dev/null |
Member
There was a problem hiding this comment.
minor: a test install below will catch these issues, so I don't think we need a separate validation
Contributor
Author
There was a problem hiding this comment.
I think there are benefits to both
- The grep check is quick, fails early, and displays a clear error message ("Found yarn-specific protocol")
- The
npm installacts as a catch-all for other errors and returns a more genericEUNSUPPORTEDPROTOCOL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Prevent yarn-specific syntax (like
workspace:^) from leaking into published npm packages. This would have caught issues where npm users couldn't install packages due to unsupported protocols.Changes
Adds a smoke test workflow (
.github/workflows/smoke-test.yaml) that:npm packworkspace:,patch:,portal:,link:) leak into tarballsNote: This PR intentionally includes a commit that introduces
workspace:^to demonstrate that the smoke test catches the issue. The CI will fail on the second commit, proving the test works.Test instructions
workspace:^commit (second commit)Checklist