https://github.com/peter-evans/rust-wasm-action
Rust-generated WebAssembly GitHub action template
https://github.com/peter-evans/rust-wasm-action
Last synced: 10 months ago
JSON representation
Rust-generated WebAssembly GitHub action template
- Host: GitHub
- URL: https://github.com/peter-evans/rust-wasm-action
- Owner: peter-evans
- License: mit
- Created: 2020-08-10T06:31:06.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2025-03-24T02:35:00.000Z (about 1 year ago)
- Last Synced: 2025-08-08T11:16:05.999Z (10 months ago)
- Language: Rust
- Homepage:
- Size: 148 KB
- Stars: 22
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Rust-generated WebAssembly GitHub action template
[](https://github.com/peter-evans/rust-wasm-action/actions?query=workflow%3ACI)
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](https://github.com/actions/toolkit) NPM packages. Bindings for this template are defined in [actions-toolkit-bindings](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](https://github.com/rustwasm/console_error_panic_hook) that calls the binding for the [`setFailed`](https://github.com/actions/toolkit/blob/main/packages/core/src/core.ts#L103-L112) 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](https://rustwasm.github.io/wasm-bindgen/reference/types/str.html#utf-16-vs-utf-8) for further detail.
## License
[MIT](LICENSE)