forked from solana-foundation/surfpool
-
Notifications
You must be signed in to change notification settings - Fork 0
217 lines (188 loc) · 7.29 KB
/
Copy pathsdk_node.yml
File metadata and controls
217 lines (188 loc) · 7.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
name: SDK Node
on:
push:
branches:
- main
paths:
- ".github/workflows/sdk_node.yml"
- "Cargo.lock"
- "Cargo.toml"
- "crates/core/src/rpc/surfnet_cheatcodes.rs"
- "crates/core/src/types.rs"
- "crates/sdk/**"
- "crates/sdk-node/**"
- "crates/types/**"
pull_request:
branches:
- main
paths:
- ".github/workflows/sdk_node.yml"
- "Cargo.lock"
- "Cargo.toml"
- "crates/core/src/rpc/surfnet_cheatcodes.rs"
- "crates/core/src/types.rs"
- "crates/sdk/**"
- "crates/sdk-node/**"
- "crates/types/**"
env:
CARGO_TERM_COLOR: always
SURFPOOL_WEB_UI_VERSION: 0.2.0-alpha.0
jobs:
kit_types_fresh:
name: Generated kit RPC types are up to date
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust artifacts
uses: Swatinem/rust-cache@v2
with:
prefix-key: v1-rust-types
cache-bin: false
workspaces: |
. -> target
- name: Regenerate kit type bindings
run: node crates/sdk-node/scripts/generate-kit-types.js
- name: Verify committed bindings are up to date
run: git diff --exit-code -- crates/sdk-node/surfpool-sdk/kit/generated
validate:
name: Validate (${{ matrix.name }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- name: linux-x64
os: ubuntu-22.04
run_sdk_tests: true
platform_dir: linux-x64-gnu
- name: macos-x64
os: macos-15-intel
run_sdk_tests: false
platform_dir: darwin-x64
- name: macos-arm64
os: macos-15
run_sdk_tests: false
platform_dir: darwin-arm64
steps:
- name: Install Linux dependencies
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y libudev-dev clang libclang-dev
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust artifacts
uses: Swatinem/rust-cache@v2
with:
prefix-key: v1-rust
cache-bin: false
workspaces: |
. -> target
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 22.14.0
cache: npm
cache-dependency-path: crates/sdk-node/package-lock.json
- name: Install npm dependencies
working-directory: crates/sdk-node
run: npm ci
- name: Run sdk lib tests
if: matrix.run_sdk_tests
run: cargo test -p surfpool-sdk --lib --tests
- name: Run sdk doc tests
if: matrix.run_sdk_tests
run: cargo test -p surfpool-sdk --doc
- name: Build sdk-node crate
run: cargo build -p surfpool-sdk-node --release
- name: Build npm package
working-directory: crates/sdk-node
run: npm run build
- name: Smoke test local package
working-directory: crates/sdk-node
run: npm run smoke
- name: Create npm platform package directories
working-directory: crates/sdk-node
run: npm run create-npm-dir
- name: Stage host binary for npm packaging
working-directory: crates/sdk-node
shell: bash
run: |
rm -rf artifacts
mkdir -p artifacts/local
cp surfpool-sdk/surfpool-sdk.*.node artifacts/local/
- name: Copy artifacts into npm platform packages
working-directory: crates/sdk-node
run: npm run artifacts
- name: Pack root and platform tarballs
id: pack
working-directory: crates/sdk-node
shell: bash
run: |
ROOT_PACK=$(NPM_CONFIG_CACHE=$(mktemp -d) npm pack --json | node -e 'let data = ""; process.stdin.on("data", (chunk) => data += chunk); process.stdin.on("end", () => console.log(JSON.parse(data)[0].filename));')
PLATFORM_PACK=$(cd "npm/${{ matrix.platform_dir }}" && NPM_CONFIG_CACHE=$(mktemp -d) npm pack --json | node -e 'let data = ""; process.stdin.on("data", (chunk) => data += chunk); process.stdin.on("end", () => console.log(JSON.parse(data)[0].filename));')
echo "root_pack=${ROOT_PACK}" >> "$GITHUB_OUTPUT"
echo "platform_pack=npm/${{ matrix.platform_dir }}/${PLATFORM_PACK}" >> "$GITHUB_OUTPUT"
- name: Smoke test packed npm install
working-directory: crates/sdk-node
shell: bash
run: |
TMP_DIR=$(mktemp -d)
cp "${{ steps.pack.outputs.root_pack }}" "${TMP_DIR}/"
cp "${{ steps.pack.outputs.platform_pack }}" "${TMP_DIR}/"
cd "${TMP_DIR}"
npm init -y
npm install "./$(basename "${{ steps.pack.outputs.platform_pack }}")"
npm install "./$(basename "${{ steps.pack.outputs.root_pack }}")"
node - <<'EOF'
const assert = require("node:assert/strict");
const { Surfnet } = require("@solana/surfpool");
const keypair = Surfnet.newKeypair();
assert.equal(keypair.secretKey.length, 64);
const surfnet = Surfnet.startWithConfig({
offline: true,
blockProductionMode: "manual"
});
assert.match(surfnet.rpcUrl, /^http:\/\//);
assert.match(surfnet.wsUrl, /^ws:\/\//);
assert.ok(surfnet.instanceId.length > 0);
assert.ok(Array.isArray(surfnet.drainEvents()));
EOF
- name: Smoke test packed kit entry
working-directory: crates/sdk-node
shell: bash
run: |
TMP_DIR=$(mktemp -d)
cp "${{ steps.pack.outputs.root_pack }}" "${TMP_DIR}/"
cp "${{ steps.pack.outputs.platform_pack }}" "${TMP_DIR}/"
cd "${TMP_DIR}"
npm init -y
npm install "./$(basename "${{ steps.pack.outputs.platform_pack }}")"
npm install "./$(basename "${{ steps.pack.outputs.root_pack }}")"
# The kit peers are optional and not auto-installed; installing them
# here validates the documented opt-in flow.
npm install "@solana/kit@^8.0.0" "@solana/kit-plugin-rpc@^0.18.0" "@solana/kit-plugin-signer@^0.18.0"
node - <<'EOF'
const assert = require("node:assert/strict");
const { createClient } = require("@solana/kit");
const { surfpool } = require("@solana/surfpool/kit");
async function main() {
const client = await createClient().use(surfpool({ surfnet: { offline: true } }));
assert.equal(client.payer.address, client.surfnet.payer);
const info = await client.cheatcodes.getSurfnetInfo().send();
assert.ok(Array.isArray(info.runbookExecutions));
const slot = await client.rpc.getSlot().send();
assert.equal(typeof slot, "bigint");
client.surfnet.stop();
}
main();
EOF
node --input-type=module - <<'EOF'
import assert from "node:assert/strict";
import { surfpool, createSurfnetCheatcodesRpc } from "@solana/surfpool/kit";
assert.equal(typeof surfpool, "function");
assert.equal(typeof createSurfnetCheatcodesRpc, "function");
EOF