Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1102 - Init CI #1144

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ YAS_SERVICES_PROMOTION=http://promotion/promotion
YAS_SERVICES_INVENTORY=http://inventory/inventory
YAS_SERVICES_RATING=http://rating/rating
YAS_SERVICES_SAMPLE_DATA=http://sampledata/sampledata
YAS_SERVICES_RECOMMENDATION=http://recommendation/recommendation
SERVER_PORT=80

# Swagger UI
Expand All @@ -88,4 +89,9 @@ COMPOSE_FILE=docker-compose.yml:docker-compose.search.yml:docker-compose.o11y.ym

# Additional configuration
YAS_PRICE_INCLUDES_TAX=false
YAS_CURRENCY_UNIT=VND
YAS_CURRENCY_UNIT=VND

# OpenAI Config
SPRING_AI_AZURE_OPENAI_API_KEY=
SPRING_AI_AZURE_OPENAI_ENDPOINT=
SPRING_AI_AZURE_OPENAI_EMBEDDING_OPTIONS_MODEL=
91 changes: 91 additions & 0 deletions .github/workflows/recommendation-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: recommendation service ci

on:
push:
branches: ["main"]
paths:
- "recommendation/**"
- ".github/workflows/actions/action.yaml"
- ".github/workflows/recommendation-ci.yaml"
- "pom.xml"
pull_request:
branches: ["main"]
paths:
- "recommendation/**"
- ".github/workflows/actions/action.yaml"
- ".github/workflows/recommendation-ci.yaml"
- "pom.xml"
workflow_dispatch:

jobs:
Build:
runs-on: ubuntu-latest
env:
FROM_ORIGINAL_REPOSITORY: ${{ github.event.pull_request.head.repo.full_name == github.repository || github.ref == 'refs/heads/main' }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- uses: ./.github/workflows/actions
- name: Run Maven Build Command
run: mvn clean install -pl recommendation -am
- name: Run Maven Checkstyle
if: ${{ env.FROM_ORIGINAL_REPOSITORY == 'true' }}
run: mvn checkstyle:checkstyle -pl recommendation -am -Dcheckstyle.output.file=recommendation-checkstyle-result.xml
- name: Upload Checkstyle Result
if: ${{ env.FROM_ORIGINAL_REPOSITORY == 'true' }}
uses: jwgmeligmeyling/checkstyle-github-action@master
with:
path: '**/recommendation-checkstyle-result.xml'
- name: Test Results
uses: dorny/test-reporter@v1
if: ${{ env.FROM_ORIGINAL_REPOSITORY == 'true' && (success() || failure()) }}
continue-on-error: true # TODO: remove once defining UT
with:
name: Recommendation-Service-Unit-Test-Results
path: "recommendation/**/*-reports/TEST*.xml"
reporter: java-junit
- name: Analyze with sonar cloud
if: ${{ env.FROM_ORIGINAL_REPOSITORY == 'true' }}
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -f recommendation
- name: OWASP Dependency Check
if: ${{ env.FROM_ORIGINAL_REPOSITORY == 'true' }}
uses: dependency-check/Dependency-Check_Action@main
env:
JAVA_HOME: /opt/jdk
with:
project: 'yas'
path: '.'
format: 'HTML'
- name: Upload OWASP Dependency Check results
if: ${{ env.FROM_ORIGINAL_REPOSITORY == 'true' }}
uses: actions/upload-artifact@master
with:
name: OWASP Dependency Check Report
path: ${{github.workspace}}/reports
- name: Add coverage report to PR
uses: madrapps/[email protected]
if: ${{ env.FROM_ORIGINAL_REPOSITORY == 'true' }}
with:
paths: ${{github.workspace}}/recommendation/target/site/jacoco/jacoco.xml
token: ${{secrets.GITHUB_TOKEN}}
min-coverage-overall: 80
min-coverage-changed-files: 60
title: 'Recommendation Coverage Report'
update-comment: true
- name: Log in to the Container registry
if: ${{ github.ref == 'refs/heads/main' }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker images
if: ${{ github.ref == 'refs/heads/main' }}
uses: docker/build-push-action@v6
with:
context: ./recommendation
push: true
tags: ghcr.io/nashtech-garage/yas-recommendation:latest
29 changes: 29 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,35 @@ services:
- ./deployment/app-config:/app-config
networks:
- yas-network
recommendation:
build: ./recommendation
image: ghcr.io/nashtech-garage/yas-recommendation:latest
ports:
- '9791:9791'
environment:
- SPRING_DATASOURCE_URL=jdbc:postgresql://postgres:5432/recommendation
- SERVER_SERVLET_CONTEXT_PATH=/recommendation
- YAS_PUBLIC_URL=${YAS_PUBLIC_API_URL}/recommendation
- YAS_SERVICES_PRODUCT
- SERVER_PORT
- LOGGING_CONFIG
- JAVA_TOOL_OPTIONS
- OTEL_EXPORTER_OTLP_ENDPOINT
- OTEL_EXPORTER_OTLP_PROTOCOL
- OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE
- OTEL_RESOURCE_ATTRIBUTES
- OTEL_SERVICE_NAME=recommendation-service
- OTEL_LOGS_EXPORTER
- OTEL_TRACES_EXPORTER
- OTEL_METRICS_EXPORTER
- OTEL_INSTRUMENTATION_LOGBACK-MDC_ADD-BAGGAGE
- OTEL_JAVAAGENT_LOGGING
- OTEL_JAVAAGENT_ENABLED
- OTEL_JAVAAGENT_DEBUG
# OpenAI Config
- SPRING_AI_AZURE_OPENAI_API_KEY
- SPRING_AI_AZURE_OPENAI_ENDPOINT
- SPRING_AI_AZURE_OPENAI_EMBEDDING_OPTIONS_MODEL
swagger-ui:
image: swaggerapi/swagger-ui:v4.16.0
environment:
Expand Down
1 change: 1 addition & 0 deletions k8s/charts/yas-configuration/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ applicationConfig:
search: http://search/search
tax: http://tax/tax
sampledata: http://sampledata/sampledata
recommendation: http://recommendation/recommendation

# Gateway config for bff microservices
gatewayRoutesConfig:
Expand Down
3 changes: 3 additions & 0 deletions nginx/templates/default.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ server {
location /sampledata/ {
proxy_pass http://sampledata;
}
location /recommendation/ {
proxy_pass http://recommendation;
}
}

server {
Expand Down
3 changes: 3 additions & 0 deletions recommendation/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM eclipse-temurin:21-jre-alpine
COPY target/recommendation*.jar app.jar
ENTRYPOINT ["java", "-jar", "/app.jar"]
6 changes: 3 additions & 3 deletions recommendation/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ spring.ai.vectorstore.pgvector.index-type=HNSW
spring.ai.vectorstore.pgvector.distance-type=COSINE_DISTANCE

# Azure AI configuration
spring.ai.azure.openai.api-key=xxx
spring.ai.azure.openai.endpoint=https://product-recommendation.openai.azure.com
spring.ai.azure.openai.embedding.options.model=text-embedding-3-small
spring.ai.azure.openai.api-key=
spring.ai.azure.openai.endpoint=
spring.ai.azure.openai.embedding.options.model=

# swagger-ui custom path
springdoc.swagger-ui.path=/swagger-ui
Expand Down
Loading