Skip to content

Commit

Permalink
Merge branch 'master' into NAS-131245
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexKarpov98 committed Nov 21, 2024
2 parents 306c86c + 71a5d2c commit 46160b7
Show file tree
Hide file tree
Showing 500 changed files with 6,716 additions and 4,621 deletions.
29 changes: 26 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,25 @@ jobs:
- name: Run tests
run: yarn test:pr --shard=${{ matrix.shard }}/${{ strategy.job-total }}
- name: Save shard coverage
run: mv coverage/webui/coverage-final.json coverage/${{matrix.shard}}.json && rm -rf coverage/webui
run: |
mv coverage/webui/coverage-final.json coverage/coverage-${{matrix.shard}}.json
mv coverage/webui/junit.xml coverage/junit-${{matrix.shard}}.xml
rm -rf coverage/webui
- name: Upload coverage
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.shard }}
path: coverage/${{matrix.shard}}.json
path: coverage/coverage-${{matrix.shard}}.json
- name: Upload test data
uses: actions/upload-artifact@v4
with:
name: coverage-junit-${{ matrix.shard }}
path: coverage/junit-${{matrix.shard}}.xml

report-coverage:
name: Collect coverage
runs-on: ubuntu-latest
if: ${{ !cancelled() }}
needs: [test]
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
Expand All @@ -87,12 +96,26 @@ jobs:
pattern: 'coverage-*'
path: coverage
merge-multiple: true
- name: Collect test data from shards
uses: actions/download-artifact@v4
with:
pattern: 'junit-*'
path: coverage
merge-multiple: true
- name: Merge Code Coverage
run: npx -y nyc merge coverage/ coverage/merged-coverage.json
- name: Upload to Codecov
- name: Merge Test Data
run: npx -y junit-report-merger coverage/merged-junit.xml "coverage/junit-*.xml"
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
name: webui
token: ${{ env.CODECOV_TOKEN }}
file: coverage/merged-coverage.json
fail_ci_if_error: true
- name: Upload extra test data to Codecov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: coverage/merged-junit.xml
10 changes: 10 additions & 0 deletions jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,15 @@ module.exports = {
transformIgnorePatterns: [
`node_modules/(?!(${esmPatterns.join('|')}))`
],
reporters: [
"default",
[
"jest-junit",
{
classNameTemplate: "{filepath}",
outputDirectory: "<rootDir>/coverage/webui"
},
]
],
clearMocks: true,
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@
"jest": "~29.7.0",
"jest-canvas-mock": "^2.5.0",
"jest-fail-on-console": "~3.3.0",
"jest-junit": "~16.0.0",
"jest-preset-angular": "~14.2.4",
"jest-when": "~3.6.0",
"jira-prepare-commit-msg": "^1.6.1",
Expand Down
2 changes: 2 additions & 0 deletions src/app/enums/dns-authenticator-type.enum.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export enum DnsAuthenticatorType {
Route53 = 'route53',
Cloudflare = 'cloudflare',
Ovh = 'OVH',
Shell = 'shell',
}
2 changes: 1 addition & 1 deletion src/app/enums/virtualization.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export enum VirtualizationType {
Vm = 'VM',
}

export const virtualizationTypeMap = new Map<VirtualizationType, string>([
export const virtualizationTypeLabels = new Map<VirtualizationType, string>([
[VirtualizationType.Container, T('Container')],
[VirtualizationType.Vm, T('VM')],
]);
Expand Down
4 changes: 2 additions & 2 deletions src/app/helpers/get-dynamic-form-schema-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { DynamicFormSchemaType } from 'app/enums/dynamic-form-schema-type.enum';
import { SchemaType } from 'app/enums/schema.enum';
import { toHumanReadableKey } from 'app/helpers/object-keys-to-human-readable.helper';
import { DynamicFormSchemaCheckbox, DynamicFormSchemaInput, DynamicFormSchemaNode } from 'app/interfaces/dynamic-form-schema.interface';
import { Schema } from 'app/interfaces/schema.interface';
import { Schema, SchemaProperties } from 'app/interfaces/schema.interface';

export function getDynamicFormSchemaNode(schema: Schema): DynamicFormSchemaNode {
export function getDynamicFormSchemaNode(schema: SchemaProperties | Schema): DynamicFormSchemaNode {
const baseSchema = {
controlName: schema._name_,
type: DynamicFormSchemaType.Input,
Expand Down
2 changes: 1 addition & 1 deletion src/app/helpers/operators/to-loading-state.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface LoadingState<T> {

/**
* Usage:
* myData$ = this.ws.call('my.method').pipe(toLoadingState());
* myData$ = this.api.call('my.method').pipe(toLoadingState());
*
* <ng-container *ngIf="myData$ | async as data">
* <my-loading-spinner *ngIf="data.isLoading"></my-loading-spinner>
Expand Down
11 changes: 6 additions & 5 deletions src/app/interfaces/api/api-call-directory.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,9 @@ import {
VmDisplayWebUriParams, VmPortWizardResult,
} from 'app/interfaces/virtual-machine.interface';
import {
VirtualizationDevice, VirtualizationGlobalConfig, AvailableGpu,
VirtualizationDevice, VirtualizationGlobalConfig,
VirtualizationImage, VirtualizationImageParams,
VirtualizationInstance, VirtualizationNetwork, AvailableUsb,
VirtualizationInstance, VirtualizationNetwork, AvailableUsb, AvailableGpus,
} from 'app/interfaces/virtualization.interface';
import {
VmDevice, VmDeviceDelete, VmDeviceUpdate, VmDisplayDevice, VmPassthroughDeviceChoice, VmUsbPassthroughDeviceChoice,
Expand Down Expand Up @@ -832,15 +832,16 @@ export interface ApiCallDirectory {

// Virt
'virt.instance.query': { params: QueryParams<VirtualizationInstance>; response: VirtualizationInstance[] };
'virt.instance.device_add': { params: [instanceId: string, device: VirtualizationDevice]; response: void }; // TODO
'virt.instance.device_delete': { params: [instanceId: string, name: string]; response: unknown }; // TODO:
'virt.instance.device_add': { params: [instanceId: string, device: VirtualizationDevice]; response: true };
'virt.instance.device_update': { params: [instanceId: string, device: VirtualizationDevice]; response: true };
'virt.instance.device_delete': { params: [instanceId: string, name: string]; response: true };
'virt.instance.device_list': { params: [instanceId: string]; response: VirtualizationDevice[] };
'virt.instance.image_choices': { params: [VirtualizationImageParams]; response: Record<string, VirtualizationImage> };

'virt.device.disk_choices': { params: []; response: Choices };
'virt.device.gpu_choices': {
params: [instanceType: VirtualizationType, gpuType: VirtualizationGpuType];
response: Record<string, AvailableGpu>;
response: AvailableGpus;
};
'virt.device.usb_choices': { params: []; response: Record<string, AvailableUsb> };

Expand Down
3 changes: 2 additions & 1 deletion src/app/interfaces/api/api-event-directory.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { SmartTestProgressUpdate } from 'app/interfaces/smart-test-progress.inte
import { TrueCommandConfig } from 'app/interfaces/true-command-config.interface';
import { User } from 'app/interfaces/user.interface';
import { VirtualMachine } from 'app/interfaces/virtual-machine.interface';
import { VirtualizationGlobalConfig, VirtualizationInstance } from 'app/interfaces/virtualization.interface';
import { VirtualizationGlobalConfig, VirtualizationInstance, VirtualizationInstanceMetrics } from 'app/interfaces/virtualization.interface';
import { ZfsSnapshot } from 'app/interfaces/zfs-snapshot.interface';

export interface ApiEventDirectory {
Expand All @@ -43,6 +43,7 @@ export interface ApiEventDirectory {
'truecommand.config': { response: TrueCommandConfig };
'user.query': { response: User };
'virt.instance.query': { response: VirtualizationInstance };
'virt.instance.metrics': { response: VirtualizationInstanceMetrics };
'virt.instance.agent_running': { response: unknown }; // TODO: Fix type
'vm.query': { response: VirtualMachine };
'zfs.pool.scan': { response: PoolScan };
Expand Down
4 changes: 2 additions & 2 deletions src/app/interfaces/api/api-job-directory.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ export interface ApiJobDirectory {
// Virt
'virt.instance.create': { params: [CreateVirtualizationInstance]; response: VirtualizationInstance };
'virt.instance.delete': { params: [instanceId: string]; response: boolean };
'virt.instance.restart': { params: VirtualizationStopParams; response: boolean };
'virt.instance.restart': { params: [instanceId: string, params: VirtualizationStopParams]; response: boolean };
'virt.instance.start': { params: [instanceId: string]; response: boolean };
'virt.instance.stop': { params: VirtualizationStopParams; response: boolean };
'virt.instance.stop': { params: [instanceId: string, params: VirtualizationStopParams]; response: boolean };
'virt.instance.update': {
params: [instanceId: string, update: UpdateVirtualizationInstance];
response: VirtualizationInstance;
Expand Down
28 changes: 4 additions & 24 deletions src/app/interfaces/dns-authenticator.interface.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,16 @@
import { DnsAuthenticatorType } from 'app/enums/dns-authenticator-type.enum';
import { Schema } from 'app/interfaces/schema.interface';

export type DnsAuthenticator = CloudflareDnsAuthenticator | Route53DnsAuthenticator;

export interface CloudflareDnsAuthenticator {
id: number;
name: string;
authenticator: DnsAuthenticatorType.Cloudflare;
attributes: {
// Either
api_token?: string;

// Or
cloudflare_email?: string;
api_key?: string;
};
}

export interface Route53DnsAuthenticator {
export interface DnsAuthenticator {
id: number;
name: string;
authenticator: DnsAuthenticatorType.Route53;
attributes: {
access_key_id: string;
secret_access_key: string;
};
attributes: Record<string, string>;
}

export interface AuthenticatorSchema {
key: DnsAuthenticatorType;
schema: Schema[];
schema: Schema;
}

export type CreateDnsAuthenticator = Omit<DnsAuthenticator, 'id'>;
export type UpdateDnsAuthenticator = Omit<DnsAuthenticator, 'id' | 'authenticator'>;
export type UpdateDnsAuthenticator = Omit<DnsAuthenticator, 'id'>;
18 changes: 17 additions & 1 deletion src/app/interfaces/schema.interface.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
import { SchemaType } from 'app/enums/schema.enum';

export interface Schema {
export type Schema = {
properties: Record<string, SchemaProperties>;
} & OldSchema;

/**
* @deprecated Remove after "reporting.exporters.exporter_schemas" refactoring.
*/
export interface OldSchema {
title: string;
type: SchemaType | SchemaType[];
_name_: string;
_required_: boolean;

}

export interface SchemaProperties {
title: string;
description?: string;
type: SchemaType | SchemaType[];
_name_: string;
_required_: boolean;
Expand Down
12 changes: 0 additions & 12 deletions src/app/interfaces/shell-details-dialog.interface.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/app/interfaces/terminal.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Observable, Subject } from 'rxjs';
export interface TerminalConfiguration {
reconnectShell$?: Subject<void>;
preInit?(): Observable<void>;
customReconnectAction?(): void;
connectionData: TerminalConnectionData;
}

Expand Down
28 changes: 21 additions & 7 deletions src/app/interfaces/virtualization.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ import {
VirtualizationType,
} from 'app/enums/virtualization.enum';

export interface VirtualizationInstanceMetrics {
cpu: {
cpu_user_percentage: number;
};
mem_usage: {
mem_usage_ram_mib: number;
};
io_full_pressure: {
io_full_pressure_full_60_percentage: number;
};
}

export interface VirtualizationInstance {
id: string;
name: string;
Expand Down Expand Up @@ -135,13 +147,10 @@ export interface VirtualizationImage {
variant: string;
}

export type VirtualizationStopParams = [
instanceId: string,
{
timeout?: number;
force?: boolean;
},
];
export interface VirtualizationStopParams {
timeout?: number;
force?: boolean;
}

export interface VirtualizationGlobalConfigUpdate {
pool: string;
Expand Down Expand Up @@ -180,6 +189,11 @@ export interface AvailableGpu {
vendor: string | null;
}

// eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style
export interface AvailableGpus {
[pci: string]: AvailableGpu;
}

export interface AvailableUsb {
vendor_id: string;
product_id: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const dummyAlert = {

describe('AlertComponent', () => {
let spectator: Spectator<AlertComponent>;
let websocket: ApiService;
let api: ApiService;
let alert: AlertPageObject;
const createComponent = createComponentFactory({
component: AlertComponent,
Expand Down Expand Up @@ -71,7 +71,7 @@ describe('AlertComponent', () => {
},
});

websocket = spectator.inject(ApiService);
api = spectator.inject(ApiService);
alert = new AlertPageObject(spectator);
});

Expand Down Expand Up @@ -103,7 +103,7 @@ describe('AlertComponent', () => {
it('dismisses an open alert when Dismiss link is pressed', async () => {
alert.clickDismissLink();

expect(websocket.call).toHaveBeenCalledWith('alert.dismiss', ['79']);
expect(api.call).toHaveBeenCalledWith('alert.dismiss', ['79']);

const state = await firstValueFrom(spectator.inject(Store).pipe(map(selectAlerts)));
expect(state).toEqual([
Expand All @@ -122,7 +122,7 @@ describe('AlertComponent', () => {

alert.clickReopenLink();

expect(websocket.call).toHaveBeenCalledWith('alert.restore', ['79']);
expect(api.call).toHaveBeenCalledWith('alert.restore', ['79']);

const state = await firstValueFrom(spectator.inject(Store).pipe(map(selectAlerts)));
expect(state).toEqual([dummyAlert]);
Expand Down
Loading

0 comments on commit 46160b7

Please sign in to comment.