peter-evans / rust-wasm-action

Rust-generated WebAssembly GitHub action template

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rust-generated WebAssembly GitHub action template

CI

A template to bootstrap the creation of a Rust-generated WebAssembly GitHub action.

About

This project is experimental. While it is very much feasible to write a GitHub action in Rust-generated WebAssembly, as this project demonstrates, there are some challenges compared to JavaScript/TypeScript.

The following is a summary of pain points I discovered, and some caveats when using the template.

  • It relies on raw bindings to the official actions toolkit NPM packages. Bindings for this template are defined in actions-toolkit-bindings but they are incomplete. I've only defined bindings that are in use by the template. It would be great to have a well maintained set of bindings published as a crate.

  • WebAssembly runs in a safe, sandboxed execution environment. As a result there is no access to files on disks, environment variables, etc. This means bindings to JavaScript functions are necessary for some functionality.

  • Panics cause the action to fail on exit but could be handled a little better. Perhaps we need a hook similar to the console_error_panic_hook that calls the binding for the setFailed function in @actions/core.

  • When dealing with string input you need to make decisions about whether to leave the string in JavaScript encoded as UTF-16 (js_sys::JsString), or to copy the string into Rust encoded as UTF-8. The later is lossy and in some cases could cause the string to be different in Rust than JavaScript. See the wasm-bindgen documentation here for further detail.

License

MIT

About

Rust-generated WebAssembly GitHub action template

License:MIT License


Languages

Language:Rust 100.0%