Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
83229b3
initial commit with using npm module
ltfschoen May 13, 2023
79cdecc
update readme
ltfschoen May 13, 2023
b9473f3
cargo fmt
ltfschoen May 13, 2023
8c7f4d8
tests: try to add wasm bindgen tests
ltfschoen May 14, 2023
366fcf8
Update examples/npm_lib/src/main.rs
ltfschoen May 31, 2023
1ae9e2d
Update examples/npm_lib/tests/wasm.rs
ltfschoen May 31, 2023
12c5db2
remove useless onclick_pjs_process_async
ltfschoen May 31, 2023
a5b446f
replace macro with gloo_console
ltfschoen May 31, 2023
9d1ef0e
updates
ltfschoen Mar 10, 2025
846ae43
revert changes to Cargo.lock in project root
ltfschoen Mar 10, 2025
bc715ed
wip
ltfschoen Mar 10, 2025
10c9f19
fix tests
ltfschoen Mar 10, 2025
c983c9c
update ci
ltfschoen Mar 10, 2025
431dc7d
update ci into shell script
ltfschoen Mar 10, 2025
50a7bea
merge latest master
ltfschoen Mar 10, 2025
29b1220
fix ci npm_lib
ltfschoen Mar 10, 2025
4a6d393
remove version causing ci issue
ltfschoen Mar 10, 2025
7956419
update ci with rustup target add wasm32-unknown-unknown
ltfschoen Mar 10, 2025
35124ae
try using miri ci npm_lib
ltfschoen Mar 10, 2025
afd192c
only nightly ci npm_lib
ltfschoen Mar 10, 2025
b756220
ci esbuild
ltfschoen Mar 10, 2025
9eb7c61
use rust not miri
ltfschoen Mar 10, 2025
1a958d2
dot instead of source
ltfschoen Mar 10, 2025
ce1ded6
fix component syntax
ltfschoen Mar 10, 2025
18448b8
fix trunk dir
ltfschoen Mar 10, 2025
5d91d75
ci check fmt
ltfschoen Mar 10, 2025
59dc770
wip
ltfschoen Mar 10, 2025
99a3046
wip
ltfschoen Mar 10, 2025
30bf872
wip
ltfschoen Mar 11, 2025
6e57d2f
wip
ltfschoen Mar 11, 2025
e3826bb
wip
ltfschoen Mar 11, 2025
877590b
add rustup component fmt
ltfschoen Mar 11, 2025
54140a0
temp - add failing test
ltfschoen Mar 11, 2025
4a25e4e
wip
ltfschoen Mar 11, 2025
27bd304
fix cargo fmt. add test error to check fails
ltfschoen Mar 11, 2025
51f82e6
wip
ltfschoen Mar 11, 2025
e7d59c5
try with test passing
ltfschoen Mar 11, 2025
60eda86
wip
ltfschoen Mar 11, 2025
046d6ca
temp only run checkfmt but gets stuck at yzdata
ltfschoen Mar 13, 2025
5a15af6
refactor
ltfschoen Mar 13, 2025
571ae0b
wip
ltfschoen Mar 13, 2025
8aa10c1
should work now. restore tests
ltfschoen Mar 13, 2025
6593804
wip
ltfschoen Mar 14, 2025
547bcf3
fix permissions error
ltfschoen Mar 14, 2025
e398f2e
fix permissions error
ltfschoen Mar 14, 2025
b75ab08
move wasm-pack
ltfschoen Mar 14, 2025
b44e9bc
fix directory
ltfschoen Mar 14, 2025
522c58f
wip
ltfschoen Mar 14, 2025
624645c
fix fmt
ltfschoen Mar 15, 2025
ed671de
fix fmt
ltfschoen Mar 15, 2025
bffca1a
remove bin/act
ltfschoen Mar 15, 2025
71f6022
wip
ltfschoen Mar 15, 2025
0ede1c3
wip
ltfschoen Mar 15, 2025
bfb8a98
try make tests faster and sleep to avoid timeout
ltfschoen Mar 15, 2025
a43f3e8
wip
ltfschoen Mar 15, 2025
c5202ac
wip
ltfschoen Mar 15, 2025
7f4e0fc
fix typo
ltfschoen Mar 15, 2025
1b4929a
wip
ltfschoen Mar 15, 2025
ea691a6
wip
ltfschoen Mar 15, 2025
c256ebe
wip
ltfschoen Mar 15, 2025
363ad15
wip
ltfschoen Mar 15, 2025
5b22d20
temp wind back
ltfschoen Mar 15, 2025
81aa593
increase timeouts
ltfschoen Mar 15, 2025
24903cc
wip
ltfschoen Mar 15, 2025
3ebaae8
wip
ltfschoen Mar 15, 2025
892e0df
wip
ltfschoen Mar 15, 2025
61dfc33
wip
ltfschoen Mar 15, 2025
5c87af7
wip
ltfschoen Mar 16, 2025
b3050fe
wip
ltfschoen Mar 16, 2025
586e58a
wip
ltfschoen Mar 16, 2025
5c95095
wip
ltfschoen Mar 16, 2025
5b0d1e8
wip
ltfschoen Mar 16, 2025
4a57c9e
wip
ltfschoen Mar 16, 2025
5d8d5b8
wip
ltfschoen Mar 16, 2025
9e8d4ef
wip - try resolve invalid type: map, expected a string
ltfschoen Mar 16, 2025
83dcfc6
wip
ltfschoen Mar 16, 2025
4f9b783
wip
ltfschoen Mar 16, 2025
cb6f9bd
wip
ltfschoen Mar 16, 2025
4b18a83
wip
ltfschoen Mar 16, 2025
5269816
use cargo test instead of wrapped wasm-pack that not work
ltfschoen Mar 17, 2025
fac4ead
wip
ltfschoen Mar 17, 2025
e01d95f
wip - try wasmtime instead
ltfschoen Mar 17, 2025
df2d493
wip
ltfschoen Mar 17, 2025
e0d5383
wip
ltfschoen Mar 17, 2025
c3a5597
wip
ltfschoen Mar 17, 2025
8dfb971
wip
ltfschoen Mar 17, 2025
cbf0a25
wip - switch back to wasm-pack using wrapper as highest priority in PATH
ltfschoen Mar 17, 2025
b317684
wip
ltfschoen Mar 17, 2025
59d5f3e
wip
ltfschoen Mar 17, 2025
ecc0ee8
wip
ltfschoen Mar 17, 2025
48b9b58
wip
ltfschoen Mar 17, 2025
987cbc0
wip
ltfschoen Mar 17, 2025
425d4ab
wip
ltfschoen Mar 17, 2025
8b019c2
wip
ltfschoen Mar 17, 2025
ecdf7d3
wip
ltfschoen Mar 17, 2025
09e3f1a
wip
ltfschoen Mar 18, 2025
b4fa700
wip
ltfschoen Mar 18, 2025
2205e27
wip - try wasmtime instead again
ltfschoen Mar 18, 2025
5a5d150
wip
ltfschoen Mar 18, 2025
5021235
wip
ltfschoen Mar 18, 2025
bd401ca
wip
ltfschoen Mar 18, 2025
13afa42
wip
ltfschoen Mar 18, 2025
0bc4288
wip
ltfschoen Mar 18, 2025
c744d02
wip
ltfschoen Mar 18, 2025
1cbda84
wip
ltfschoen Mar 18, 2025
7a38dad
wip
ltfschoen Mar 18, 2025
e7b5ed8
wip
ltfschoen Mar 18, 2025
5bacce9
wip - switch back to wasm-pack
ltfschoen Mar 22, 2025
74477bd
wip - try wasm-pack solution
ltfschoen Mar 22, 2025
f62f388
wip
ltfschoen Mar 22, 2025
f2df417
wip
ltfschoen Mar 22, 2025
5baedee
wip
ltfschoen Mar 22, 2025
b2f4ea2
wip
ltfschoen Mar 22, 2025
59743c3
wip
ltfschoen Mar 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .actrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# --privileged
# --container-architecture=linux/amd64
# -P ubuntu-18.04=nektos/act-environments-ubuntu:18.04
113 changes: 113 additions & 0 deletions .github/actions/base-setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: Base Setup Action
description: Sets up the environment with Node.js and other dependencies

# inputs:
# github-token:
# description: 'GitHub token for Node.js setup'
# required: true

runs:
using: composite
steps:
- name: Install Act dependencies
if: ${{ env.ACT }}
shell: bash
run: |
apt-get update && apt-get install sudo -y

# - name: Setup Node.js
# uses: actions/setup-node@v4
# with:
# node-version: '22.x'
# registry-url: 'https://registry.npmjs.org'
# token: ${{ inputs.github-token }}

- name: Configure system
shell: bash
run: |
# Set noninteractive installation
export DEBIAN_FRONTEND=noninteractive
export TZ=Australia/Sydney

# Pre-configure tzdata to avoid prompts
sudo ln -fs /usr/share/zoneinfo/Australia/Sydney /etc/localtime
echo "Australia/Sydney" | sudo tee /etc/timezone

# Pre-accept tzdata license
echo 'tzdata tzdata/Areas select Australia' | sudo debconf-set-selections
echo 'tzdata tzdata/Zones/Australia select Sydney' | sudo debconf-set-selections

# Script to try to resolve error `invalid type: map, expected a string` when running `wasm-pack build`
# https://github.com/rustwasm/wasm-pack/issues/1420#issuecomment-2585397056
#
# This script approach is a workaround for the "invalid type: map, expected a string" error
# that can occur when running `wasm-pack build`, where the error typically happens due to
# race conditions when multiple wasm-pack processes try to access the same configuration
# files simultaneously.
#
# The script creates a mutex using flock on a lock file (wasm-pack-lock) in the XDG runtime directory,
# and then executes the actual wasm-pack binary from your Cargo installation. By placing this script
# earlier in the $PATH, any calls to wasm-pack will use the wrapper instead of the original binary.
#
# It effectively serializes all wasm-pack calls through the lock file, preventing the race condition
# that causes the map/string type error. The tradeoff is that concurrent builds will execute sequentially,
# which might impact performance in heavily parallelized build environments.
#
# The directory containing the script must appear before ~/.cargo/bin in $PATH, the order of which may be
# checked by running `echo $PATH`.

# sudo mkdir -p /var/tmp/wasm
# sudo mv ./.github/actions/wasm-pack-script/wasm-pack-script.sh /var/tmp/wasm/wasm-pack
# sudo chmod +x /var/tmp/wasm/wasm-pack

# Ensure that the highest priority part of the PATH variable is at the start, not the end.
# Note: It doesn't appear to work, but maybe because /usr/local/bin was already in PATH but not at the
# highest priority part, so we'll store it in its own folder and add that to the PATH
# echo 'export PATH="/var/tmp/wasm:$PATH"' >> $HOME/.profile
# source $HOME/.profile

# Add wasm-pack commad to GITHUB_ENV for subsequent steps
# Can't get this to work. `/etc/skel/.cargo/bin:` always seems to be before
# echo 'export PATH="/var/tmp/wasm:$PATH"' >> $GITHUB_ENV

# Can't get it to work. `/etc/skel/.cargo/bin:` always seems to be before
# echo "/var/tmp/wasm" > $GITHUB_PATH.new
# cat $GITHUB_PATH >> $GITHUB_PATH.new
# mv $GITHUB_PATH.new $GITHUB_PATH

# Install system dependencies
sudo apt-get update
sudo apt-get upgrade -y
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential pkg-config \
libssl-dev unzip curl wget ca-certificates gnupg dialog tzdata

# Install Node.js 22.x
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key \
| sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] \
https://deb.nodesource.com/node_22.x nodistro main" \
| sudo tee /etc/apt/sources.list.d/nodesource.list
sudo apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs

# Install global npm packages with proper permissions
sudo mkdir -p /usr/lib/node_modules
sudo chown -R $USER:$(id -gn) /usr/lib/node_modules
sudo npm install -g yarn

# Install rustup with retries
source ./.github/actions/retry-script/retry.sh
retry 10 curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sudo sh -s -- -y --profile minimal

# Add cargo to PATH and source rustup
source $HOME/.cargo/env

# Add cargo environment to GITHUB_ENV for subsequent steps
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
echo "CARGO_HOME=$HOME/.cargo" >> $GITHUB_ENV
echo "RUSTUP_HOME=$HOME/.rustup" >> $GITHUB_ENV

# Check order of $PATH
# echo "Check order of PATH"
# echo $PATH
28 changes: 28 additions & 0 deletions .github/actions/retry-script/retry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# Retry failed command multiple times with exponential backoff
function retry() {
local retries=$1
shift
local count=0
local wait=5
until "$@"; do
exit=$?
count=$((count + 1))
if [ $count -lt $retries ]; then
echo "Command failed with exit code $exit. Attempt $count/$retries."
echo "Retrying in $wait seconds..."
sleep $wait
# Exponential backoff with max of 60 seconds
wait=$((wait * 2))
[ $wait -gt 60 ] && wait=60
else
echo "Command failed after $retries attempts."
echo "Last exit code: $exit"
echo "Last error output:"
"$@" 2>&1
return $exit
fi
done
return 0
}
137 changes: 137 additions & 0 deletions .github/actions/rust-setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
name: Rust Setup Action
description: Sets up Rust toolchain with specified version and configures components

inputs:
toolchain:
description: 'Rust toolchain version to use'
required: true
# default: 'stable'
default: 1.81.0
targets:
description: 'Target architectures to install'
required: false
default: 'wasm32-unknown-unknown'

runs:
using: composite
steps:
- name: Configure rustup
shell: bash
run: |
# Source cargo environment
source $HOME/.cargo/env

# Verify rustup installation
if ! command -v rustup &> /dev/null; then
echo "Error: rustup not found. Please ensure base-setup completed successfully."
exit 1
fi

# Set minimal profile
rustup set profile minimal

# - name: Install Rust toolchain (stable)
# uses: dtolnay/rust-toolchain@master
# with:
# toolchain: stable
# targets: wasm32-unknown-unknown
# components: rustfmt

# - name: Install Rust toolchain (nightly)
# uses: dtolnay/rust-toolchain@master
# with:
# toolchain: nightly
# targets: wasm32-unknown-unknown
# components: rustfmt

# - name: Install Rust toolchain
# uses: dtolnay/[email protected]
# with:
# # toolchain: nightly
# targets: wasm32-unknown-unknown
# components: rustfmt

- name: Set default toolchain
shell: bash
run: |
source $HOME/.cargo/env
rustup install ${{ inputs.toolchain }}
rustup default ${{ inputs.toolchain }}
rustup target add ${{ inputs.targets }}
rustup component add rustfmt
rustup override set ${{ inputs.toolchain }}
rustc --version
rustup show

- name: Install nightly toolchain
shell: bash
run: |
source $HOME/.cargo/env
rustup toolchain install nightly
rustup target add wasm32-unknown-unknown --toolchain nightly
rustup component add rustfmt --toolchain nightly
cargo +nightly --version
rustup show

# - name: Cache cargo dependencies
# uses: actions/cache@v4
# with:
# path: |
# ~/.cargo/registry
# ~/.cargo/git
# target
# key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
# restore-keys: |
# ${{ runner.os }}-cargo-

- name: Configure WASM tools
shell: bash
run: |
# Source cargo environment and retry script
source $HOME/.cargo/env
source ./.github/actions/retry-script/retry.sh

sudo mkdir -p /var/tmp/wasm
cd /var/tmp/wasm
sudo chown -R $USER:$(id -gn) /var/tmp/wasm

# Download the specific branch as a zip file
retry 10 curl -L https://github.com/ZabelTech/wasm-pack/archive/refs/heads/correctly-parse-package_json.zip -o wasm-pack-custom.zip

# Extract and switch directory
chmod +x wasm-pack-custom.zip
unzip wasm-pack-custom.zip
cd wasm-pack-correctly-parse-package_json

# Build the binary (this will take a moment)
cargo build --release

# Move the binary to your local bin
sudo mv target/release/wasm-pack /usr/local/bin/

# Make it executable
sudo chmod +x /usr/local/bin/wasm-pack

# Clean up
cd ../
rm -rf wasm-pack-custom.zip wasm-pack-correctly-parse-package_json

# # Download and install pre-built wasm-pack binary
# retry 10 curl -L https://github.com/rustwasm/wasm-pack/releases/download/v0.12.1/wasm-pack-v0.12.1-x86_64-unknown-linux-musl.tar.gz | sudo tar -xz
# sudo mv wasm-pack-*/wasm-pack /usr/local/bin/
# sudo chmod +x /usr/local/bin/wasm-pack

echo "Installing wasm-bindgen-cli with retries"
# Note: The `--vers "0.2.100"` must match the version of `wasm-bindgen` in Cargo.toml file
retry 10 cargo install wasm-bindgen-cli --vers "0.2.100"

# Verify wasm-pack installation
if ! command -v wasm-pack &> /dev/null; then
echo "Error: wasm-pack installation failed"
exit 1
fi

echo "Verify tools are available from rust-setup"
wasm-pack --version
wasm-bindgen --version
rustup show
5 changes: 5 additions & 0 deletions .github/actions/wasm-pack-script/wasm-pack-script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

# Reference: https://github.com/rustwasm/wasm-pack/issues/1420
XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-"/run/user/$UID"}"
exec flock "$XDG_RUNTIME_DIR/wasm-pack-lock" "${CARGO_HOME:-"$HOME/.cargo"}/bin/wasm-pack" "$@"
Loading
Loading