Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

interface: Add WASM build to CI and fix it #28

Merged
merged 2 commits into from
Nov 27, 2024
Merged
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
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}`;
2 changes: 1 addition & 1 deletion scripts/utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export function getProgramFolders() {

export function getAllProgramFolders() {
return getCargo().workspace.members.filter((member) =>
(getCargo(member).lib?.['crate-type'] ?? []).includes('cdylib')
getCargo(member).package?.metadata?.solana?.['program-id']
);
}

Expand Down