From 3407a90756a0649304ca8119e629236eb5333ffb Mon Sep 17 00:00:00 2001 From: SHAcollision <127778313+SHAcollision@users.noreply.github.com> Date: Fri, 28 Feb 2025 18:57:10 -0400 Subject: [PATCH] chore(tests): add wasm tests to CI (#83) * ci: add WASM testing workflow to GitHub Actions * ci: enhance WASM testing workflow with testnet startup and cleanup * ci: enhance testnet setup and testing workflow with improved logging and connectivity checks * trying something different * fix: skip testing browser --------- Co-authored-by: Miguel Medeiros --- .github/workflows/pr-check.yml | 51 ++++++++++++++++++++++++++++++++++ pubky/pkg/package.json | 1 + 2 files changed, 52 insertions(+) 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"