Skip to content

Commit

Permalink
updated ui config (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuldeep-knoldus authored Jun 13, 2024
1 parent f9d6cdc commit c12c9d1
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 52 deletions.
122 changes: 84 additions & 38 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Java CI with Maven
name: CI/CD Pipeline

on:
push:
Expand All @@ -7,72 +7,118 @@ on:

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

# Setup for Java projects
- name: Set up JDK 21
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: maven
- name: Read service names from file
id: read-service-names

# Build and deploy Java services
- name: Build and deploy Java services
run: |
SERVICE_NAMES=$(cat projects-changes-deploy.txt)
echo "Service Names: $SERVICE_NAMES"
echo "::set-output name=service_names::$SERVICE_NAMES"
- name: Build and deploy services
run: |
for SERVICE_NAME in $(echo ${{ steps.read-service-names.outputs.service_names }} | tr ',' ' '); do
for SERVICE_NAME in $(echo $SERVICE_NAMES | tr ',' ' '); do
echo "Building and deploying $SERVICE_NAME"
# Set the build context to the root directory
cd $SERVICE_NAME
if [ $SERVICE_NAME != "blogs-analyzer-ui" ]; then
if [ -d "$SERVICE_NAME" ]; then
cd $SERVICE_NAME
if [ "$SERVICE_NAME" != "blogs-analyzer-ui" ]; then
mvn clean install -B -V
fi
cd ..
fi
done
# Setup for Angular projects
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: '21'

# Install dependencies for Angular projects
- name: Install dependencies for Angular projects
run: |
SERVICE_NAMES=$(cat projects-changes-deploy.txt)
echo "Service Names: $SERVICE_NAMES"
for SERVICE_NAME in $(echo $SERVICE_NAMES | tr ',' ' '); do
echo "Processing Service: $SERVICE_NAME"
if [ -d "$SERVICE_NAME" ]; then
cd $SERVICE_NAME
if [ "$SERVICE_NAME" == "blogs-analyzer-ui" ]; then
npm install
fi
cd ..
fi
done
sonarcloud:
name: SonarCloud
name: SonarCloud Analysis
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

# Setup for Java projects
- name: Set up JDK 21
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: maven
- name: Read service names from file
id: read-service-names

# Setup for Node.js
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: '21'

# Sonar Analysis for Java projects
- name: Sonar Analysis for Java projects
run: |
SERVICE_NAMES=$(cat projects-changes-deploy.txt)
echo "Service Names: $SERVICE_NAMES"
echo "::set-output name=service_names::$SERVICE_NAMES"
- name: SonarCloud Scan
for SERVICE_NAME in $(echo $SERVICE_NAMES | tr ',' ' '); do
echo "Processing Service: $SERVICE_NAME"
if [ -d "$SERVICE_NAME" ]; then
cd $SERVICE_NAME
if [ "$SERVICE_NAME" != "blogs-analyzer-ui" ]; then
mvn clean verify sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=nashtech -Dsonar.branch.name=master
fi
cd ..
fi
done
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

# Sonar Analysis for Angular projects
- name: Sonar Analysis for Angular projects
run: |
for SERVICE_NAME in $(echo ${{ steps.read-service-names.outputs.service_names }} | tr ',' ' '); do
SERVICE_NAMES=$(cat projects-changes-deploy.txt)
echo "Service Names: $SERVICE_NAMES"
for SERVICE_NAME in $(echo $SERVICE_NAMES | tr ',' ' '); do
echo "Processing Service: $SERVICE_NAME"
#ls -al
cd $SERVICE_NAME
#pwd
if [ "$SERVICE_NAME" == "blogs-analyzer-ui" ]; then
npm install
# Run tests and generate code coverage reports (replace with your test command)
npm test -- --coverage
# Install SonarScanner for Node.js
npm install -g sonarqube-scanner
# Run SonarScanner for Node.js
sonar-scanner -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=nashtech -Dsonar.branch.name=master
else
# Maven Sonar
mvn clean verify sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=nashtech -Dsonar.branch.name=master
if [ -d "$SERVICE_NAME" ]; then
cd $SERVICE_NAME
if [ "$SERVICE_NAME" == "blogs-analyzer-ui" ]; then
npm install
npm test
npm install -g sonarqube-scanner
npm run sonar
fi
cd ..
fi
done
done
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
9 changes: 7 additions & 2 deletions blogs-analyzer-ui/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
"src/assets"
],
"styles": [
"src/styles.scss"
"@angular/material/prebuilt-themes/indigo-pink.css",
"src/styles.scss",
"./node_modules/bootstrap/dist/css/bootstrap.min.css"
],
"scripts": []
},
Expand Down Expand Up @@ -82,6 +84,7 @@
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"codeCoverage": true,
"polyfills": [
"zone.js",
"zone.js/testing"
Expand All @@ -93,9 +96,11 @@
"src/assets"
],
"styles": [
"@angular/material/prebuilt-themes/indigo-pink.css",
"src/styles.scss"
],
"scripts": []
"scripts": [],
"karmaConfig": "karma.conf.js"
}
}
}
Expand Down
46 changes: 46 additions & 0 deletions blogs-analyzer-ui/karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
clearContext: false
},
coverageReporter : {
dir: require('path').join(__dirname, './coverage'),
subdir: '.',
reporters: [
{type: 'html'},
{type: 'lcovonly'},
{type: 'text-summary'},
{type: 'cobertura'}
],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml','coverage'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
browsers: ['ChromeHeadless'],
customLaunchers: {
ChromeHeadless: {
base: 'Chrome',
flags: [
'--disable-gpu',
'--no-sandbox',
'--disable-setuid-sandbox',
'--headless',
'--remote-debugging-port=9222']
}
},
browserNoActivityTimeout: 60000,
autoWatch: false,
singleRun: true,
});
};
9 changes: 7 additions & 2 deletions blogs-analyzer-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"
"test": "ng test --code-coverage=true --watch=false --browsers=ChromeHeadless --karma-config=karma.conf.js",
"sonar": "sonar-scanner"
},
"private": true,
"dependencies": {
Expand All @@ -19,7 +20,9 @@
"@angular/platform-browser-dynamic": "^16.0.0",
"@angular/router": "^16.0.0",
"@angular/material": "^16.1.1",
"bootstrap": "^5.3.0",
"rxjs": "~7.8.0",
"sonarqube-scanner": "^3.0.1",
"tslib": "^2.3.0",
"zone.js": "~0.13.0"
},
Expand All @@ -31,9 +34,11 @@
"jasmine-core": "~4.6.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "~2.2.0",
"karma-coverage": "~2.2.1",
"karma-coverage-istanbul-reporter": "~3.0.3",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.0.0",
"sonar-scanner": "^3.1.0",
"typescript": "~5.0.2"
}
}
11 changes: 11 additions & 0 deletions blogs-analyzer-ui/sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
sonar.sources=src
sonar.tests=coverage
sonar.sourceEncoding=UTF-8
sonar.projectVersion=1.0
sonar.host.url=https://sonarcloud.io
sonar.organization=nashtech
sonar.projectKey=blogs-analyzer-ui
sonar.projectName=blogs-analyzer-ui
sonar.exclusions=**/node_modules/**,**/*.html,**/*.scss,**/*.spec.ts,**/*.css,**/models/**,**/assets/**
sonar.javascript.lcov.reportPaths=coverage/lcov.info
sonar.token=013631d793a41fe3c4b7d4fefb99224b542318c7
7 changes: 0 additions & 7 deletions blogs-analyzer-ui/src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,4 @@ describe('AppComponent', () => {
const app = fixture.componentInstance;
expect(app.title).toEqual('blogs-analyzer-ui');
});

it('should render title', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.nativeElement as HTMLElement;
expect(compiled.querySelector('.content span')?.textContent).toContain('blogs-analyzer-ui app is running!');
});
});
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { DashboardComponent } from './dashboard.component';
import {HeaderComponent} from "./components/header/header.component";
import {RouterTestingModule} from "@angular/router/testing";

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

beforeEach(() => {
TestBed.configureTestingModule({
declarations: [DashboardComponent]
declarations: [DashboardComponent, HeaderComponent],
imports: [RouterTestingModule]
});
fixture = TestBed.createComponent(DashboardComponent);
component = fixture.componentInstance;
Expand Down
3 changes: 1 addition & 2 deletions projects-changes-deploy.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
blogs-analyzer
blogs-analyzer-ui
blogs-analyzer-ui

0 comments on commit c12c9d1

Please sign in to comment.