Skip to content

Commit

Permalink
build: add bindings-ts github workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
chadoh committed Aug 22, 2023
1 parent 325cf4f commit dcc423d
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 4 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/bindings-ts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: bindings typescript

on: [push, pull_request]

jobs:
test:
name: test generated libraries
runs-on: ubuntu-20.04
services:
rpc:
image: stellar/quickstart:soroban-dev@sha256:a6b03cf6b0433c99f2f799b719f0faadbb79684b1b763e7674ba749fb0f648ee
ports:
- 8000:8000
env:
ENABLE_LOGS: true
NETWORK: standalone
ENABLE_SOROBAN_RPC: true
options: >-
--health-cmd "curl -X POST \"http://localhost:8000/soroban/rpc\""
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v3
- uses: stellar/actions/rust-cache@main
- uses: baptiste0928/cargo-install@v2
with:
crate: soroban-cli
version: "0.9.4" # FIXME: install version in this branch; main's broken with quickstart currently
- run: rustup update
- run: rustup target add wasm32-unknown-unknown
- run: make build-test-wasms
- run: npm i && npm run test
working-directory: cmd/crates/soroban-spec-typescript/ts-tests
12 changes: 12 additions & 0 deletions cmd/crates/soroban-spec-typescript/ts-tests/package-lock.json

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

4 changes: 3 additions & 1 deletion cmd/crates/soroban-spec-typescript/ts-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"private": true,
"type": "module",
"scripts": {
"test": "ava"
"soroban": "../../../../target/bin/soroban",
"setup": "curl -X POST \"http://localhost:8000\" && npm run soroban -- config network add standalone --rpc-url \"http://localhost:8000/soroban/rpc\" --network-passphrase \"Standalone Network ; February 2017\" && npm run soroban -- config identity fund --network standalone && export CONTRACT_ID=$(../../../../target/bin/soroban contract deploy --wasm ../../../../target/wasm32-unknown-unknown/test-wasms/test_custom_types.wasm --network standalone) && npm run soroban -- contract bindings typescript --contract-id $CONTRACT_ID --network standalone --output-dir ./node_modules/test-custom-types --overwrite || { echo \"Make sure you're running standalone RPC network on localhost:8000\" && exit 1; }",
"test": "npm run setup && ava"
},
"devDependencies": {
"@ava/typescript": "^4.1.0",
Expand Down
6 changes: 3 additions & 3 deletions cmd/crates/soroban-spec-typescript/ts-tests/src/test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import test from 'ava'
import { Contract, Ok, Err, networks } from '../../fixtures/test_custom_types/dist/esm/index.js'
import { Contract, Ok, Err, networks } from 'test-custom-types'

const rpcUrl = 'https://rpc-futurenet.stellar.org'
const publicKey = 'GCBVOLOM32I7OD5TWZQCIXCXML3TK56MDY7ZMTAILIBQHHKPCVU42XYW'

const contract = new Contract({
...networks.futurenet,
...networks[Object.keys(networks)[0] as keyof typeof networks],
rpcUrl,
wallet: {
isConnected: () => Promise.resolve(true),
Expand Down Expand Up @@ -185,4 +185,4 @@ test('tuple_strukt', async t => {
const arg = [{ a: 0, b: true, c: 'hello' }, { tag: 'First', values: undefined }] as const
const res = [{ a: 0, b: true, c: 'hello' }, ['First']]
t.deepEqual(await contract.tupleStrukt({ tuple_strukt: arg }), res)
})
})

0 comments on commit dcc423d

Please sign in to comment.