Skip to content

Commit

Permalink
interface: Add WASM build to CI and fix it
Browse files Browse the repository at this point in the history
#### Problem

The solana-system-interface crate is meant to work with WASM, but it's
not currently tested in CI.

#### Summary of changes

* Add `crate-type` to Cargo.toml, which is required for wasm-pack
* Add step testing `wasm-pack` in CI
  • Loading branch information
joncinque committed Nov 26, 2024
1 parent b530451 commit ec9155b
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,28 @@ jobs:
- name: Lint / Docs
run: pnpm zx ./scripts/interface/lint-docs.mjs

wasm_interface:
name: Build Interface in WASM
runs-on: ubuntu-latest
needs: format_and_lint_interface
steps:
- name: Git Checkout
uses: actions/checkout@v4

- name: Setup Environment
uses: ./.github/actions/setup
with:
cargo-cache-key: cargo-wasm-interface
solana: true

- name: Install wasm-pack
uses: taiki-e/install-action@v2
with:
tool: wasm-pack

- name: Build Interface with wasm-pack
run: pnpm interface:wasm

test_interface:
name: Test Interface
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,6 @@ frozen-abi = [
"solana-pubkey/std"
]
serde = ["dep:serde", "dep:serde_derive", "solana-pubkey/serde"]

[lib]
crate-type = ["cdylib", "rlib"]
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"interface:format": "zx ./scripts/interface/format.mjs",
"interface:lint": "zx ./scripts/interface/lint.mjs",
"interface:test": "zx ./scripts/interface/test.mjs",
"interface:wasm": "zx ./scripts/interface/wasm.mjs",
"template:upgrade": "zx ./scripts/upgrade-template.mjs"
},
"devDependencies": {
Expand Down
14 changes: 14 additions & 0 deletions scripts/interface/wasm.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env zx
import 'zx/globals';
import {
cliArguments,
workingDirectory,
} from '../utils.mjs';

// Configure additional arguments here, e.g.:
// ['--arg1', '--arg2', ...cliArguments()]
const buildArgs = cliArguments();
const cratePath = path.join(workingDirectory, 'interface');

// Build the interface.
await $`wasm-pack build --target nodejs --dev ${cratePath} --features bincode ${buildArgs}`;

0 comments on commit ec9155b

Please sign in to comment.