Skip to content

ci: add npm compatibility smoke test#282

Merged
sameerank merged 5 commits into
mainfrom
sameerank/add-npm-smoke-test
May 15, 2026
Merged

ci: add npm compatibility smoke test#282
sameerank merged 5 commits into
mainfrom
sameerank/add-npm-smoke-test

Conversation

@sameerank
Copy link
Copy Markdown
Contributor

@sameerank sameerank commented May 14, 2026

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:

  1. Packs each package using npm pack
  2. Validates no yarn-specific protocols (workspace:, patch:, portal:, link:) leak into tarballs
  3. Installs packages using npm (not yarn) to catch incompatibilities
  4. Verifies packages load correctly and exports are available

Note: 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

  1. Watch CI fail on the workspace:^ commit (second commit)
datadog-openfeature-node-server-1.2.1.tgz
    "@datadog/flagging-core": "workspace:^"
❌ Found yarn-specific protocol in packages/node-server
  1. After observing failure, a fix commit will be pushed
  2. Watch CI pass after the fix

Checklist

  • Updated Documentation
  • Tested locally
  • Tested on staging
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.

sameerank added 2 commits May 14, 2026 09:16
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.
@sameerank sameerank force-pushed the sameerank/add-npm-smoke-test branch from dab7b11 to 6c22671 Compare May 14, 2026 16:22
This reverts the intentional workspace:^ change to show that the smoke test
passes when packages use npm-compatible version specifiers.
@sameerank sameerank marked this pull request as ready for review May 14, 2026 16:31
@sameerank sameerank requested a review from a team as a code owner May 14, 2026 16:31
@sameerank sameerank requested review from greghuels and typotter and removed request for a team May 14, 2026 16:31
This ensures the smoke test runs when the workflow itself is modified,
not just when package files change.
@sameerank sameerank force-pushed the sameerank/add-npm-smoke-test branch from 9af71c8 to 76ccdda Compare May 14, 2026 16:45
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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

minor: a test install below will catch these issues, so I don't think we need a separate validation

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think there are benefits to both

  1. The grep check is quick, fails early, and displays a clear error message ("Found yarn-specific protocol")
  2. The npm install acts as a catch-all for other errors and returns a more generic EUNSUPPORTEDPROTOCOL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants