Skip to content
This repository was archived by the owner on Jul 10, 2025. It is now read-only.

Commit 537b4be

Browse files
chore: Add tests CI (#130)
* fix(aqua): Remove topology hack (#125) * Fix scripts * Remove hack * feat(readme): Add `fluence deal logs` output example to README [DXJ-512] (#126) Add deal logs output to README * Setup fcli with action * Use unstable * Test CI * Fix * Fx * Add colors * Fix * Dump logs * Bump js-client * More logs * Log stdout and stderr * Capture stderr * F * F * F * > * NO COLOR * Setup tmate * Add workers * Run without CI true * Run on builder * Run tmata * Setup rust * No colors * Do not setup tmate * Cleanup --------- Co-authored-by: InversionSpaces <[email protected]>
1 parent e8393d8 commit 537b4be

File tree

9 files changed

+246
-48
lines changed

9 files changed

+246
-48
lines changed

.github/workflows/tests.yml

Lines changed: 109 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,37 @@ on:
77
description: "git ref to checkout to"
88
type: string
99
default: "main"
10+
nox-image:
11+
description: "nox image tag"
12+
type: string
13+
default: "null"
14+
fcli-version:
15+
description: "fcli version to use"
16+
type: string
17+
# default: "unstable"
18+
default: "main"
19+
js-client-version:
20+
description: "@fluencelabs/js-client version"
21+
type: string
22+
default: "null"
23+
fluence-env:
24+
description: "env to run tests against"
25+
type: string
26+
default: "local"
1027

1128
jobs:
1229
tests:
13-
name: "build"
14-
runs-on: ubuntu-latest
30+
name: "Run tests"
31+
runs-on: builder
32+
33+
env:
34+
FLUENCE_USER_DIR: "${{ github.workspace }}/tmp/.fluence"
35+
CI: true
36+
# FORCE_COLOR: true
37+
38+
permissions:
39+
contents: read
40+
id-token: write
1541

1642
steps:
1743
- name: Checkout repository
@@ -20,11 +46,86 @@ jobs:
2046
repository: fluencelabs/frpc
2147
ref: ${{ inputs.ref }}
2248

23-
- name: Install fluence-cli@unstable
24-
run: npm i -g @fluencelabs/[email protected]
49+
- name: Import secrets
50+
uses: hashicorp/[email protected]
51+
with:
52+
url: https://vault.fluence.dev
53+
path: jwt/github
54+
role: ci
55+
method: jwt
56+
jwtGithubAudience: "https://github.com/fluencelabs"
57+
jwtTtl: 300
58+
secrets: |
59+
kv/docker-registry/basicauth/ci username | DOCKER_USERNAME ;
60+
kv/docker-registry/basicauth/ci password | DOCKER_PASSWORD ;
61+
kv/npm-registry/basicauth/ci token | NODE_AUTH_TOKEN ;
62+
kv/ci/frpc chain_urls | RPC_PROVIDERS ;
63+
kv/ci/frpc private_key | FLUENCE_CHAIN_PRIVATE_KEY
64+
65+
- name: Login to DockerHub
66+
uses: docker/login-action@v2
67+
with:
68+
registry: docker.fluence.dev
69+
username: ${{ env.DOCKER_USERNAME }}
70+
password: ${{ env.DOCKER_PASSWORD }}
71+
72+
- name: Setup Rust toolchain
73+
uses: dsherret/rust-toolchain-file@v1
74+
75+
- name: Setup fcli
76+
uses: fluencelabs/setup-fluence@v1
77+
with:
78+
artifact: fcli
79+
version: ${{ inputs.fcli-version }}
80+
81+
- name: Init local env with fcli
82+
run: fluence local init --no-input
83+
84+
- name: Replace nox image in docker-compose
85+
if: inputs.nox-image != 'null'
86+
working-directory: .fluence
87+
run: |
88+
sed -i'' -e '/nox-/!b;n;s|image: fluencelabs/nox:.*$|image: ${{ inputs.nox-image }}|' docker-compose.yaml
89+
90+
- name: Run local env
91+
run: fluence local up
92+
93+
- name: Setup node with self-hosted registry
94+
uses: actions/setup-node@v3
95+
with:
96+
node-version: "18"
97+
registry-url: "https://npm.fluence.dev"
98+
cache: "npm"
99+
100+
- name: Run npm i
101+
run: npm i
102+
103+
- name: Run npm i in gateway
104+
working-directory: gateway
105+
run: npm i
106+
107+
- name: Set js-client version
108+
if: inputs.js-client-version != 'null'
109+
uses: fluencelabs/github-actions/npm-set-dependency@main
110+
with:
111+
package: "@fluencelabs/js-client"
112+
version: "${{ inputs.js-client-version }}"
113+
working-directory: gateway
114+
115+
- name: Run npm run build
116+
run: npm run build
117+
118+
- name: Run tests
119+
env:
120+
FLUENCE_ENV: ${{ inputs.fluence-env }}
121+
run: npm run test -- -t deploy
25122

26-
- name: Check if main.aqua compiles
27-
run: fluence aqua --dry
123+
- name: Dump container logs
124+
if: always()
125+
uses: jwalton/gh-docker-logs@v2
28126

29-
- name: Check if services builds
30-
run: fluence build
127+
- name: Cleanup
128+
if: always()
129+
run: |
130+
fluence local down
131+
rm -rf tmp ${{ env.FLUENCE_USER_DIR }}

.gitignore

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ src/js/src/aqua
99
aqua-compiled
1010

1111
# recommended by Fluence Labs:
12-
/.fluence/project-secrets.yaml
13-
/.fluence/schemas
14-
/.fluence/tmp
12+
.fluence/project-secrets.yaml
13+
.fluence/docker-compose.yaml
14+
.fluence/schemas
15+
.fluence/secrets
16+
.fluence/tmp
1517

1618
# to avoid accidental publish of RPC URLs
1719
gateway/configs/quickstart_config.json

README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,55 @@ Fluence CLI did a bunch of work for us behind the scenes and signing the transac
507507
508508
Note that the deal's section in [fluence.yaml](./fluence.yaml) specifies the minimum and maximum workers that should be deployed under the *defaultWorker* namespace. Fluence CLI currently provides default values for min and max workers of one (1) and three (3), respectively. In the near future, you will be able to provide your spot price for service execution, hosting targets in the form of named capacity providers and more.
509509
510+
After successful deal deployment it is possible to retrieve logs for the deployed deal.
511+
512+
**Command**:
513+
514+
```bash
515+
fluence deal logs
516+
```
517+
518+
**Output**:
519+
520+
```bash
521+
Connecting to random stage relay: /dns4/0-stage.fluence.dev/tcp/9000/wss/p2p/12D3KooWDcpWuyrMTDinqNgmXAuRdfd2mTdY9VoXZSAet2pDzh6r
522+
Connected
523+
defaultWorker (host_id: 12D3KooWMMGdfVEJ1rWe1nH1nehYDzNEHhg5ogdfiGk88AupCMnf, worker_id: 12D3KooWGctQEUKcgWBetu9aiR3owMZcBGNcpDC5ZE3H6dL16uSP, spell_id: 679acf1c-57e2-4dd7-aa78-bb181df7a00a):
524+
525+
2023-10-25 14:41:48 Installing worker for deal 0x02ab47b7b2737e16a516421c1b8ad36475e0f7ce
526+
2023-10-25 14:41:48 parsed worker definition bafkreifp4gbp3emepswptldwlpbhpybt47uy2c3ksm3y7rut6cmcdnljwa {
527+
"services": [
528+
{
529+
"modules": [
530+
{
531+
"config": "bafkreia2wftbxfd4blycnvlxw2yl7ibhan2g7vauexv7fspibodlu34que",
532+
"wasm": "bafkreiarl3nin4jtauc52k76h4ze7yekvc5d2uno5fkgpotmcekwm7cnqa"
533+
},
534+
{
535+
"config": "bafkreiaclbxbmtydpwdcpoh2yggcd6uimicmbb6rxzab7bgp342w5vcz2m",
536+
"wasm": "bafybeieeemeldllgokrkgybbrrjqeehyin3blv5cgehhdp3nlrfyj4eqoa"
537+
}
538+
],
539+
"name": "eth_rpc"
540+
}
541+
],
542+
"spells": []
543+
}
544+
2023-10-25 14:41:50 Created service eth_rpc 2b5967ae-e5f9-4929-8668-d2039593af28
545+
2023-10-25 14:41:50 Installation finished
546+
2023-10-25 14:41:50 Worker installation finished with status {
547+
"message": "",
548+
"state": "INSTALLATION_SUCCESSFUL",
549+
"timestamp": 1698244910
550+
}
551+
552+
defaultWorker (host_id: 12D3KooWJ4bTHirdTFNZpCS72TAzwtdmavTBkkEXtzo6wHL25CtE, worker_id: unknown, spell_id: unknown): Worker is not installed yet
553+
554+
defaultWorker (host_id: 12D3KooWAKNos2KogexTXhrkMZzFYpLHuWJ4PgoAhurSAv7o5CWA, worker_id: unknown, spell_id: unknown): Worker is not installed yet
555+
```
556+
557+
In the example output above, we see that the worker for the *defaultWorker* namespace was installed successfully. The worker is now ready to receive requests from the gateway. The other two workers are not installed yet. It should happen in a while and one can check the logs again to see the progress.
558+
510559
### fRPC Aqua Code
511560
512561
Now that we have our services deployed and ready for action, it's time to look at Aqua, which is utilized by the Gateway to bridge HTTP to/from libp2p. Let's have a look at the Aqua code and structure.

fluence.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,21 @@
44

55
# Documentation: https://github.com/fluencelabs/fluence-cli/tree/main/docs/configs/fluence.md
66

7-
version: 2
7+
version: 4
8+
89
aquaInputPath: src/aqua/main.aqua
10+
911
workers:
1012
defaultWorker:
1113
services: [ eth_rpc ]
14+
1215
deals:
1316
defaultWorker:
1417
minWorkers: 3
1518
targetWorkers: 3
19+
1620
relays: stage
21+
1722
services:
1823
eth_rpc:
1924
get: wasm-modules

gateway/aqua/rpc.aqua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ func balancedEthCall{Logger, Balancer}(method: string, jsonArgs: []string) -> Js
4242
worker, provider <- Balancer.next()
4343
Logger.logWorker(worker)
4444
Logger.logCall(provider)
45-
Op.noop() -- dirty hack for topology to converge
4645
rpc <- fromWorkerProvider(worker, provider)
4746
result <- rpcCall{rpc}(method, jsonArgs)
4847
<- result

gateway/package-lock.json

Lines changed: 59 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gateway/package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
"main": "src/index.js",
66
"type": "module",
77
"scripts": {
8-
"run:example": "fluence aqua -i aqua/ -o aqua-compiled/ --js && node src/index.js \"config.json\"",
9-
"run": "fluence aqua -i aqua/ -o aqua-compiled/ --js && node src/index.js",
10-
"compile": "fluence aqua -i aqua/ -o aqua-compiled/ --js",
8+
"run": "npm run compile && node src/index.js",
9+
"compile": "fluence aqua -i aqua/ -o aqua-compiled/ --js --no-input",
1110
"req": "node web3run.js"
1211
},
1312
"bin": {
@@ -21,7 +20,7 @@
2120
"author": "Fluence Labs",
2221
"license": "Apache-2.0",
2322
"dependencies": {
24-
"@fluencelabs/js-client": "0.3.0",
23+
"@fluencelabs/js-client": "0.4.2",
2524
"@fluencelabs/marine-worker": "0.3.3",
2625
"body-parser": "1.20.2",
2726
"express": "4.18.2",

0 commit comments

Comments
 (0)