diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index 1b95873..8dab91a 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -77,3 +77,54 @@ jobs: exit 1 fi fi + + wasm-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup Rust + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + target: wasm32-unknown-unknown + override: true + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: "22" + + - name: Install wasm-pack + run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh + + - name: Cache + uses: Swatinem/rust-cache@v2 + + - name: Build WASM + working-directory: pubky/pkg + run: | + npm install + npm run build + + - name: Run the testnet + working-directory: pubky/pkg + run: npm run testnet > testnet.log 2>&1 & + + - name: Wait for testnet homeserver + run: | + until nc -zv 127.0.0.1 6286; do + echo "Waiting for testnet homeserver to be ready..." + sleep 1 + done + + - name: Run Tests (only node-js) + working-directory: pubky/pkg + # runing only `test-nodjs` and not browser because of weird `exit` behavior + run: npm run test-nodejs + + - name: Show testnet logs if tests fail + working-directory: pubky/pkg + if: failure() + run: cat testnet.log diff --git a/pubky/pkg/package.json b/pubky/pkg/package.json index 6e035cb..4820b05 100644 --- a/pubky/pkg/package.json +++ b/pubky/pkg/package.json @@ -34,6 +34,7 @@ ], "devDependencies": { "browser-resolve": "^2.0.0", + "browserify": "^17.0.1", "esmify": "^2.1.1", "tape": "^5.8.1", "tape-run": "^11.0.0"