Skip to content

Commit

Permalink
fix: workflows and spec files (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbystedt authored Sep 20, 2023
1 parent ae63927 commit 4e37508
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 54 deletions.
65 changes: 38 additions & 27 deletions .github/workflows/pr-open.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ jobs:
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Log in to the Container registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Backend Docker image
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: ./
push: true
Expand All @@ -56,37 +56,27 @@ jobs:
REPO_LOCATION=
tests-backend:
name: Backend Unit Tests
name: Backend Tests
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Get npm cache directory
id: npm-cache-dir-backend
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v3
id: npm-cache-backend # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
- name: Use Node.js
uses: actions/setup-node@v3
with:
path: ${{ steps.npm-cache-dir-backend.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Cache for test results
id: cache-backend
uses: actions/cache@v3
with:
path: coverage
key: backend-coverage-${{ github.run_number }}
restore-keys: |
backend-coverage-
node-version: 18
cache: 'npm'

- name: npm ci
run: npm ci

- name: lint
if: ${{ github.actor != 'dependabot[bot]' }}
run: npm run lint

- name: Tests
run: |
npm ci
npm run test:cov
- name: unit test
run: npm run test:cov

- name: Report code coverage
if: ${{ github.actor != 'dependabot[bot]' }}
Expand All @@ -96,3 +86,24 @@ jobs:
delete-old-comments: true
github-token: ${{ secrets.GITHUB_TOKEN }}
lcov-file: ./coverage/lcov.info

# tests-frontend:
# name: Frontend Tests
# runs-on: ubuntu-latest
# steps:
# - name: Checkout repository
# uses: actions/checkout@v3

# - name: Use Node.js
# uses: actions/setup-node@v3
# with:
# node-version: 18
# cache: 'npm'

# - name: npm ci
# run: npm ci
# working-directory: ./ui

# - name: unit test
# run: npm run test
# working-directory: ./ui
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Main Merge
name: Tag Main

on:
push:
Expand Down Expand Up @@ -49,8 +49,8 @@ jobs:
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2

build-backend:
name: Backend Image Build
build-image:
name: Build Image
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -66,21 +66,19 @@ jobs:
images: ${{ secrets.ARTIFACTORY_REGISTRY }}/${{ github.repository }}-backend

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Log in to the Container registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ${{ secrets.ARTIFACTORY_REGISTRY }}
username: ${{ secrets.ARTIFACTORY_USERNAME }}
password: ${{ secrets.ARTIFACTORY_PASSWORD }}

- name: Build and push Backend Docker image
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
10 changes: 2 additions & 8 deletions ui/src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { AppComponent } from './app.component';
describe('AppComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [RouterTestingModule, AppComponent]
}).compileComponents();
imports: [RouterTestingModule, AppComponent],
}).compileComponents();
});

it('should create the app', () => {
Expand All @@ -15,12 +15,6 @@ describe('AppComponent', () => {
expect(app).toBeTruthy();
});

it(`should have as title 'ui'`, () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app.title).toEqual('ui');
});

it('should render title', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MatDialogRef } from '@angular/material/dialog';

import { DeleteConfirmDialogComponent } from './delete-confirm-dialog.component';

Expand All @@ -9,6 +10,12 @@ describe('DeleteConfirmDialogComponent', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [DeleteConfirmDialogComponent],
providers: [
{
provide: MatDialogRef,
useValue: {},
},
],
});
fixture = TestBed.createComponent(DeleteConfirmDialogComponent);
component = fixture.componentInstance;
Expand Down
5 changes: 3 additions & 2 deletions ui/src/app/graph/inspector/inspector.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { HttpClientModule } from '@angular/common/http';

import { InspectorComponent } from './inspector.component';

Expand All @@ -8,8 +9,8 @@ describe('InspectorComponent', () => {

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [InspectorComponent]
}).compileComponents();
imports: [InspectorComponent, HttpClientModule],
}).compileComponents();

fixture = TestBed.createComponent(InspectorComponent);
component = fixture.componentInstance;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { VertexFormFieldComponent } from './vertex-form-field.component';
import { FormGroup } from '@angular/forms';

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

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [VertexFormFieldComponent]
})
.compileComponents();
imports: [VertexFormFieldComponent],
providers: [{ provide: FormGroup, useValue: new FormGroup([]) }],
}).compileComponents();

fixture = TestBed.createComponent(VertexFormFieldComponent);
component = fixture.componentInstance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ export class ActionContentComponent implements OnInit {
values: string[] = [];

ngOnInit(): void {
const actions = this.intention?.actions ?? [];
const valueSet = new Set<string>(
this.intention.actions.map((action: any) => {
actions.map((action: any) => {
return get(action, this.key);
}),
);
Expand Down
6 changes: 3 additions & 3 deletions ui/src/app/page-not-found/page-not-found.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';

import { PageNotFoundComponent } from './page-not-found.component';

Expand All @@ -8,9 +9,8 @@ describe('PageNotFoundComponent', () => {

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [PageNotFoundComponent]
})
.compileComponents();
imports: [RouterTestingModule, PageNotFoundComponent],
}).compileComponents();

fixture = TestBed.createComponent(PageNotFoundComponent);
component = fixture.componentInstance;
Expand Down
3 changes: 2 additions & 1 deletion ui/src/app/preferences.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { TestBed } from '@angular/core/testing';
import { HttpClientModule } from '@angular/common/http';

import { PreferencesService } from './preferences.service';

describe('PreferencesService', () => {
let service: PreferencesService;

beforeEach(() => {
TestBed.configureTestingModule({});
TestBed.configureTestingModule({ imports: [HttpClientModule] });
service = TestBed.inject(PreferencesService);
});

Expand Down
3 changes: 2 additions & 1 deletion ui/src/app/service/graph-api.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { TestBed } from '@angular/core/testing';
import { HttpClientModule } from '@angular/common/http';

import { GraphApiService } from './graph-api.service';

describe('GraphApiService', () => {
let service: GraphApiService;

beforeEach(() => {
TestBed.configureTestingModule({});
TestBed.configureTestingModule({ imports: [HttpClientModule] });
service = TestBed.inject(GraphApiService);
});

Expand Down

0 comments on commit 4e37508

Please sign in to comment.