Skip to content

Created Github Action workflow for npm publishing for SearchClient#49

Merged
naveensky merged 8 commits intomainfrom
SQ-7306
Nov 28, 2025
Merged

Created Github Action workflow for npm publishing for SearchClient#49
naveensky merged 8 commits intomainfrom
SQ-7306

Conversation

@raghavbitqit
Copy link
Collaborator

No description provided.

@sparq-ai sparq-ai deleted a comment from claude bot Nov 27, 2025
@sparq-ai sparq-ai deleted a comment from claude bot Nov 27, 2025
@sparq-ai sparq-ai deleted a comment from claude bot Nov 28, 2025
@claude
Copy link

claude bot commented Nov 28, 2025

Pull Request Review: NPM Publishing Workflow

Thank you for implementing the automated NPM publishing workflow! This is a valuable addition to the repository.

Strengths

  1. Smart Version Detection - The workflow includes a version check that prevents duplicate publishes
  2. Proper Testing - Running tests before publishing ensures quality control
  3. Good Documentation - The updated DEPLOY.md clearly explains the process
  4. Consistent Branding - README updates properly reflect the Sparq rebrand

Critical Issues

1. Overly Broad Trigger
The workflow triggers on EVERY push to main, not just version bumps. This wastes CI minutes and risks accidental publishes.

Recommendation: Add a paths filter to only run when package.json changes, or use version tags.

2. Missing Build Verification
The workflow builds but doesn't verify that required files exist before publishing.

Recommendation: Add a step to verify lib/index.min.js and lib/SearchClient.d.ts exist after build.

3. README Badge URLs
Lines 3-4 still point to old searchtap org URLs - update to sparq-ai or remove.

Security Concerns

  • Token documentation should specify using Automation type token with limited scope
  • Consider adding --provenance flag to publish command for supply chain security
  • Add dry-run validation before actual publish

Code Quality Suggestions

  • Use GitHub Actions annotations (::warning::, ::notice::) for better visibility
  • Document Node version requirement in package.json engines field
  • Add troubleshooting section to DEPLOY.md

Summary

Must Fix:

  • Refine workflow trigger (use paths filter or tags)
  • Add build output verification
  • Update README badge URLs

Should Fix:

  • Add dry-run validation step
  • Add package provenance flag
  • Improve error messaging with annotations

Overall: Approve with changes requested. The workflow will function but needs refinement for production use.

- Add OIDC permissions for npm provenance
- Upgrade Node.js from 18 to 20
- Add npm update step for latest npm version
- Use npm ci instead of npm install
- Enable --provenance flag for supply chain security

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@claude
Copy link

claude bot commented Nov 28, 2025

Pull Request Review: GitHub Actions Workflow for NPM Publishing

Overview

This PR introduces automated NPM publishing via GitHub Actions, along with rebranding from @searchtap to @sparq. Overall, this is a solid implementation with good practices. Below are my findings:


Strengths

  1. Smart Version Check: The workflow includes a version check before publishing to prevent duplicate publishes - this is excellent practice
  2. NPM Provenance: Uses --provenance flag which adds supply chain security transparency
  3. Modern Actions: Uses up-to-date action versions (@v4 for checkout and setup-node)
  4. CI/CD Best Practices: Runs tests and build before publishing
  5. Access Control: Properly uses --access=public for scoped packages
  6. Documentation: Updated DEPLOY.md with clear instructions

Code Quality and Best Practices

Good:

  • Uses npm ci instead of npm install for consistent, clean installations
  • Proper permissions scope (least privilege)
  • Clear step names and logical workflow structure

Concerns:

  1. CRITICAL - Workflow Trigger Risk (.github/workflows/npm-publish.yml:3-5)

    • Issue: The workflow triggers on EVERY push to main, but the package version in this PR is already 2.0.5
    • Risk: If this PR merges, it will immediately attempt to publish. If version 2.0.5 already exists on npm, it will skip (safe), but if it does not exist, it will publish potentially untested code
    • Recommendation: Consider adding a tag-based trigger instead to allow controlled releases via git tags rather than automatic publishing on every merge
  2. Node Version Update (.github/workflows/npm-publish.yml:23)

    • Uses Node 20, but package.json does not specify engine requirements
    • Recommendation: Add engines field to package.json specifying node >= 20.0.0
  3. Redundant npm Update (.github/workflows/npm-publish.yml:26-27)

    • The step npm install -g npm@latest may be unnecessary as setup-node@v4 typically includes a recent npm version
    • This could introduce variability between environments

Potential Issues

  1. Missing NPM_TOKEN Secret - The workflow will fail if the NPM_TOKEN secret is not configured in the repository. Ensure this is set up before merging.

  2. Test Command Compatibility (.github/workflows/npm-publish.yml:32-33)

    • The test command uses legacy OpenSSL provider flags in package.json (line 14)
    • This might cause issues depending on the Node version
    • The tests use nock mocking, which should work in CI, but verify this runs successfully
  3. Build Command Compatibility (.github/workflows/npm-publish.yml:35-36)

    • Uses NODE_OPTIONS=--openssl-legacy-provider which suggests OpenSSL compatibility issues
    • With Node 20, this flag may not be necessary or could cause problems
    • Action: Test the build with Node 20 locally to verify compatibility

Security Concerns

Good Security Practices:

  • Uses OIDC token (id-token: write) for provenance
  • Minimal permissions granted
  • Secrets properly referenced

Supply Chain Consideration:

  • Publishing happens automatically on merge to main
  • No manual approval step or separate staging environment
  • Consider adding a workflow_dispatch trigger for manual control

Performance Considerations

  • Workflow is well-optimized with necessary steps only
  • npm ci provides faster, more reliable installations than npm install
  • No unnecessary dependencies or steps

Test Coverage

Current State:

  • PR includes no new tests (workflow itself is not tested)
  • Existing tests in tests/SearchClient.spec.ts cover core functionality
  • Tests use mocking (nock) which is appropriate

Concerns:

  1. No workflow validation - Consider adding a test workflow run before enabling auto-publish
  2. Test compatibility - The existing tests should be verified to work with the CI environment (especially with Node 20)

Recommendation:

  • Add a separate CI workflow that runs on PRs to catch issues before merge

Additional Observations

  1. Package Rename (package.json:2)

    • Changing from @searchtap/search-client to @sparq/search-client is a significant breaking change
    • Users on the old package will not automatically get updates
    • Consider publishing a final version of @searchtap/search-client with a deprecation notice
  2. Version Bump (package.json:3)

    • Version changed from 2.0.0 to 2.0.5
    • Skipping versions (2.0.1-2.0.4) is unusual
    • Verify this is intentional
  3. README Updates

    • Good: All references updated from searchtap to sparq
    • Minor: Some badges may need updating (travis-ci, codacy) to reflect new repository name

Recommendations Summary

Before Merging:

  1. Verify NPM_TOKEN secret is configured
  2. Test build and tests with Node 20 locally
  3. Consider changing trigger to tag-based instead of push to main
  4. Add engines field to package.json

Consider for Follow-up:

  1. Add a separate CI workflow for PR validation
  2. Deprecate old @searchtap/search-client package
  3. Add workflow_dispatch for manual publish control
  4. Update CI badges in README

Overall Assessment: Approve with recommendations

This is a well-structured workflow that follows modern best practices. The main concern is the automatic publishing on every main branch push, which could be risky. Consider the tag-based trigger suggestion for more controlled releases.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@naveensky naveensky merged commit 7f1aebd into main Nov 28, 2025
1 check passed
@naveensky naveensky deleted the SQ-7306 branch November 28, 2025 07:17
@claude
Copy link

claude bot commented Nov 28, 2025

Code Review: PR #49 - NPM Publishing Workflow

Summary

This PR adds automated NPM publishing via GitHub Actions and updates branding from SearchTap to Sparq. Overall good implementation, but there are critical security issues that must be addressed before merging.


Critical Issues

1. Missing NPM_TOKEN in Workflow (.github/workflows/npm-publish.yml:55)

The workflow runs npm publish but does not configure the NPM_TOKEN. This will cause the publish step to fail.

Fix needed: Add env to the publish step:

- name: Publish to NPM
  if: steps.version-check.outputs.should_publish == 'true'
  run: npm publish --access=public --provenance
  env:
    NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

2. Triggers on Every Push to Main (.github/workflows/npm-publish.yml:4-5)

The workflow runs on every push to main, not just version changes. This could waste CI/CD resources and create confusion.

Recommendation: Consider using Git tags (on: push: tags: ['v*']) or workflow_dispatch for manual triggering.

3. npm@latest Auto-Update (.github/workflows/npm-publish.yml:26-27)

Installing npm@latest introduces unpredictable behavior and breaks reproducible builds.

Fix: Pin to a specific npm version: npm install -g npm@10.9.0

4. Outdated axios Dependency (package.json:22)

axios 0.18.0 from 2018 has known security vulnerabilities (CVE-2020-28168, CVE-2021-3749).

Fix: Update to latest version: npm install axios@latest


Positive Points

  • Good use of --provenance flag for supply chain security
  • Proper OIDC permissions configured (id-token: write)
  • Smart duplicate publish prevention with version check
  • CI runs tests and build before publishing
  • Comprehensive documentation in DEPLOY.md
  • Consistent branding updates across all files

Minor Improvements

5. Missing Error Handling

The version check script does not handle edge cases (malformed package.json, unreachable npm registry). Consider adding set -e and exit codes.

6. Documentation Gap (DEPLOY.md:19)

Instructions mention NPM_TOKEN but do not specify token type or permissions needed.

7. Version Bump Clarification (package.json:3)

Jumped from 2.0.0 to 2.0.5. Is this intentional? Were 2.0.1-2.0.4 published elsewhere?


Recommendations Summary

Before Merging (Critical):

  1. Add NODE_AUTH_TOKEN environment variable to publish step
  2. Update axios to latest version (security fix)
  3. Pin npm version instead of using @latest
  4. Verify NPM_TOKEN secret is configured in repository

Consider (Important):
5. Change trigger strategy (tags vs every push)
6. Clarify version bump rationale

Nice to Have:
7. Add error handling to version check script
8. Enhance DEPLOY.md with token type details


Great work on automating the deployment process! Once the critical issues are addressed, this will significantly improve the release workflow.

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.

2 participants