huggingface / ratchet

A cross-platform browser ML framework.
https://ratchet.sh
MIT License
631 stars 33 forks source link

chore: add pkg.pr.new publish workflow #237

Closed ocavue closed 4 months ago

ocavue commented 4 months ago

This PR includes multiple improvements for the CI workflow:

  1. Add a root package.json, which specifies the version of Node.js package manager pnpm and wasm-pack. It's a good idea to explicitly declare the dependencies and their versions (see 12-factors for explanation).

    Notice that I didn't use the latest version of pnpm and wasm-pack, which were released very recently. I assume that this project is using an older version of these two dependencies during development. We can update the version in a separate PR.

  2. In justfile, use the local wasm-pack binary under node_modules/.bin, instead of the global binary in PATH. This ensures that we can use different versions of wasm-pack in different projects without affecting others.

  3. Add a new job build in .github/workflows/rust.yml. This rust.yml now has two jobs: check and build. Although the check job is failing in the master branch, I can make build work. I extracted the common part of the two jobs (i.e., installing dependencies) into .github/actions/setup/action.yml so that we can reuse them in both jobs without copy-and-paste.

  4. In the job build, I use pkg.pr.new to publish ratchet-web for every pushed Git commit. In every pull request, you can see a bot commit like this one to show an npm install command that can install the built version of this package. pkg.pr.new is for a faster development feedback loop, and it doesn't actually publish packages to the NPM registry. I will address the NPM registry publishing in a different pull request.

    [!NOTE]
    To make pkg.pr.new work, you would need to install this GitHub App to the repo https://github.com/huggingface/ratchet. I'm not sure whether you have permission to do that under the huggingface org. If you don't have the permission, we can just comment out this part in .github/workflows/rust.yml and use some other methods.

  5. Finally, I've updated CONTRIBUTING.md to include some changes about pnpm introduced in this PR, as well as to fix some incorrect Markdown heading levels.

github-actions[bot] commented 4 months ago
Code Metrics Report
  ===============================================================================
 Language            Files        Lines         Code     Comments       Blanks
===============================================================================
 TOML                    1           77           65            2           10
-------------------------------------------------------------------------------
 Rust                   66        14563        12457          200         1906
 |- Markdown            35          343            0          272           71
 (Total)                          14906        12457          472         1977
===============================================================================
 Total                  67        14640        12522          202         1916
===============================================================================

  
FL33TW00D commented 4 months ago

This is excellent - thank you!