|
| 1 | +name: "Build and Test (Reusable)" |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + upload-artifacts: |
| 7 | + description: "Upload build artifacts" |
| 8 | + type: boolean |
| 9 | + default: false |
| 10 | + |
| 11 | +jobs: |
| 12 | + run: |
| 13 | + name: "Test" |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v4 |
| 18 | + with: |
| 19 | + ref: ${{ github.event.pull_request.head.sha || github.sha }} |
| 20 | + |
| 21 | + - name: Install Rust |
| 22 | + uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1 |
| 23 | + with: |
| 24 | + toolchain: nightly-2025-10-23 |
| 25 | + |
| 26 | + - name: Cache Rust dependencies |
| 27 | + uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1 |
| 28 | + with: |
| 29 | + workspaces: "packages/wasm-utxo" |
| 30 | + cache-on-failure: true |
| 31 | + |
| 32 | + - name: Setup node 20 |
| 33 | + uses: actions/setup-node@v4 |
| 34 | + with: |
| 35 | + node-version: 20 |
| 36 | + |
| 37 | + - name: Ensure npm 11.5.1 |
| 38 | + run: | |
| 39 | + npm install -g npm@11.5.1 |
| 40 | +
|
| 41 | + - name: Install wasm tools |
| 42 | + run: | |
| 43 | + rustup component add rustfmt |
| 44 | + cargo install wasm-pack --version 0.13.1 |
| 45 | + cargo install wasm-opt --version 0.116.1 |
| 46 | + cargo install cargo-deny --locked |
| 47 | +
|
| 48 | + - name: Build Info |
| 49 | + run: | |
| 50 | + echo "node $(node --version)" |
| 51 | + echo "npm $(npm --version)" |
| 52 | + echo "rustc $(rustc --version)" |
| 53 | + echo "wasm-pack $(wasm-pack --version)" |
| 54 | + echo "wasm-opt $(wasm-opt --version)" |
| 55 | + echo "cargo-deny $(cargo deny --version)" |
| 56 | + git --version |
| 57 | + echo "base ref $GITHUB_BASE_REF" |
| 58 | + echo "head ref $GITHUB_HEAD_REF" |
| 59 | +
|
| 60 | + - name: Fetch Base Ref |
| 61 | + if: github.event_name == 'pull_request' |
| 62 | + run: | |
| 63 | + git fetch origin $GITHUB_BASE_REF |
| 64 | +
|
| 65 | + - name: Install Packages |
| 66 | + run: npm ci --workspaces --include-workspace-root |
| 67 | + |
| 68 | + - name: Check dependencies with cargo-deny |
| 69 | + run: cargo deny check |
| 70 | + working-directory: packages/wasm-utxo |
| 71 | + |
| 72 | + - name: build packages |
| 73 | + run: npm --workspaces run build |
| 74 | + |
| 75 | + - name: Check Source Code Formatting |
| 76 | + run: npm run check-fmt |
| 77 | + |
| 78 | + - name: wasm-utxo / cargo test |
| 79 | + run: cargo test --workspace |
| 80 | + working-directory: packages/wasm-utxo |
| 81 | + |
| 82 | + - name: wasm-utxo / Wasm-Pack Test (Node) |
| 83 | + run: npm run test:wasm-pack-node |
| 84 | + working-directory: packages/wasm-utxo |
| 85 | + |
| 86 | + - name: wasm-utxo / Wasm-Pack Test (Chrome) |
| 87 | + run: npm run test:wasm-pack-chrome |
| 88 | + working-directory: packages/wasm-utxo |
| 89 | + |
| 90 | + - name: Unit Test |
| 91 | + run: npm --workspaces test |
| 92 | + |
| 93 | + - name: Upload build artifacts |
| 94 | + if: inputs.upload-artifacts |
| 95 | + uses: actions/upload-artifact@v4 |
| 96 | + with: |
| 97 | + name: wasm-utxo-build |
| 98 | + path: | |
| 99 | + packages/wasm-utxo/pkg/ |
| 100 | + packages/wasm-utxo/dist/ |
| 101 | + retention-days: 1 |
| 102 | + |
0 commit comments