Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
161 changes: 129 additions & 32 deletions .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@ on:
type: boolean
default: false

env:
RUST_TOOLCHAIN: nightly-2025-10-23
NODE_VERSION: 20
NPM_VERSION: 11.5.1
WASM_PACK_VERSION: 0.13.1
WASM_OPT_VERSION: 0.116.1

jobs:
run:
name: "Test"
build:
name: "Build"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
Expand All @@ -21,28 +27,27 @@ jobs:
- name: Install Rust
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
with:
toolchain: nightly-2025-10-23
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: rustfmt, clippy

- name: Cache Rust dependencies
uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
with:
workspaces: "packages/wasm-utxo"
workspaces: |
packages/wasm-utxo
packages/wasm-bip32
cache-on-failure: true

- name: Setup node 20
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20

- name: Ensure npm 11.5.1
run: |
npm install -g npm@11.5.1
node-version: ${{ env.NODE_VERSION }}

- name: Install wasm tools
- name: Install npm and wasm tools
run: |
rustup component add rustfmt
cargo install wasm-pack --version 0.13.1
cargo install wasm-opt --version 0.116.1
npm install -g npm@${{ env.NPM_VERSION }}
cargo install wasm-pack --version ${{ env.WASM_PACK_VERSION }}
cargo install wasm-opt --version ${{ env.WASM_OPT_VERSION }}
cargo install cargo-deny --locked

- name: Build Info
Expand All @@ -53,14 +58,10 @@ jobs:
echo "wasm-pack $(wasm-pack --version)"
echo "wasm-opt $(wasm-opt --version)"
echo "cargo-deny $(cargo deny --version)"
git --version
echo "base ref $GITHUB_BASE_REF"
echo "head ref $GITHUB_HEAD_REF"

- name: Fetch Base Ref
if: github.event_name == 'pull_request'
run: |
git fetch origin $GITHUB_BASE_REF
run: git fetch origin $GITHUB_BASE_REF

- name: Install Packages
run: npm ci --workspaces --include-workspace-root
Expand All @@ -69,32 +70,129 @@ jobs:
run: cargo deny check
working-directory: packages/wasm-utxo

- name: build packages
- name: Build packages
run: npm --workspaces run build

- name: Check Source Code Formatting
run: npm run check-fmt

- name: wasm-utxo / Lint
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-output
path: |
packages/wasm-utxo/dist/
packages/wasm-utxo/js/wasm/
packages/wasm-bip32/dist/
packages/wasm-bip32/js/wasm/
retention-days: 1

test:
name: "Test ${{ matrix.package }}"
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
package: [wasm-bip32, wasm-utxo]
include:
- package: wasm-utxo
needs-wasm-pack: true
has-wasm-pack-tests: true
- package: wasm-bip32
needs-wasm-pack: false
has-wasm-pack-tests: false
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}

- name: Install Rust
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: rustfmt, clippy

- name: Cache Rust dependencies
uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
with:
workspaces: packages/${{ matrix.package }}
cache-on-failure: true

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}

- name: Install npm
run: npm install -g npm@${{ env.NPM_VERSION }}

- name: Install wasm-pack
if: matrix.needs-wasm-pack
run: cargo install wasm-pack --version ${{ env.WASM_PACK_VERSION }}

- name: Install Packages
run: npm ci --workspaces --include-workspace-root

- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-output
path: packages/

- name: Lint
run: npm run lint
working-directory: packages/wasm-utxo
working-directory: packages/${{ matrix.package }}

- name: wasm-utxo / cargo test
- name: Cargo Test
run: cargo test --workspace
working-directory: packages/wasm-utxo
working-directory: packages/${{ matrix.package }}

- name: wasm-utxo / Wasm-Pack Test (Node)
- name: Wasm-Pack Test (Node)
if: matrix.has-wasm-pack-tests
run: npm run test:wasm-pack-node
working-directory: packages/wasm-utxo
working-directory: packages/${{ matrix.package }}

- name: wasm-utxo / Wasm-Pack Test (Chrome)
- name: Wasm-Pack Test (Chrome)
if: matrix.has-wasm-pack-tests
run: npm run test:wasm-pack-chrome
working-directory: packages/wasm-utxo
working-directory: packages/${{ matrix.package }}

- name: Unit Test
run: npm --workspaces test
run: npm test
working-directory: packages/${{ matrix.package }}

- name: Upload build artifacts
finalize:
name: "Finalize"
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}

- name: Install npm
run: npm install -g npm@${{ env.NPM_VERSION }}

- name: Install Packages
run: npm ci --workspaces --include-workspace-root

- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-output
path: packages/

- name: webui / Unit Test
run: npm test
working-directory: packages/webui

- name: Upload final build artifacts
if: inputs.upload-artifacts
uses: actions/upload-artifact@v4
with:
Expand All @@ -103,4 +201,3 @@ jobs:
packages/wasm-utxo/pkg/
packages/wasm-utxo/dist/
retention-days: 1

35 changes: 27 additions & 8 deletions .github/workflows/status-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,42 @@
# avoiding the multi-level name composition that occurs with reusable workflows.
# Configure branch protection rules to require "test / Test" as the status check.

name: "test / Test"
name: "test"

on:
workflow_run:
workflows: ["Build and Test"]
types:
- completed

permissions:
statuses: write

jobs:
status:
name: "Test"
runs-on: ubuntu-latest
steps:
- name: Check Build and Test Status
run: |
if [ "${{ github.event.workflow_run.conclusion }}" != "success" ]; then
echo "Build and Test workflow failed"
exit 1
fi
echo "Build and Test workflow succeeded"
- name: Set commit status
uses: actions/github-script@v7
with:
script: |
const { owner, repo } = context.repo;
const sha = context.payload.workflow_run.head_sha;
const conclusion = context.payload.workflow_run.conclusion;
const runUrl = context.payload.workflow_run.html_url;

const state = conclusion === 'success' ? 'success' :
conclusion === 'failure' ? 'failure' :
conclusion === 'cancelled' ? 'failure' : 'error';

await github.rest.repos.createCommitStatus({
owner,
repo,
sha,
state,
target_url: runUrl,
description: `Build and Test ${conclusion}`,
context: 'test / Test'
});

84 changes: 84 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions packages/wasm-bip32/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
target/
node_modules/
# we actually only track the .ts files
dist/
test/*.js
test/*.d.ts
js/*.js
js/*.d.ts
js/wasm
.vscode
5 changes: 5 additions & 0 deletions packages/wasm-bip32/.mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extensions": ["ts", "tsx", "js", "jsx"],
"spec": ["test/**/*.ts"],
"node-option": ["import=tsx/esm", "experimental-wasm-modules"]
}
Loading