Skip to content

Commit 9439538

Browse files
committed
Merge branch 'refs/heads/main' into 01700-add-dependency-injections-to-all-remaining-command-classes
# Conflicts: # src/commands/base.ts # src/commands/relay.ts # src/core/dependency-injection/container-init.ts # src/index.ts # test/e2e/integration/commands/init.test.ts # test/unit/commands/cluster.test.ts # test/unit/commands/network.test.ts
2 parents 04baf10 + 61f369c commit 9439538

File tree

86 files changed

+5060
-465
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+5060
-465
lines changed

.github/workflows/zxc-code-analysis.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,13 @@ jobs:
285285
name: Unit Test Coverage Report
286286
path: 'coverage/unit'
287287

288+
- name: Download HelmClient Unit Test Coverage Report
289+
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
290+
if: ${{ (inputs.enable-codecov-analysis || inputs.enable-codacy-coverage) && !cancelled() && !failure() }}
291+
with:
292+
name: Unit Test Coverage Report
293+
path: 'coverage/unit-helm'
294+
288295
- name: Download E2E Integration Coverage Report
289296
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
290297
if: ${{ (inputs.enable-codecov-analysis || inputs.enable-codacy-coverage) && inputs.enable-e2e-coverage-report && !cancelled() && !failure() }}

.github/workflows/zxc-unit-test.yaml

+28
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,27 @@ jobs:
7878
- name: Run Unit Tests
7979
run: npm test
8080

81+
- name: Setup Helm
82+
uses: azure/setup-helm@b9e51907a09c216f16ebe8536097933489208112 # v4.3.0
83+
if: ${{ runner.os == 'linux' }}
84+
with:
85+
version: "v3.12.3" # helm version
86+
87+
- name: Setup Kind
88+
uses: helm/kind-action@a1b0e391336a6ee6713a0583f8c6240d70863de3 # v1.12.0
89+
if: ${{ runner.os == 'linux' }}
90+
with:
91+
install_only: true
92+
node_image: kindest/node:v1.31.4@sha256:2cb39f7295fe7eafee0842b1052a599a4fb0f8bcf3f83d96c7f4864c357c6c30
93+
version: v0.26.0
94+
kubectl_version: v1.31.4
95+
verbosity: 3
96+
wait: 120s
97+
98+
- name: Run Helm Client Unit Tests
99+
if: ${{ runner.os == 'linux' }}
100+
run: npm run test-helm
101+
81102
- name: Publish Windows Unit Test Report
82103
uses: EnricoMi/publish-unit-test-result-action/windows/bash@170bf24d20d201b842d7a52403b73ed297e6645b # v2.18.0
83104
if: ${{ runner.os == 'Windows' && steps.npm-deps.conclusion == 'success' && !cancelled() }}
@@ -99,6 +120,13 @@ jobs:
99120
name: Unit Test Coverage Report
100121
path: 'coverage/unit'
101122

123+
- name: Publish HelmClient Unit Test Coverage Report
124+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
125+
if: ${{ runner.os == 'linux' && !cancelled() }}
126+
with:
127+
name: HelmClient Unit Test Coverage Report
128+
path: 'coverage/unit-helm'
129+
102130
- name: Publish Test Reports
103131
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
104132
if: ${{ runner.os == 'linux' && steps.npm-deps.conclusion == 'success' && !cancelled() }}

.github/workflows/zxc-update-readme.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ jobs:
7878
sudo apt-get update
7979
sudo apt-get install -y wget
8080
81+
- name: Setup Helm
82+
uses: azure/setup-helm@b9e51907a09c216f16ebe8536097933489208112 # v4.3.0
83+
with:
84+
version: "v3.12.3" # helm version
85+
8186
- name: Setup Kind
8287
uses: helm/kind-action@a1b0e391336a6ee6713a0583f8c6240d70863de3 # v1.12.0
8388
with:

Taskfile.helper.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ tasks:
315315
deps:
316316
- task: "init"
317317
cmds:
318-
- SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- relay destroy -n "${SOLO_NAMESPACE}" -i node1 -q --dev
318+
- SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- relay destroy --deployment "${SOLO_DEPLOYMENT}" -i node1 -q --dev
319319

320320
solo:cache:remove:
321321
silent: true

eslint.config.mjs

+17-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,23 @@ export default [
131131
'@typescript-eslint/no-warning-comments': 'off',
132132
'@typescript-eslint/no-empty-function': 'off',
133133
'@typescript-eslint/no-var-requires': 'off',
134-
'@typescript-eslint/explicit-function-return-type': 'off',
134+
'@typescript-eslint/explicit-function-return-type': [
135+
'warn',
136+
{
137+
allowExpressions: false,
138+
allowTypedFunctionExpressions: false,
139+
allowHigherOrderFunctions: false,
140+
},
141+
],
142+
'@typescript-eslint/typedef': [
143+
'warn',
144+
{
145+
variableDeclaration: true,
146+
parameter: true,
147+
propertyDeclaration: true,
148+
memberVariableDeclaration: true,
149+
},
150+
],
135151
'@typescript-eslint/explicit-module-boundary-types': 'off',
136152
'@typescript-eslint/ban-types': 'off',
137153
'@typescript-eslint/camelcase': 'off',

package-lock.json

+6-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"access": "public"
1212
},
1313
"scripts": {
14-
"test": "cross-env MOCHA_SUITE_NAME=\"Unit Tests\" c8 --report-dir='coverage/unit' mocha 'test/unit/**/*.ts' --reporter-options configFile=mocha-multi-reporter.json,cmrOutput=mocha-junit-reporter+mochaFile+junit.xml",
14+
"test": "cross-env MOCHA_SUITE_NAME=\"Unit Tests\" c8 --report-dir='coverage/unit' mocha 'test/unit/**/*.ts' --exclude 'test/unit/core/helm/**/*.ts' --reporter-options configFile=mocha-multi-reporter.json,cmrOutput=mocha-junit-reporter+mochaFile+junit.xml",
15+
"test-helm": "cross-env MOCHA_SUITE_NAME=\"Helm Unit Tests\" c8 --report-dir='coverage/unit-helm' mocha 'test/unit/core/helm/**/*.ts' --reporter-options configFile=mocha-multi-reporter.json,cmrOutput=mocha-junit-reporter+mochaFile+junit.xml",
1516
"test-mathex": "cross-env MOCHA_SUITE_NAME=\"MathEx Unit Tests\" c8 --report-dir='coverage/unit-mathex' mocha 'test/unit/**/math-ex*.ts' --reporter-options configFile=mocha-multi-reporter.json,cmrOutput=mocha-junit-reporter+mochaFile+junit.xml",
1617
"test-data": "cross-env MOCHA_SUITE_NAME=\"Data Layer Unit Tests\" c8 --report-dir='coverage/unit-data' mocha 'test/unit/data/**' --reporter-options configFile=mocha-multi-reporter.json,cmrOutput=mocha-junit-reporter+mochaFile+junit.xml",
1718
"test-e2e-all": "cross-env MOCHA_SUITE_NAME=\"Mocha E2E All Tests\" c8 --report-dir='coverage/e2e-all' mocha 'test/e2e/**/*.ts' --reporter-options configFile=mocha-multi-reporter.json,cmrOutput=mocha-junit-reporter+mochaFile+junit-e2e-all.xml",
@@ -99,7 +100,7 @@
99100
"@types/mocha": "^10.0.10",
100101
"@types/mocha-each": "^2.0.4",
101102
"@types/node": "^22.13.14",
102-
"@types/semver": "^7.5.8",
103+
"@types/semver": "^7.7.0",
103104
"@types/sinon": "^17.0.4",
104105
"@types/sinon-chai": "^4.0.0",
105106
"@types/stream-buffers": "^3.0.7",

src/commands/base.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import {ShellRunner} from '../core/shell-runner.js';
55
import {type LockManager} from '../core/lock/lock-manager.js';
66
import {type LocalConfig} from '../core/config/local/local-config.js';
77
import {type RemoteConfigManager} from '../core/config/remote/remote-config-manager.js';
8-
import {type Helm} from '../core/helm.js';
9-
import {type K8Factory} from '../integration/kube/k8-factory.js';
108
import {type ChartManager} from '../core/chart-manager.js';
119
import {type ConfigManager} from '../core/config-manager.js';
1210
import {type DependencyManager} from '../core/dependency-managers/index.js';
11+
import {type K8Factory} from '../integration/kube/k8-factory.js';
12+
import {type HelmClient} from '../integration/helm/helm-client.js';
1313
import * as constants from '../core/constants.js';
1414
import fs from 'fs';
1515
import {type ClusterRef, type ClusterRefs} from '../core/config/remote/types.js';
@@ -21,7 +21,7 @@ import {InjectTokens} from '../core/dependency-injection/inject-tokens.js';
2121

2222
export abstract class BaseCommand extends ShellRunner {
2323
constructor(
24-
@inject(InjectTokens.Helm) protected readonly helm?: Helm,
24+
@inject(InjectTokens.Helm) protected readonly helm?: HelmClient,
2525
@inject(InjectTokens.K8Factory) protected readonly k8Factory?: K8Factory,
2626
@inject(InjectTokens.ChartManager) protected readonly chartManager?: ChartManager,
2727
@inject(InjectTokens.ConfigManager) public readonly configManager?: ConfigManager,

src/commands/cluster/config-interfaces/cluster-ref-setup-config-class.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {type NamespaceName} from '../../../integration/kube/resources/namespace/
44
import {type ClusterRef} from '../../../core/config/remote/types.js';
55

66
export interface ClusterRefSetupConfigClass {
7-
chartDir: string;
7+
chartDirectory: string;
88
clusterSetupNamespace: NamespaceName;
99
deployMinio: boolean;
1010
deployPrometheusStack: boolean;

src/commands/cluster/config-interfaces/cluster-ref-setup-context.ts

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {type ClusterRefSetupConfigClass} from './cluster-ref-setup-config-class.
44

55
export interface ClusterRefSetupContext {
66
config: ClusterRefSetupConfigClass;
7-
chartPath: string;
87
isChartInstalled: boolean;
98
valuesArg: string;
109
context: string;

src/commands/cluster/configs.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export class ClusterCommandConfigs {
103103
]);
104104

105105
ctx.config = {
106-
chartDir: configManager.getFlag(flags.chartDirectory),
106+
chartDirectory: configManager.getFlag(flags.chartDirectory),
107107
clusterSetupNamespace: configManager.getFlag<NamespaceName>(flags.clusterSetupNamespace),
108108
deployMinio: configManager.getFlag<boolean>(flags.deployMinio),
109109
deployPrometheusStack: configManager.getFlag<boolean>(flags.deployPrometheusStack),

src/commands/cluster/tasks.ts

+7-17
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import {Flags as flags} from '../flags.js';
44
import {type ArgvStruct, type AnyListrContext, type ConfigBuilder} from '../../types/aliases.js';
5-
import {prepareChartPath, showVersionBanner} from '../../core/helpers.js';
5+
import {showVersionBanner} from '../../core/helpers.js';
66
import * as constants from '../../core/constants.js';
77
import chalk from 'chalk';
88
import {ListrLock} from '../../core/lock/listr-lock.js';
@@ -21,7 +21,6 @@ import {patchInject} from '../../core/dependency-injection/container-helper.js';
2121
import {type SoloLogger} from '../../core/logging/solo-logger.js';
2222
import {type ChartManager} from '../../core/chart-manager.js';
2323
import {type LockManager} from '../../core/lock/lock-manager.js';
24-
import {type Helm} from '../../core/helm.js';
2524
import {type ClusterChecks} from '../../core/cluster-checks.js';
2625
import {container} from 'tsyringe-neo';
2726
import {InjectTokens} from '../../core/dependency-injection/inject-tokens.js';
@@ -42,14 +41,12 @@ export class ClusterCommandTasks {
4241
@inject(InjectTokens.SoloLogger) private readonly logger: SoloLogger,
4342
@inject(InjectTokens.ChartManager) private readonly chartManager: ChartManager,
4443
@inject(InjectTokens.LockManager) private readonly leaseManager: LockManager,
45-
@inject(InjectTokens.Helm) private readonly helm: Helm,
4644
) {
4745
this.k8Factory = patchInject(k8Factory, InjectTokens.K8Factory, this.constructor.name);
4846
this.localConfig = patchInject(localConfig, InjectTokens.LocalConfig, this.constructor.name);
4947
this.logger = patchInject(logger, InjectTokens.SoloLogger, this.constructor.name);
5048
this.chartManager = patchInject(chartManager, InjectTokens.ChartManager, this.constructor.name);
5149
this.leaseManager = patchInject(leaseManager, InjectTokens.LockManager, this.constructor.name);
52-
this.helm = patchInject(helm, InjectTokens.Helm, this.constructor.name);
5350
}
5451

5552
public connectClusterRef(): SoloListrTask<ClusterRefConnectContext> {
@@ -114,16 +111,16 @@ export class ClusterCommandTasks {
114111
/**
115112
* Prepare values arg for cluster setup command
116113
*
117-
* @param [chartDir] - local charts directory (default is empty)
114+
* @param chartDirectory
118115
* @param [prometheusStackEnabled] - a bool to denote whether to install prometheus stack
119116
* @param [minioEnabled] - a bool to denote whether to install minio
120117
*/
121118
private prepareValuesArg(
122-
chartDir = flags.chartDirectory.definition.defaultValue as string,
119+
chartDirectory = flags.chartDirectory.definition.defaultValue as string,
123120
prometheusStackEnabled = flags.deployPrometheusStack.definition.defaultValue as boolean,
124121
minioEnabled = flags.deployMinio.definition.defaultValue as boolean,
125122
): string {
126-
let valuesArg = chartDir ? `-f ${PathEx.join(chartDir, 'solo-cluster-setup', 'values.yaml')}` : '';
123+
let valuesArg = chartDirectory ? `-f ${PathEx.join(chartDirectory, 'solo-cluster-setup', 'values.yaml')}` : '';
127124

128125
valuesArg += ` --set cloud.prometheusStack.enabled=${prometheusStackEnabled}`;
129126
valuesArg += ` --set cloud.minio.enabled=${minioEnabled}`;
@@ -208,13 +205,6 @@ export class ClusterCommandTasks {
208205
return {
209206
title: 'Prepare chart values',
210207
task: async ctx => {
211-
ctx.chartPath = await prepareChartPath(
212-
this.helm,
213-
ctx.config.chartDir,
214-
constants.SOLO_TESTING_CHART_URL,
215-
constants.SOLO_CLUSTER_SETUP_CHART,
216-
);
217-
218208
// if minio is already present, don't deploy it
219209
if (ctx.config.deployMinio && (await self.clusterChecks.isMinioInstalled(ctx.config.clusterSetupNamespace))) {
220210
ctx.config.deployMinio = false;
@@ -235,7 +225,7 @@ export class ClusterCommandTasks {
235225
}
236226

237227
ctx.valuesArg = this.prepareValuesArg(
238-
ctx.config.chartDir,
228+
ctx.config.chartDirectory,
239229
ctx.config.deployPrometheusStack,
240230
ctx.config.deployMinio,
241231
);
@@ -254,11 +244,11 @@ export class ClusterCommandTasks {
254244
const valuesArg = ctx.valuesArg;
255245

256246
try {
257-
this.logger.debug(`Installing chart chartPath = ${ctx.chartPath}, version = ${version}`);
258247
await this.chartManager.install(
259248
clusterSetupNamespace,
260249
constants.SOLO_CLUSTER_SETUP_CHART,
261-
ctx.chartPath,
250+
constants.SOLO_CLUSTER_SETUP_CHART,
251+
ctx.config.chartDirectory ? ctx.config.chartDirectory : constants.SOLO_TESTING_CHART_URL,
262252
version,
263253
valuesArg,
264254
ctx.config.context,

src/commands/explorer.ts

+12-21
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ import {type AnyYargs, type ArgvStruct} from '../types/aliases.js';
1414
import {ListrLock} from '../core/lock/listr-lock.js';
1515
import {ComponentType} from '../core/config/remote/enumerations.js';
1616
import {MirrorNodeExplorerComponent} from '../core/config/remote/components/mirror-node-explorer-component.js';
17-
import {prepareChartPath, prepareValuesFiles, showVersionBanner} from '../core/helpers.js';
17+
import {prepareValuesFiles, showVersionBanner} from '../core/helpers.js';
1818
import {type Optional, type SoloListrTask} from '../types/index.js';
1919
import {resolveNamespaceFromDeployment} from '../core/resolvers.js';
2020
import {NamespaceName} from '../integration/kube/resources/namespace/namespace-name.js';
2121
import {type ClusterChecks} from '../core/cluster-checks.js';
2222
import {container, inject, injectable} from 'tsyringe-neo';
2323
import {InjectTokens} from '../core/dependency-injection/inject-tokens.js';
24-
import {INGRESS_CONTROLLER_NAME} from '../core/constants.js';
24+
import {HEDERA_EXPLORER_CHART_URL, INGRESS_CONTROLLER_NAME} from '../core/constants.js';
2525
import {INGRESS_CONTROLLER_VERSION} from '../../version.js';
2626
import {patchInject} from '../core/dependency-injection/container-helper.js';
2727
import * as helpers from '../core/helpers.js';
@@ -76,6 +76,7 @@ export class ExplorerCommand extends BaseCommand {
7676
private static readonly DEPLOY_FLAGS_LIST = {
7777
required: [],
7878
optional: [
79+
flags.cacheDir,
7980
flags.chartDirectory,
8081
flags.clusterRef,
8182
flags.enableIngress,
@@ -232,14 +233,7 @@ export class ExplorerCommand extends BaseCommand {
232233
title: 'Install cert manager',
233234
task: async ctx => {
234235
const config = ctx.config;
235-
const {chartDirectory, soloChartVersion} = config;
236-
237-
const chartPath = await prepareChartPath(
238-
self.helm,
239-
chartDirectory,
240-
constants.SOLO_TESTING_CHART_URL,
241-
constants.SOLO_CERT_MANAGER_CHART,
242-
);
236+
const {soloChartVersion} = config;
243237

244238
const soloCertManagerValuesArg = await self.prepareCertManagerChartValuesArg(config);
245239
// check if CRDs of cert-manager are already installed
@@ -259,7 +253,8 @@ export class ExplorerCommand extends BaseCommand {
259253
await self.chartManager.install(
260254
NamespaceName.of(constants.CERT_MANAGER_NAME_SPACE),
261255
constants.SOLO_CERT_MANAGER_CHART,
262-
chartPath,
256+
constants.SOLO_CERT_MANAGER_CHART,
257+
ctx.config.chartDirectory ? ctx.config.chartDirectory : constants.SOLO_TESTING_CHART_URL,
263258
soloChartVersion,
264259
' --set cert-manager.installCRDs=true',
265260
ctx.config.clusterContext,
@@ -287,7 +282,8 @@ export class ExplorerCommand extends BaseCommand {
287282
await self.chartManager.upgrade(
288283
NamespaceName.of(constants.CERT_MANAGER_NAME_SPACE),
289284
constants.SOLO_CERT_MANAGER_CHART,
290-
chartPath,
285+
constants.SOLO_CERT_MANAGER_CHART,
286+
ctx.config.chartDirectory ? ctx.config.chartDirectory : constants.SOLO_TESTING_CHART_URL,
291287
soloChartVersion,
292288
soloCertManagerValuesArg,
293289
ctx.config.clusterContext,
@@ -308,7 +304,8 @@ export class ExplorerCommand extends BaseCommand {
308304
await self.chartManager.install(
309305
config.namespace,
310306
constants.HEDERA_EXPLORER_RELEASE_NAME,
311-
constants.HEDERA_EXPLORER_CHART_URL,
307+
'',
308+
HEDERA_EXPLORER_CHART_URL,
312309
config.hederaExplorerVersion,
313310
exploreValuesArg,
314311
ctx.config.clusterContext,
@@ -328,17 +325,11 @@ export class ExplorerCommand extends BaseCommand {
328325
}
329326
explorerIngressControllerValuesArg += ` --set fullnameOverride=${constants.EXPLORER_INGRESS_CONTROLLER}`;
330327

331-
const ingressControllerChartPath = await prepareChartPath(
332-
self.helm,
333-
'', // don't use chartPath which is for local solo-charts only
334-
constants.INGRESS_CONTROLLER_RELEASE_NAME,
335-
constants.INGRESS_CONTROLLER_RELEASE_NAME,
336-
);
337-
338328
await self.chartManager.install(
339329
config.namespace,
340330
constants.INGRESS_CONTROLLER_RELEASE_NAME,
341-
ingressControllerChartPath,
331+
constants.INGRESS_CONTROLLER_RELEASE_NAME,
332+
constants.INGRESS_CONTROLLER_RELEASE_NAME,
342333
INGRESS_CONTROLLER_VERSION,
343334
explorerIngressControllerValuesArg,
344335
ctx.config.clusterContext,

0 commit comments

Comments
 (0)