Skip to content

Commit

Permalink
feat: remove nox
Browse files Browse the repository at this point in the history
  • Loading branch information
shamsartem committed Dec 20, 2024
1 parent fd4bcc3 commit 352a32f
Show file tree
Hide file tree
Showing 19 changed files with 34 additions and 916 deletions.
8 changes: 0 additions & 8 deletions .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@
"extends": ["github>fluencelabs/renovate", "github>fluencelabs/renovate:npm"],
"enabledManagers": ["npm", "regex"],
"regexManagers": [
{
"fileMatch": ["^packages/cli/package/src/versions\\.json$"],
"matchStrings": [
"\"nox\": \"(?<lookupName>[^:]+):(?<currentValue>.*)\",\n"
],
"datasourceTemplate": "docker",
"depNameTemplate": "nox"
},
{
"fileMatch": ["^packages/cli/package/src/versions\\.json$"],
"matchStrings": [
Expand Down
22 changes: 0 additions & 22 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ on:
description: "Fluence environment to run tests against"
type: string
default: "local"
nox-image:
description: "nox image tag"
type: string
default: "null"
chain-rpc-image:
description: "chain-rpc image tag"
type: string
Expand Down Expand Up @@ -88,23 +84,6 @@ jobs:
kv/docker-registry/basicauth/ci password | DOCKER_PASSWORD ;
kv/npm-registry/basicauth/ci token | NODE_AUTH_TOKEN;
- name: Set nox image
run: |
# set nox image
case ${{ inputs.nox-image }} in
# if nox image is not passed from e2e read from versions.json
'null')
nox="$(jq .nox packages/cli/package/src/versions.json -r)"
;;
# else set nox image to snapshot passed from e2e
*)
nox=${{ inputs.nox-image }}
;;
esac
echo "nox image used for tests is $nox"
echo "NOX_IMAGE=${nox}" >> $GITHUB_ENV
- name: Set deal images
run: |
# set deal images
Expand Down Expand Up @@ -173,7 +152,6 @@ jobs:
with:
versions: |
{
"nox": "${{ env.NOX_IMAGE }}",
"chain-rpc": "${{ env.CHAIN_RPC_IMAGE }}",
"chain-deploy-script": "${{ env.CHAIN_DEPLOY_SCRIPT_IMAGE }}",
"subgraph-deploy-script": "${{ env.SUBGRAPH_DEPLOY_SCRIPT_IMAGE }}"
Expand Down
1 change: 0 additions & 1 deletion packages/cli/package/example.env
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@


# CLI Dependency override examples
# FCLI_V_NOX="fluencelabs/nox:0.4.0"
# FCLI_V_CHAIN="docker.fluence.dev/aurora:0.2.11"

# environment variables to be used by Fluence CLI maintainers to develop Fluence CLI:
Expand Down
3 changes: 0 additions & 3 deletions packages/cli/package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,9 @@
},
"dependencies": {
"@fluencelabs/deal-ts-clients": "0.22.1",
"@fluencelabs/fluence-network-environment": "1.2.3",
"@fluencelabs/js-client": "0.9.0",
"@iarna/toml": "2.2.5",
"@kubernetes/client-node": "github:fluencelabs/kubernetes-client-javascript#e72ee00a52fec4eb4a8327632895d888ee504f4d",
"@mswjs/interceptors": "0.29.1",
"@multiformats/multiaddr": "12.2.1",
"@oclif/color": "1.0.13",
"@oclif/core": "4.0.29",
"@oclif/plugin-autocomplete": "3.2.6",
Expand Down
37 changes: 0 additions & 37 deletions packages/cli/package/src/commands/default/peers.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/cli/package/src/commands/provider/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export default class Deploy extends BaseCommand<typeof Deploy> {
* @param specPath File system path to a YAML Kubernetes spec.
* @return Array of resources created
*/
export async function kubectlApply(
async function kubectlApply(
kubeconfigPath: string,
specPath: string,
peerName: string,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package/src/commands/provider/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default class Info extends BaseCommand<typeof Info> {
)),
computePeers: computePeers.map(({ name, peerId, walletAddress }) => {
return {
nox: name,
peer: name,
peerId,
wallet: walletAddress,
};
Expand Down
14 changes: 7 additions & 7 deletions packages/cli/package/src/lib/configs/project/chainContainers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import { versions } from "../../../versions.js";

export type Service = {
type Service = {
image?: string;
ports?: string[];
pull_policy?: string;
Expand All @@ -29,24 +29,24 @@ export type Service = {
healthcheck?: Record<string, string | number>;
};

export type Config = {
type Config = {
services: Record<string, Service>;
volumes?: Record<string, null>;
include?: string[];
secrets?: Record<string, { file?: string }>;
};

export const CHAIN_DEPLOY_SCRIPT_NAME = "chain-deploy-script";
const CHAIN_DEPLOY_SCRIPT_NAME = "chain-deploy-script";
export const CHAIN_RPC_CONTAINER_NAME = "chain-rpc";
export const CHAIN_RPC_PORT = "8545";
const GRAPH_NODE_CONTAINER_NAME = "graph-node";
const GRAPH_NODE_PORT = "8020";
export const IPFS_CONTAINER_NAME = "ipfs";
export const IPFS_PORT = "5001";
const IPFS_CONTAINER_NAME = "ipfs";
const IPFS_PORT = "5001";
const POSTGRES_CONTAINER_NAME = "postgres";
const SUBGRAPH_DEPLOY_SCRIPT_NAME = "subgraph-deploy-script";

export const chainContainers: Config = {
export const chainContainers = {
volumes: {
"chain-rpc": null,
[IPFS_CONTAINER_NAME]: null,
Expand Down Expand Up @@ -150,4 +150,4 @@ export const chainContainers: Config = {
depends_on: [GRAPH_NODE_CONTAINER_NAME],
},
},
};
} as const satisfies Config;
176 changes: 2 additions & 174 deletions packages/cli/package/src/lib/configs/project/dockerCompose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,192 +15,20 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import assert from "assert";
import { writeFile } from "fs/promises";
import { join, relative } from "path";

import { yamlDiffPatch } from "yaml-diff-patch";

import { versions } from "../../../versions.js";
import {
CONFIGS_DIR_NAME,
HTTP_PORT_START,
PROVIDER_CONFIG_FULL_FILE_NAME,
TCP_PORT_START,
WEB_SOCKET_PORT_START,
} from "../../const.js";
import { numToStr } from "../../helpers/typesafeStringify.js";
import { pathExists } from "../../helpers/utils.js";
import { genSecretKeyOrReturnExisting } from "../../keyPairs.js";
import { ensureFluenceConfigsDir, getFluenceDir } from "../../paths.js";
import { ensureDockerComposeConfigPath } from "../../paths.js";

import { CHAIN_RPC_CONTAINER_NAME } from "./chainContainers.js";
import { IPFS_CONTAINER_NAME } from "./chainContainers.js";
import { CHAIN_DEPLOY_SCRIPT_NAME } from "./chainContainers.js";
import {
chainContainers,
type Config,
type Service,
} from "./chainContainers.js";
import {
ensureComputerPeerConfigs,
getConfigTomlName,
} from "./provider/provider.js";

type GenNoxImageArgs = {
name: string;
tcpPort: number;
webSocketPort: number;
httpPort: number;
bootstrapName: string;
bootstrapTcpPort?: number;
};

function genNox({
name,
tcpPort,
webSocketPort,
httpPort,
bootstrapName,
bootstrapTcpPort,
}: GenNoxImageArgs): [name: string, service: Service] {
const configTomlName = getConfigTomlName(name);
const configLocation = `/run/${CONFIGS_DIR_NAME}/${configTomlName}`;
const tcpPortString = numToStr(tcpPort);
const websocketPortString = numToStr(webSocketPort);
return [
name,
{
image: versions.nox,
ports: [
`${tcpPortString}:${tcpPortString}`,
`${websocketPortString}:${websocketPortString}`,
],
environment: {
WASM_LOG: "debug",
FLUENCE_MAX_SPELL_PARTICLE_TTL: "30s",
FLUENCE_ROOT_KEY_PAIR__PATH: `/run/secrets/${name}`,
RUST_LOG:
"info,chain_connector=debug,run-console=trace,aquamarine::log=debug,network=trace,worker_inactive=trace,expired=info,spell=debug,ipfs_effector=debug,ipfs_pure=debug,spell_event_bus=trace,system_services=debug,particle_reap=debug,aquamarine::actor=debug,aquamarine::aqua_runtime=off,aquamarine=warn,chain_listener=debug,chain-connector=debug,execution=trace",
},
command: [
`--config=${configLocation}`,
"--dev-mode",
"--external-maddrs",
`/dns4/${name}/tcp/${tcpPortString}`,
`/dns4/${name}/tcp/${websocketPortString}/ws`,
"--allow-private-ips",
bootstrapTcpPort === undefined
? "--local"
: `--bootstraps=/dns/${bootstrapName}/tcp/${numToStr(bootstrapTcpPort)}`,
"--print-config",
],
depends_on: {
[IPFS_CONTAINER_NAME]: { condition: "service_healthy" },
[CHAIN_RPC_CONTAINER_NAME]: { condition: "service_healthy" },
[CHAIN_DEPLOY_SCRIPT_NAME]: {
condition: "service_completed_successfully",
},
},
volumes: [
`./${CONFIGS_DIR_NAME}/${configTomlName}:${configLocation}`,
`${name}:/.fluence`,
],
secrets: [name],
healthcheck: {
test: `curl -f http://localhost:${numToStr(httpPort)}/health`,
interval: "5s",
timeout: "2s",
retries: 10,
},
},
];
}

async function genDefaultDockerCompose(): Promise<Config> {
const configsDir = await ensureFluenceConfigsDir();
const fluenceDir = getFluenceDir();
const computePeers = await ensureComputerPeerConfigs();

const peers = await Promise.all(
computePeers.map(async ({ name, overriddenNoxConfig }) => {
return {
...(await genSecretKeyOrReturnExisting(name)),
webSocketPort: overriddenNoxConfig.websocketPort,
tcpPort: overriddenNoxConfig.tcpPort,
httpPort: overriddenNoxConfig.httpPort,
relativeConfigFilePath: relative(
fluenceDir,
join(configsDir, getConfigTomlName(name)),
),
};
}),
);

const [bootstrap, ...restNoxes] = peers;

assert(
bootstrap !== undefined,
`Unreachable. 'computePeers' non-emptiness is checked during ${PROVIDER_CONFIG_FULL_FILE_NAME} validation`,
);

const {
name: bootstrapName,
webSocketPort: bootstrapWebSocketPort = WEB_SOCKET_PORT_START,
tcpPort: bootstrapTcpPort = TCP_PORT_START,
httpPort: bootstrapHttpPort = HTTP_PORT_START,
} = bootstrap;

return {
volumes: {
...chainContainers.volumes,
...Object.fromEntries(
peers.map(({ name }) => {
return [name, null] as const;
}),
),
},
secrets: Object.fromEntries(
peers.map(({ name, relativeSecretFilePath: file }) => {
return [name, { file }] as const;
}),
),
services: {
...chainContainers.services,
...Object.fromEntries([
genNox({
name: bootstrapName,
tcpPort: bootstrapTcpPort,
webSocketPort: bootstrapWebSocketPort,
httpPort: bootstrapHttpPort,
bootstrapName: bootstrapName,
}),
]),
...Object.fromEntries(
restNoxes.map(({ name, tcpPort, webSocketPort, httpPort }) => {
return genNox({
name,
tcpPort,
webSocketPort,
httpPort,
bootstrapName,
bootstrapTcpPort,
});
}),
),
},
};
}
import { chainContainers } from "./chainContainers.js";

export async function ensureDockerComposeConfig() {
const configPath = await ensureDockerComposeConfigPath();

if (!(await pathExists(configPath))) {
await writeFile(
configPath,
yamlDiffPatch("", {}, await genDefaultDockerCompose()),
);
await writeFile(configPath, yamlDiffPatch("", {}, chainContainers));
}

return configPath;
Expand Down
Loading

0 comments on commit 352a32f

Please sign in to comment.