-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
404 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
name: Test and Build post service | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ubaid4j/cloud-native-app-spring-boot/post-service | ||
VERSION: latest | ||
|
||
on: | ||
push: | ||
paths: | ||
- 'post-service/**' | ||
branches: | ||
- social-app-project | ||
|
||
defaults: | ||
run: | ||
working-directory: ./post-service | ||
|
||
jobs: | ||
build: | ||
name: Build and Test | ||
runs-on: ubuntu-24.04 | ||
permissions: | ||
contents: read | ||
security-events: write | ||
steps: | ||
- name: Checkout source code | ||
uses: actions/checkout@v3 | ||
- name: set up JDK | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: temurin | ||
java-version: 22 | ||
cache: maven | ||
- name: Code vulnerability scanning | ||
uses: anchore/scan-action@v3 | ||
id: scan | ||
with: | ||
path: "${{ github.workspace }}/post-service" | ||
only-fixed: true | ||
fail-build: true | ||
severity-cutoff: critical | ||
- name: Upload vulnerability report | ||
uses: github/codeql-action/upload-sarif@v3 | ||
if: success() | ||
with: | ||
sarif_file: ${{ steps.scan.outputs.sarif }} | ||
- name: Build and Test | ||
run: | | ||
mvn -Pprod verify | ||
- name: Setup k8s validator | ||
uses: alexellis/arkade-get@master | ||
with: | ||
kubectl: latest | ||
kubeval: latest | ||
kustomize: latest | ||
- name: Validate k8s files | ||
run: | | ||
kustomize build k8s -o k8s/k8s.yml | ||
kubeval --schema-location https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/ --strict -d k8s/k8s.yml | ||
rm -f k8s/k8s.yml | ||
package: | ||
name: Package and Publish | ||
needs: [build] | ||
runs-on: ubuntu-24.04 | ||
permissions: | ||
contents: read | ||
packages: write | ||
security-events: write | ||
steps: | ||
- name: Checkout source code | ||
uses: actions/checkout@v3 | ||
- name: Setup JDK | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: temurin | ||
java-version: 22 | ||
cache: maven | ||
- name: Build Container Image | ||
run: | | ||
mvn -Pprod spring-boot:build-image | ||
- name: OCI Image vulnerability scanning | ||
uses: anchore/scan-action@v3 | ||
id: scan | ||
with: | ||
image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} | ||
fail-build: true | ||
only-fixed: true | ||
severity-cutoff: critical | ||
- name: Upload vulnerability report | ||
uses: github/codeql-action/upload-sarif@v3 | ||
if: success() | ||
with: | ||
sarif_file: ${{ steps.scan.outputs.sarif }} | ||
- name: Login to container registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Publish container image | ||
run: docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Enable auto-env through the sdkman_auto_env config | ||
# Add key=value pairs of SDKs to use below | ||
java=22.0.1-tem | ||
maven=4.0.0-beta-3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,32 @@ | ||
import {ComponentFixture, TestBed} from '@angular/core/testing'; | ||
import {AppComponent} from './app.component'; | ||
import {PostService} from "./posts/post.service"; | ||
|
||
describe('AppComponent', () => { | ||
let component: AppComponent; | ||
let fixture: ComponentFixture<AppComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [ | ||
AppComponent | ||
] | ||
}).compileComponents(); | ||
await TestBed.configureTestingModule({ | ||
imports: [ | ||
AppComponent | ||
], | ||
}) | ||
.overrideTemplate(AppComponent, '') | ||
.compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(AppComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}) | ||
|
||
it('should create the app', () => { | ||
expect(component).toBeTruthy(); | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
it('should have a title "The Social Platform"', () => { | ||
expect(component.title).toEqual('The Social Platform'); | ||
expect(component.title).toEqual('The Social Platform'); | ||
}); | ||
}); |
23 changes: 13 additions & 10 deletions
23
api-gateway/src/main/webapp/app/posts/post.service.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
import {TestBed} from '@angular/core/testing'; | ||
|
||
import { PostService } from './post.service'; | ||
import {PostService} from './post.service'; | ||
import {HttpClientTestingModule} from "@angular/common/http/testing"; | ||
|
||
describe('PostService', () => { | ||
let service: PostService; | ||
let service: PostService; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({}); | ||
service = TestBed.inject(PostService); | ||
}); | ||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [HttpClientTestingModule] | ||
}); | ||
service = TestBed.inject(PostService); | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(service).toBeTruthy(); | ||
}); | ||
it('should be created', () => { | ||
expect(service).toBeTruthy(); | ||
}); | ||
}); |
33 changes: 17 additions & 16 deletions
33
api-gateway/src/main/webapp/app/posts/post/post.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,24 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import {ComponentFixture, TestBed} from '@angular/core/testing'; | ||
|
||
import { PostComponent } from './post.component'; | ||
import {PostComponent} from './post.component'; | ||
import {HttpClientTestingModule} from "@angular/common/http/testing"; | ||
|
||
describe('PostComponent', () => { | ||
let component: PostComponent; | ||
let fixture: ComponentFixture<PostComponent>; | ||
let component: PostComponent; | ||
let fixture: ComponentFixture<PostComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [PostComponent] | ||
}) | ||
.compileComponents(); | ||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [PostComponent, HttpClientTestingModule] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(PostComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
fixture = TestBed.createComponent(PostComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
37 changes: 20 additions & 17 deletions
37
api-gateway/src/main/webapp/app/posts/posts.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,26 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import {ComponentFixture, TestBed} from '@angular/core/testing'; | ||
|
||
import { PostsComponent } from './posts.component'; | ||
import {PostsComponent} from './posts.component'; | ||
import {PostService} from "./post.service"; | ||
import {HttpClientTestingModule} from "@angular/common/http/testing"; | ||
|
||
describe('PostsComponent', () => { | ||
let component: PostsComponent; | ||
let fixture: ComponentFixture<PostsComponent>; | ||
let component: PostsComponent; | ||
let fixture: ComponentFixture<PostsComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [PostsComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(PostsComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [PostsComponent, HttpClientTestingModule], | ||
}) | ||
.overrideTemplate(PostsComponent, '') | ||
.compileComponents(); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
fixture = TestBed.createComponent(PostsComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Enable auto-env through the sdkman_auto_env config | ||
# Add key=value pairs of SDKs to use below | ||
java=22.0.1-tem | ||
maven=4.0.0-beta-3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
server: | ||
port: 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: post-service | ||
labels: | ||
app: post-service | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: post-service | ||
template: | ||
metadata: | ||
labels: | ||
app: post-service | ||
spec: | ||
containers: | ||
- name: post-service | ||
image: ghcr.io/ubaid4j/cloud-native-app-spring-boot/post-service:latest | ||
imagePullPolicy: IfNotPresent | ||
env: | ||
- name: SPRING_PROFILES_ACTIVE | ||
value: prod | ||
ports: | ||
- containerPort: 80 | ||
livenessProbe: | ||
httpGet: | ||
path: /management/health/liveness | ||
port: 80 | ||
readinessProbe: | ||
httpGet: | ||
path: /management/health/readiness | ||
port: 80 | ||
volumeMounts: | ||
- mountPath: /workspace/config | ||
name: post-service-config-volume | ||
volumes: | ||
- name: post-service-config-volume | ||
configMap: | ||
name: post-service-config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
|
||
resources: | ||
- deployment.yml | ||
- ingress.yml | ||
- service.yml | ||
|
||
configMapGenerator: | ||
- name: post-service-config | ||
files: | ||
- application.yml | ||
options: | ||
labels: | ||
config: post-service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: post-service | ||
labels: | ||
service: post-service | ||
spec: | ||
type: ClusterIP | ||
selector: | ||
app: post-service | ||
ports: | ||
- port: 80 | ||
protocol: TCP | ||
targetPort: 80 |
Oops, something went wrong.