Skip to content

Commit

Permalink
ci(core): enable tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-hm committed Aug 6, 2024
1 parent 600eb4a commit 8e735c3
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 66 deletions.
63 changes: 36 additions & 27 deletions .github/workflows/check-build-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,30 @@ concurrency:
cancel-in-progress: true

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: extractions/setup-just@v2
- uses: actions/setup-node@v4
with:
node-version: '22'
- uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-
- run: npm ci
- run: just check
# check:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: extractions/setup-just@v2
# - uses: actions/setup-node@v4
# with:
# node-version: '22'
# - uses: actions/cache@v3
# with:
# path: ~/.npm
# key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
# restore-keys: |
# ${{ runner.OS }}-node-
# - run: npm ci
# - run: just check


build-and-test:
needs: check
# needs: check
runs-on: ubuntu-latest
strategy:
matrix:
package: [ client-core, client-payments, client-vms ]
# strategy:
# matrix:
# package: [ client-core, client-payments, client-vms ]
steps:
- uses: actions/checkout@v4
- uses: extractions/setup-just@v2
Expand All @@ -47,13 +47,22 @@ jobs:
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-
- name: Run install protobuf-compiler (if 'client-payments')
if: contains(matrix.package, 'client-payments')
env:
DEBIAN_FRONTEND: noninteractive
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y protobuf-compiler
- run: |
sudo apt install -y protobuf-compiler curl
npm ci
just test-${{ matrix.package }}
- name: Install and configure nilup
run: |
curl https://nilup.nilogy.xyz/install.sh | bash
$HOME/.nilup/bin/nilup use 0.5.0
$HOME/.nilup/bin/nilup init
echo "$HOME/.nilup/bin" >> $GITHUB_PATH
- run: |
nillion-devnet &
PID=$!
echo "nillion-devnet started with PID: $PID"
sleep 5
kill $PID
echo "nillion-devnet with PID $PID has been stopped."
# just test-${{ matrix.package }}
6 changes: 3 additions & 3 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ test-client-core:
npm -w packages/client-core run test:build
npm -w packages/client-core run test
test-serve-client-core:
test-client-core-serve:
#!/usr/bin/env bash
set -euxo pipefail
npm -w packages/client-core run clean
Expand Down Expand Up @@ -116,7 +116,7 @@ test-client-payments:
npm -w packages/client-payments run test:build
npm -w packages/client-payments run test
test-serve-client-payments:
test-client-payments-serve:
#!/usr/bin/env bash
set -euxo pipefail
just clean
Expand Down Expand Up @@ -152,7 +152,7 @@ test-client-vms:
npm -w packages/client-vms run test:build
npm -w packages/client-vms run test
test-serve-client-vms:
test-client-vms-serve:
#!/usr/bin/env bash
set -euxo pipefail
just clean
Expand Down
4 changes: 1 addition & 3 deletions packages/client-core/jasmine.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import { fileURLToPath } from "node:url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

console.log(__dirname);

export default {
port: 9191,
srcDir: "../fixture",
Expand Down Expand Up @@ -35,6 +33,6 @@ export default {
"/(:filename).(wasm|js)": (req, res) => {
res.sendFile(path.resolve(__dirname, `dist/${req.baseUrl}`));
},
"/nilchain": proxy(configFixture.payments_rpc_endpoint),
"/nilchain": proxy("http://localhost:26650"),
},
};
2 changes: 1 addition & 1 deletion packages/client-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"clean": "rm -rf dist",
"build": "node esbuild.config.mjs",
"build:watch": "node esbuild.config.mjs --watch",
"test": "echo 'info: disabled due to cli specific failures'",
"test": "npx jasmine-browser-runner runSpecs --config=jasmine.config.mjs",
"test:build": "npx webpack --config webpack.config.mjs",
"test:build:watch": "npx webpack --config webpack.config.mjs --watch",
"test:serve": "npx jasmine-browser-runner serve --config=jasmine.config.mjs"
Expand Down
8 changes: 4 additions & 4 deletions packages/client-core/src/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ export type NamedNetwork = z.infer<typeof NamedNetwork>;
export const PartialConfig = {
TestFixture: {
network: NamedNetwork.enum.TestFixture,
cluster: "e2c959ca-ecb2-45b0-8f2b-d91abbfa3708",
cluster: "57408f48-0f51-4699-a317-20a7764e87f7",
bootnodes: [
"/ip4/127.0.0.1/tcp/14211/ws/p2p/12D3KooWCAGu6gqDrkDWWcFnjsT9Y8rUzUH8buWjdFcU3TfWRmuN",
"/ip4/127.0.0.1/tcp/53192/ws/p2p/12D3KooWPTNZdksW3n4tq7pEFa1pejjGi3AoPXRp58sPbZuwyVhU",
],
chain: "nillion-chain-devnet",
endpoint: "http://localhost:9191/nilchain",
logging: true,
userSeed: "nillion-testnet-seed-1",
nodeSeed: "nillion-testnet-seed-1",
userSeed: "nillion-testnet-test-fixture-1",
nodeSeed: "nillion-testnet-test-fixture-1",
},
Devnet: {
network: NamedNetwork.enum.Devnet,
Expand Down
7 changes: 2 additions & 5 deletions packages/client-core/tests/core.init.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
StoreId,
VmClientConfig,
} from "@nillion/client-core";
import { expectOk } from "../../fixture/helpers";
import { expectOk, FixtureConfig } from "../../fixture/helpers";
import { Effect as E } from "effect";

const SUITE_NAME = `@nillion/client-core > initialization`;
Expand Down Expand Up @@ -63,10 +63,7 @@ describe(SUITE_NAME, () => {

it("can compute stable partyId from seed 'nillion-testnet-seed-1'", () => {
const partyId = client.partyId;
expect(partyId).toBeDefined();
expect(partyId).toEqual(
"12D3KooWGq5MCUuLARrwM95muvipNWy4MqmCk41g9k9JVth6AF6e",
);
expect(partyId).toEqual(FixtureConfig.partyId);
});

it("can fetch the cluster descriptor", async () => {
Expand Down
7 changes: 2 additions & 5 deletions packages/client-core/tests/core.nonpaid.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
NamedValue,
VmClientConfig,
} from "@nillion/client-core";
import configFixture from "../../fixture/network.json";
import { expectOk, loadProgram } from "../../fixture/helpers";

const SUITE_NAME = `@nillion/client-core > non-paid functions`;
Expand All @@ -25,9 +24,7 @@ describe(SUITE_NAME, () => {

const data = {
store: StoreId.parse("aaaaaaaa-bbbb-cccc-dddd-ffffffffffff"),
program: ProgramId.parse(
`${configFixture.programs_namespace}/simple_shares`,
),
program: ProgramId.parse("foo/simple_share"),
};

beforeAll(async () => {
Expand All @@ -41,7 +38,7 @@ describe(SUITE_NAME, () => {
console.log(`*** Finish ${SUITE_NAME} *** \n\n`);
});

it("can get quote for compute", async () => {
xit("can get quote for compute", async () => {
const args = {
bindings: ProgramBindings.create(data.program),
values: NadaValues.create().insert(
Expand Down
1 change: 1 addition & 0 deletions packages/client-core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"noEmit": false,
"baseUrl": ".",
"paths": {
"@nillion/client-core": [
Expand Down
7 changes: 1 addition & 6 deletions packages/client-core/webpack.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,7 @@ export default {
rules: [
{
test: /\.tsx?$/,
use: {
loader: "ts-loader",
options: {
transpileOnly: true,
},
},
use: "ts-loader",
exclude: /node_modules/,
},
{
Expand Down
1 change: 1 addition & 0 deletions packages/fixture/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./data";
export * from "./expect";
export * from "./network";
export * from "./program";
7 changes: 7 additions & 0 deletions packages/fixture/helpers/network.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const FixtureConfig = {
// NILLION_NILCHAIN_PRIVATE_KEY_0 from seed "nillion-testnet-test-fixture-1"
paymentsKey:
"9a975f567428d054f2bf3092812e6c42f901ce07d9711bc77ee2cd81101f42c5",
// expected party id derived from "nillion-testnet-test-fixture-1"
partyId: "12D3KooWH2cVwpy73bn4gWNvPdywPshp3gTWPmrPyzex4uUMNb8j",
};
9 changes: 0 additions & 9 deletions packages/fixture/network.json

This file was deleted.

5 changes: 2 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react",
"module": "es2022",
"module": "esnext",
"moduleResolution": "bundler",
"noEmit": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"target": "es2022",
"target": "esnext",
"lib": [
"dom",
"dom.iterable",
Expand Down

0 comments on commit 8e735c3

Please sign in to comment.