Skip to content

Commit

Permalink
Add actions and main.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
ksendart authored and Ksenya Arysheva committed Nov 15, 2023
1 parent b9769f1 commit a795dba
Show file tree
Hide file tree
Showing 21 changed files with 648 additions and 71 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: savant-github-actions
on: [push]
jobs:
check-packages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: '16'
- run: npm install
lint:
runs-on: ubuntu-latest
steps:
- name: Base checkout
uses: actions/checkout@v4
- name: Base node
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Install dependencies
run: npm install
- name: Linting
run: npm run lint
test:
runs-on: ubuntu-latest
steps:
- name: Base checkout
uses: actions/checkout@v4
- name: Base node
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Install dependencies
run: npm install
- name: Testing
run: npm run test
7 changes: 3 additions & 4 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
"zone.js/testing"
],
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"inlineStyleLanguage": "scss",
"assets": [
"src/favicon.ico",
Expand Down Expand Up @@ -142,11 +143,9 @@
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "projects/savant-lib/src/test.ts",
"tsConfig": "projects/savant-lib/tsconfig.spec.json",
"polyfills": [
"zone.js",
"zone.js/testing"
]
"karmaConfig": "projects/savant-lib/karma.conf.js"
}
},
"lint": {
Expand Down
58 changes: 58 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html

module.exports = function (config) {
config.set({
basePath: 'src',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-spec-reporter'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage'),
require('@angular-devkit/build-angular/plugins/karma')
],
browsers: ['ChromeHeadlessNoSandbox'],
client: {
jasmine: {
// you can add configuration options for Jasmine here
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
// for example, you can disable the random execution with `random: false`
// or set a specific seed with `seed: 4321`
},
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
jasmineHtmlReporter: {
suppressAll: true // removes the duplicated traces
},
coverageReporter: {
dir: require('path').join(__dirname, '../../coverage/savant'),
subdir: '.',
reporters: [
{ type: 'html' },
{ type: 'text-summary' }
]
},
customLaunchers: {
ChromeHeadlessNoSandbox: {
base: 'ChromeHeadless',
flags: [
'--headless',
'--disable-gpu',
'--no-sandbox'
]
},
},
reporters: ['progress', 'spec', 'kjhtml'],
specReporter: {
suppressSkipped: true,
},
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
singleRun: true,
restartOnFileChange: true
});
};
38 changes: 38 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.1.0",
"karma-spec-reporter": "^0.0.36",
"ng-mocks": "^14.11.0",
"ng-packagr": "^16.2.0",
"typescript": "~5.1.3"
}
Expand Down
58 changes: 58 additions & 0 deletions projects/savant-lib/karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html

module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-spec-reporter'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage'),
require('@angular-devkit/build-angular/plugins/karma')
],
browsers: ['ChromeHeadlessNoSandbox'],
client: {
jasmine: {
// you can add configuration options for Jasmine here
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
// for example, you can disable the random execution with `random: false`
// or set a specific seed with `seed: 4321`
},
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
jasmineHtmlReporter: {
suppressAll: true // removes the duplicated traces
},
coverageReporter: {
dir: require('path').join(__dirname, '../../coverage/savant-lib'),
subdir: '.',
reporters: [
{ type: 'html' },
{ type: 'text-summary' }
]
},
customLaunchers: {
ChromeHeadlessNoSandbox: {
base: 'ChromeHeadless',
flags: [
'--headless',
'--disable-gpu',
'--no-sandbox'
]
},
},
reporters: ['progress', 'spec', 'kjhtml'],
specReporter: {
suppressSkipped: true,
},
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
singleRun: true,
restartOnFileChange: true
});
};
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { FrameContainerComponent } from './frame-container.component';
import { MockComponent, MockModule } from 'ng-mocks';
import { FrameTreeComponent } from '../frame-tree/frame-tree.component';
import { SharedModule } from '../../../utils';

describe('FrameContainerComponent', () => {
let component: FrameContainerComponent;
let fixture: ComponentFixture<FrameContainerComponent>;

beforeEach(() => {
TestBed.configureTestingModule({
declarations: [FrameContainerComponent]
declarations: [FrameContainerComponent, MockComponent(FrameTreeComponent)],
imports: [
MockModule(SharedModule),
],
});
fixture = TestBed.createComponent(FrameContainerComponent);
component = fixture.componentInstance;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { FrameDetailsComponent } from './frame-details.component';
import { MatSnackBarModule } from '@angular/material/snack-bar';
import { MockComponent } from 'ng-mocks';
import { FrameTreeComponent } from '../frame-tree/frame-tree.component';
import { frame } from '../../../../../../src/app/api/models/data';
import { SharedModule } from '../../../utils';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { MatExpansionModule } from '@angular/material/expansion';

describe('FrameDetailsComponent', () => {
let component: FrameDetailsComponent;
let fixture: ComponentFixture<FrameDetailsComponent>;

beforeEach(() => {
TestBed.configureTestingModule({
declarations: [FrameDetailsComponent]
declarations: [FrameDetailsComponent, MockComponent(FrameTreeComponent)],
imports: [
MatSnackBarModule,
SharedModule,
BrowserAnimationsModule,
MatExpansionModule,
]
});
fixture = TestBed.createComponent(FrameDetailsComponent);
component = fixture.componentInstance;
fixture.componentInstance.frame = frame
fixture.detectChanges();
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { ObjectDetailsComponent } from './object-details.component';
import { MatSnackBarModule } from '@angular/material/snack-bar';
import { object } from '../../../../../../src/app/api/models/data';
import { SharedModule } from '../../../utils';
import { MatExpansionModule } from '@angular/material/expansion';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

describe('ObjectDetailsComponent', () => {
let component: ObjectDetailsComponent;
let fixture: ComponentFixture<ObjectDetailsComponent>;

beforeEach(() => {
TestBed.configureTestingModule({
declarations: [ObjectDetailsComponent]
declarations: [ObjectDetailsComponent],
imports: [
MatSnackBarModule,
SharedModule,
MatExpansionModule,
BrowserAnimationsModule,
],
});
fixture = TestBed.createComponent(ObjectDetailsComponent);
component = fixture.componentInstance;
fixture.componentInstance.frameObject = object;
fixture.detectChanges();
});

Expand Down
15 changes: 15 additions & 0 deletions projects/savant-lib/src/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// This file is required by karma.conf.js and loads recursively all the .spec and framework files

import 'zone.js';
import 'zone.js/testing';
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';

// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting(),
);
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { LogFilterComponent } from './log-filter.component';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatSelectModule } from '@angular/material/select';
import { MatInputModule } from '@angular/material/input';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { MockComponent } from 'ng-mocks';
import { SpanSelectorComponent } from '../span-selector/span-selector.component';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';

describe('LogFilterComponent', () => {
let component: LogFilterComponent;
let fixture: ComponentFixture<LogFilterComponent>;

beforeEach(() => {
TestBed.configureTestingModule({
declarations: [LogFilterComponent]
declarations: [LogFilterComponent, MockComponent(SpanSelectorComponent)],
imports: [
MatFormFieldModule,
MatSelectModule,
MatInputModule,
BrowserAnimationsModule,
FormsModule,
ReactiveFormsModule,
]
});
fixture = TestBed.createComponent(LogFilterComponent);
component = fixture.componentInstance;
Expand Down
Loading

0 comments on commit a795dba

Please sign in to comment.