diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6182cd1e..21e28848 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,10 +1,5 @@ name: CI - -on: - pull_request: - branches: - - main - +on: [push] concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true @@ -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 @@ -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" diff --git a/.mise.toml b/.mise.toml index 46cc63f0..1064fe03 100644 --- a/.mise.toml +++ b/.mise.toml @@ -1,2 +1,3 @@ [tools] node = "23.0" +"cargo:wasm-pack" = "0.13.1" diff --git a/.nil-sdk.toml b/.nil-sdk.toml new file mode 100644 index 00000000..3a067255 --- /dev/null +++ b/.nil-sdk.toml @@ -0,0 +1 @@ +version = "v0.9.0-rc.57" diff --git a/biome.jsonc b/biome.jsonc index 734bb130..0d02c5e3 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -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, diff --git a/client-vms/tests/payments.test.ts b/client-vms/tests/payments.test.ts index f203cbc5..f66a5cda 100644 --- a/client-vms/tests/payments.test.ts +++ b/client-vms/tests/payments.test.ts @@ -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); @@ -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 () => { @@ -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); }); }); diff --git a/client-wasm/package.json b/client-wasm/package.json index 3acae4b5..f3d5019b 100644 --- a/client-wasm/package.json +++ b/client-wasm/package.json @@ -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", diff --git a/client-wasm/rustfmt.toml b/client-wasm/rustfmt.toml new file mode 100644 index 00000000..ecf334f0 --- /dev/null +++ b/client-wasm/rustfmt.toml @@ -0,0 +1,5 @@ +version = "Two" +use_small_heuristics = "Max" +merge_derives = false +max_width = 120 +imports_granularity = "Crate" diff --git a/nillion b/nillion index 7180d6e0..eb39eea0 160000 --- a/nillion +++ b/nillion @@ -1 +1 @@ -Subproject commit 7180d6e07cdad5ead8f98c25442ba94dd59b606c +Subproject commit eb39eea05901761e2cf0f9a9fa463d1ffba0c695