Skip to content

Commit

Permalink
Merge pull request #76 from NillionNetwork/chore/ci-client-wasm-tests
Browse files Browse the repository at this point in the history
chore: add client-wasm tests to the CI workflow
  • Loading branch information
pablojhl authored Jan 29, 2025
2 parents b95d432 + baccd47 commit 5bd77de
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 18 deletions.
64 changes: 51 additions & 13 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
name: CI

on:
pull_request:
branches:
- main

on: [push]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
Expand All @@ -13,12 +8,29 @@ jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Generate nillion repo app token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.NILLION_GITHUB_ACTIONS_PUBLIC_APP_ID }}
owner: NillionNetwork
private-key: ${{ secrets.NILLION_GITHUB_ACTIONS_PUBLIC_APP_PRIVATE_KEY }}
repositories: nillion
- uses: actions/checkout@v4
with:
token: ${{ steps.generate-token.outputs.token }}
submodules: 'recursive'
- name: Install rustup
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2024-07-01
- uses: actions/setup-node@v4
with:
node-version: "23"
- uses: pnpm/action-setup@v4
- run: pnpm install
- run: pnpm --filter "@nillion/client-wasm" rust:check:format
- run: pnpm --filter "@nillion/client-wasm" rust:clippy
- run: pnpm --filter "@nillion/client-vms" build:proto
- run: pnpm --filter "@nillion/client-vms" build
- run: pnpm --filter "@nillion/client-react-hooks" build
Expand All @@ -27,20 +39,46 @@ jobs:
- run: pnpm exec tsc -p client-vms/tsconfig.json
- run: pnpm exec tsc -p client-react-hooks/tsconfig.json

test-client-wasm:
needs: check
runs-on: ubuntu-latest
steps:
- name: Generate nillion repo app token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.NILLION_GITHUB_ACTIONS_PUBLIC_APP_ID }}
owner: NillionNetwork
private-key: ${{ secrets.NILLION_GITHUB_ACTIONS_PUBLIC_APP_PRIVATE_KEY }}
repositories: nillion
- uses: actions/checkout@v4
with:
token: ${{ steps.generate-token.outputs.token }}
submodules: 'recursive'
- name: Install rustup
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2024-07-01
- uses: jdx/mise-action@v2
- uses: pnpm/action-setup@v4
- run: pnpm install
- run: pnpm --filter "@nillion/client-wasm" test

test-client-vms:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Aws credentials are required so that nilup can access rc builds
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: "eu-west-1"
- uses: NillionNetwork/nillion-setup-action@main
- name: Get SDK Version
id: get-sdk-version
run: |
VERSION=$(cat .nil-sdk.toml | sed -e "s|.*\"\(.*\)\".*|\1|g")
echo "version=$VERSION" > $GITHUB_OUTPUT
- name: Install nillion SDK
uses: NillionNetwork/nillion-setup-action@main
with:
version: "v0.9.0-rc.49"
version: ${{ steps.get-sdk-version.outputs.version }}
- uses: actions/setup-python@v5
with:
python-version: "3.12"
Expand Down
1 change: 1 addition & 0 deletions .mise.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[tools]
node = "23.0"
"cargo:wasm-pack" = "0.13.1"
1 change: 1 addition & 0 deletions .nil-sdk.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version = "v0.9.0-rc.57"
2 changes: 1 addition & 1 deletion biome.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"files": {
"ignoreUnknown": false,
"include": ["**/*.ts", "**/*.mjs", "**/*.json", "**/*.tsx"],
"ignore": ["client-vms/src/gen-proto", "client-wasm/dist"]
"ignore": ["client-vms/src/gen-proto", "client-wasm/dist", "nillion"]
},
"formatter": {
"enabled": true,
Expand Down
7 changes: 4 additions & 3 deletions client-vms/tests/payments.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Env, PrivateKeyPerSuite } from "./helpers";

describe("PaymentClient", () => {
let client: VmClient;
const fundsAmount = BigInt(20000);

beforeAll(async () => {
const signer = await createSignerFromKey(PrivateKeyPerSuite.Payments);
Expand Down Expand Up @@ -63,13 +64,13 @@ describe("PaymentClient", () => {
});

it("add enough funds", async () => {
const result = await client.payer.addFunds(BigInt(10));
const result = await client.payer.addFunds(fundsAmount);
expect(result).toBeNull;
});

it("account is funded", async () => {
const account = await client.payer.accountBalance();
expect(account.balance).toBe(BigInt(1000));
expect(account.balance).toBe(BigInt(2));
});

it("can pay from balance", async () => {
Expand All @@ -81,6 +82,6 @@ describe("PaymentClient", () => {
});
await client.payer.payForOperation(request);
const account = await client.payer.accountBalance();
expect(account.balance).toBeLessThan(BigInt(1000));
expect(account.balance).toBeLessThan(fundsAmount);
});
});
3 changes: 3 additions & 0 deletions client-wasm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
}
},
"scripts": {
"rust:check:format": "cargo fmt --check",
"rust:format": "cargo fmt",
"rust:clippy": "cargo clippy",
"test": "wasm-pack test --node",
"typecheck": "echo 'no op'; exit 0",
"build:watch": "echo 'no op'; exit 0",
Expand Down
5 changes: 5 additions & 0 deletions client-wasm/rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version = "Two"
use_small_heuristics = "Max"
merge_derives = false
max_width = 120
imports_granularity = "Crate"
2 changes: 1 addition & 1 deletion nillion

0 comments on commit 5bd77de

Please sign in to comment.