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

Prepare WASM bindings for release #1176

Merged
merged 8 commits into from
Oct 23, 2024
Merged

Prepare WASM bindings for release #1176

merged 8 commits into from
Oct 23, 2024

Conversation

rygine
Copy link
Collaborator

@rygine rygine commented Oct 23, 2024

Summary

  • Replaced NPM with Yarn
  • Updated node version
  • Added WASM bindings release workflow
  • Updated build process
  • Added initial CHANGELOG

Summary by CodeRabbit

  • New Features

    • Introduced a GitHub Actions workflow for automating the release process of WASM bindings.
    • Added a new configuration file for Yarn, enhancing package management settings.
    • Marked the initial release of the @xmtp/wasm-bindings package (version 0.0.1).
  • Updates

    • Updated Node.js version requirements to 20.15.0.
    • Changed package name and version in package.json.
  • Bug Fixes

    • Streamlined the package creation process by removing unnecessary file generation.

@rygine rygine requested review from a team as code owners October 23, 2024 16:24
Copy link
Contributor

coderabbitai bot commented Oct 23, 2024

Walkthrough

This pull request introduces significant changes to the bindings_wasm project, including a new GitHub Actions workflow for automating the release of WASM bindings. It updates various configuration files to support a newer version of Node.js and modifies the package structure. Additionally, it enhances the .gitignore file to better manage ignored files, streamlines the build process by removing unnecessary file creations, and documents the initial release in the changelog.

Changes

File Change Summary
.github/workflows/release-wasm-bindings.yml New workflow added for automating the release of WASM bindings.
bindings_wasm/.gitignore Added entries to ignore yarn directory, .yarn/, and dist directory while keeping certain subdirectories.
bindings_wasm/.node-version Updated Node.js version from 18.19.1 to 20.15.0.
bindings_wasm/.nvmrc Updated Node.js version from 18.19.1 to 20.15.0.
bindings_wasm/.yarnrc.yml Created new configuration file for Yarn with specific settings.
bindings_wasm/CHANGELOG.md Added new entry for initial release version 0.0.1 of @xmtp/wasm-bindings.
bindings_wasm/package.json Updated package name, version, main entry point, type definitions, Node engine requirement, and added package manager field.
xtask/src/build.rs Removed creation of package.json and .gitignore files during the build process.

Possibly related PRs

  • Skip wasm-opt if it errors during wasm build #1175: This PR modifies the build.rs file, which is related to the WASM build process, and includes enhancements for colored output in the terminal, similar to the new GitHub Actions workflow that sets the CARGO_TERM_COLOR environment variable for colored output.

Suggested reviewers

  • nplasterer

Poem

🐰 In the meadow, a change did bloom,
A workflow to banish the gloom.
With Yarn and Node, all set to play,
Our WASM bindings are here to stay!
Hopping along, we cheer with delight,
For a smoother release, all feels just right! 🌼


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between e9b23d1 and ad025b3.

📒 Files selected for processing (1)
  • bindings_wasm/.gitignore (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • bindings_wasm/.gitignore

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 854307a and e9b23d1.

⛔ Files ignored due to path filters (3)
  • bindings_wasm/.yarn/releases/yarn-4.5.1.cjs is excluded by !**/.yarn/**
  • bindings_wasm/package-lock.json is excluded by !**/package-lock.json
  • bindings_wasm/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (8)
  • .github/workflows/release-wasm-bindings.yml (1 hunks)
  • bindings_wasm/.gitignore (1 hunks)
  • bindings_wasm/.node-version (1 hunks)
  • bindings_wasm/.nvmrc (1 hunks)
  • bindings_wasm/.yarnrc.yml (1 hunks)
  • bindings_wasm/CHANGELOG.md (1 hunks)
  • bindings_wasm/package.json (3 hunks)
  • xtask/src/build.rs (0 hunks)
💤 Files with no reviewable changes (1)
  • xtask/src/build.rs
✅ Files skipped from review due to trivial changes (4)
  • bindings_wasm/.gitignore
  • bindings_wasm/.node-version
  • bindings_wasm/.nvmrc
  • bindings_wasm/.yarnrc.yml
🧰 Additional context used
🪛 actionlint
.github/workflows/release-wasm-bindings.yml

13-13: label "warp-ubuntu-latest-x64-16x" is unknown. available labels are "windows-latest", "windows-latest-8-cores", "windows-2022", "windows-2019", "ubuntu-latest", "ubuntu-latest-4-cores", "ubuntu-latest-8-cores", "ubuntu-latest-16-cores", "ubuntu-24.04", "ubuntu-22.04", "ubuntu-20.04", "macos-latest", "macos-latest-xl", "macos-latest-xlarge", "macos-latest-large", "macos-15-xlarge", "macos-15-large", "macos-15", "macos-14-xl", "macos-14-xlarge", "macos-14-large", "macos-14", "macos-14.0", "macos-13-xl", "macos-13-xlarge", "macos-13-large", "macos-13", "macos-13.0", "macos-12-xl", "macos-12-xlarge", "macos-12-large", "macos-12", "macos-12.0", "self-hosted", "x64", "arm", "arm64", "linux", "macos", "windows". if it is a custom label for self-hosted runner, set list of labels in actionlint.yaml config file

(runner-label)

🪛 LanguageTool
bindings_wasm/CHANGELOG.md

[uncategorized] ~5-~5: Dieses Wort müsste großgeschrieben werden. Überlegen Sie, es zu ändern.
Context: ... @xmtp/wasm-bindings ## 0.0.1 Initial release

(AI_DE_GGEC_REPLACEMENT_ORTHOGRAPHY_LOWERCASE)

🔇 Additional comments (6)
bindings_wasm/package.json (5)

26-30: Build script changes look good.

The build scripts have been properly updated to:

  • Use Yarn instead of npm
  • Clean up release artifacts
  • Ensure builds run before publishing

54-55: LGTM: Package manager specification.

The explicit packageManager field is a good practice that ensures consistent tooling across the project.


44-46: Breaking change: Node.js version requirement.

The minimum Node.js version has been increased to 20. This is a breaking change that should be prominently documented in the CHANGELOG.

#!/bin/bash
# Check if CHANGELOG mentions Node.js version update
echo "Checking CHANGELOG for Node.js version update..."
fd CHANGELOG --exec rg -i "node.*20|node.*version"

33-42: Verify the simplified dist structure.

The package structure has been simplified with all outputs going to the dist root. Please ensure this works correctly for all target environments.

#!/bin/bash
# Check the actual structure of the dist directory after build
echo "Checking if the build creates the expected structure..."
yarn build
ls -la dist/

2-3: Verify package name change impact.

The package has been renamed from @xmtp/client-bindings-wasm to @xmtp/wasm-bindings. This is a breaking change that will affect any existing dependencies.

✅ Verification successful

Let me try a different approach to verify the package name change impact by searching for any imports or references to either package name in the codebase.

This should help us understand if there are any existing dependencies or references to either package name in the codebase.


Based on the search results, I can now generate a final response:

Package name change appears safe to proceed

The package rename from @xmtp/client-bindings-wasm to @xmtp/wasm-bindings appears to be a safe change because:

  • The old package name @xmtp/client-bindings-wasm is not listed as a dependency in any other package.json files in the codebase
  • References to the package name only appear in files within the bindings_wasm directory itself (package.json, yarn.lock, and CHANGELOG.md)
  • This appears to be the first official release (v0.0.1) of the package, suggesting it hasn't been published or consumed by other packages yet
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any references to the old package name in the codebase
echo "Searching for old package name references..."
rg "@xmtp/client-bindings-wasm"

# Check if this package is a dependency in other package.json files
echo "Checking dependencies in other package.json files..."
fd package.json --exec jq -r '.dependencies | select(."@xmtp/client-bindings-wasm" != null)'
fd package.json --exec jq -r '.devDependencies | select(."@xmtp/client-bindings-wasm" != null)'

Length of output: 368


Script:

#!/bin/bash
# Search for any references to either package name in the codebase
echo "Searching for package name references..."
rg -l "@xmtp/(client-bindings-wasm|wasm-bindings)"

# Look for package.json files and check their content
echo "Checking package.json files..."
fd package.json --type f --exec cat {}

Length of output: 3246

.github/workflows/release-wasm-bindings.yml (1)

13-13: Verify custom runner label.

The runner label warp-ubuntu-latest-x64-16x is not a standard GitHub-hosted runner label.

If this is a custom self-hosted runner, please document this requirement. Otherwise, consider using a standard GitHub-hosted runner like ubuntu-latest.

🧰 Tools
🪛 actionlint

13-13: label "warp-ubuntu-latest-x64-16x" is unknown. available labels are "windows-latest", "windows-latest-8-cores", "windows-2022", "windows-2019", "ubuntu-latest", "ubuntu-latest-4-cores", "ubuntu-latest-8-cores", "ubuntu-latest-16-cores", "ubuntu-24.04", "ubuntu-22.04", "ubuntu-20.04", "macos-latest", "macos-latest-xl", "macos-latest-xlarge", "macos-latest-large", "macos-15-xlarge", "macos-15-large", "macos-15", "macos-14-xl", "macos-14-xlarge", "macos-14-large", "macos-14", "macos-14.0", "macos-13-xl", "macos-13-xlarge", "macos-13-large", "macos-13", "macos-13.0", "macos-12-xl", "macos-12-xlarge", "macos-12-large", "macos-12", "macos-12.0", "self-hosted", "x64", "arm", "arm64", "linux", "macos", "windows". if it is a custom label for self-hosted runner, set list of labels in actionlint.yaml config file

(runner-label)

Comment on lines +29 to +37
- name: Setup node
uses: actions/setup-node@v4
with:
node-version-file: ".node-version"
cache-dependency-path: "bindings_wasm/yarn.lock"
cache: "yarn"
env:
SKIP_YARN_COREPACK_CHECK: "1"

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add NPM registry configuration for publishing.

The Node.js setup should include registry configuration for publishing:

       - name: Setup node
         uses: actions/setup-node@v4
         with:
           node-version-file: ".node-version"
           cache-dependency-path: "bindings_wasm/yarn.lock"
           cache: "yarn"
+          registry-url: 'https://registry.npmjs.org'
         env:
           SKIP_YARN_COREPACK_CHECK: "1"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Setup node
uses: actions/setup-node@v4
with:
node-version-file: ".node-version"
cache-dependency-path: "bindings_wasm/yarn.lock"
cache: "yarn"
env:
SKIP_YARN_COREPACK_CHECK: "1"
- name: Setup node
uses: actions/setup-node@v4
with:
node-version-file: ".node-version"
cache-dependency-path: "bindings_wasm/yarn.lock"
cache: "yarn"
registry-url: 'https://registry.npmjs.org'
env:
SKIP_YARN_COREPACK_CHECK: "1"

Comment on lines +10 to +13
release:
permissions:
id-token: write
runs-on: warp-ubuntu-latest-x64-16x
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Update permissions for NPM publishing.

The current permissions block might be insufficient for NPM publishing. Consider adding necessary permissions:

   permissions:
     id-token: write
+    contents: read
+    packages: write
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
release:
permissions:
id-token: write
runs-on: warp-ubuntu-latest-x64-16x
release:
permissions:
id-token: write
contents: read
packages: write
runs-on: warp-ubuntu-latest-x64-16x
🧰 Tools
🪛 actionlint

13-13: label "warp-ubuntu-latest-x64-16x" is unknown. available labels are "windows-latest", "windows-latest-8-cores", "windows-2022", "windows-2019", "ubuntu-latest", "ubuntu-latest-4-cores", "ubuntu-latest-8-cores", "ubuntu-latest-16-cores", "ubuntu-24.04", "ubuntu-22.04", "ubuntu-20.04", "macos-latest", "macos-latest-xl", "macos-latest-xlarge", "macos-latest-large", "macos-15-xlarge", "macos-15-large", "macos-15", "macos-14-xl", "macos-14-xlarge", "macos-14-large", "macos-14", "macos-14.0", "macos-13-xl", "macos-13-xlarge", "macos-13-large", "macos-13", "macos-13.0", "macos-12-xl", "macos-12-xlarge", "macos-12-large", "macos-12", "macos-12.0", "self-hosted", "x64", "arm", "arm64", "linux", "macos", "windows". if it is a custom label for self-hosted runner, set list of labels in actionlint.yaml config file

(runner-label)

Comment on lines +3 to +8
on:
workflow_dispatch:

env:
CARGO_TERM_COLOR: always

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add version control parameters to the workflow trigger.

Consider adding input parameters to control the release version and ensure intentional releases:

 on:
   workflow_dispatch:
+    inputs:
+      version:
+        description: 'Version to release (e.g., 1.0.0)'
+        required: true
+      dry_run:
+        description: 'Perform a dry run without publishing'
+        type: boolean
+        default: false
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
on:
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
on:
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 1.0.0)'
required: true
dry_run:
description: 'Perform a dry run without publishing'
type: boolean
default: false
env:
CARGO_TERM_COLOR: always

Comment on lines +22 to +28
- name: Cache
uses: Swatinem/rust-cache@v2
with:
workspaces: |
.
bindings_wasm

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Optimize Rust caching configuration.

The current cache configuration could be more specific:

       - name: Cache
         uses: Swatinem/rust-cache@v2
         with:
           workspaces: |
-            .
-            bindings_wasm
+            bindings_wasm:target
           shared-key: "wasm-bindings"
+          cache-directories: |
+            bindings_wasm/node_modules

Committable suggestion was skipped due to low confidence.

Comment on lines +46 to +49
- name: Build
working-directory: bindings_wasm
run: yarn build

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add build validation step.

Consider adding validation after the build step to ensure the output is correct:

       - name: Build
         working-directory: bindings_wasm
         run: yarn build
+
+      - name: Validate build output
+        working-directory: bindings_wasm
+        run: |
+          if [ ! -f "dist/index.js" ] || [ ! -f "dist/index.d.ts" ]; then
+            echo "Error: Build output files are missing"
+            exit 1
+          fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Build
working-directory: bindings_wasm
run: yarn build
- name: Build
working-directory: bindings_wasm
run: yarn build
- name: Validate build output
working-directory: bindings_wasm
run: |
if [ ! -f "dist/index.js" ] || [ ! -f "dist/index.d.ts" ]; then
echo "Error: Build output files are missing"
exit 1
fi

Comment on lines +50 to +56
- name: Publish to NPM
uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_TOKEN }}
package: bindings_wasm
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance the publishing step with validation and documentation.

The publishing step could be improved with additional checks and documentation:

       - name: Publish to NPM
         uses: JS-DevTools/npm-publish@v3
         with:
           token: ${{ secrets.NPM_TOKEN }}
           package: bindings_wasm
+          dry-run: ${{ inputs.dry_run }}
+          check-version: true
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
+      - name: Create GitHub Release
+        if: ${{ !inputs.dry_run }}
+        uses: actions/create-release@v1
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        with:
+          tag_name: wasm-v${{ inputs.version }}
+          release_name: WASM Bindings v${{ inputs.version }}
+          body_path: bindings_wasm/CHANGELOG.md
+          draft: false

Committable suggestion was skipped due to low confidence.

@rygine rygine merged commit 9331eb7 into main Oct 23, 2024
4 checks passed
@rygine rygine deleted the rygine/wasm-update branch October 23, 2024 16:57
This was referenced Oct 24, 2024
insipx pushed a commit that referenced this pull request Oct 29, 2024
* Update node version

* Update .gitignore

* Use yarn instead of NPM

* Add WASM bindings release workflow

* Update build process

* Update build command

* Add CHANGELOG

* Add empty line to
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