Skip to content

Commit

Permalink
Release 1.0 (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
vburmus authored Nov 12, 2024
2 parents 39518a9 + c22939b commit c53430b
Show file tree
Hide file tree
Showing 258 changed files with 10,531 additions and 1 deletion.
64 changes: 64 additions & 0 deletions .github/workflows/cd-backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: CD for Backend

on:
pull_request:
branches:
- release-*
paths:
- 'backend/**'

jobs:
cd:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./backend

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: 21
distribution: 'adopt'

- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle

- name: Run Gradle build
run: ./gradlew build

- name: Zip Gradle build
working-directory: ./backend/build/libs
run: zip backend.zip backend-0.1.jar

- name: Terraform init
run: terraform init -migrate-state
working-directory: ./deployment/cd_backend

- name: Terraform deployment
working-directory: ./deployment/cd_backend
run: |
SECURITY_GROUP_ID=$(aws ec2 describe-security-groups --filters "Name=group-name,Values=${RDS_CONN_SECURITY_GROUP_NAME}" --query "SecurityGroups[0].GroupId" --output text)
TF_VAR_rds_connection_sg_id=$SECURITY_GROUP_ID TF_VAR_rds_instance_username=$RDS_INSTANCE_USERNAME TF_VAR_rds_instance_password=$RDS_INSTANCE_PASSWORD TF_VAR_rds_instance_endpoint=$RDS_INSTANCE_ENDPOINT terraform apply -var-file="../variables.tfvars" -replace="aws_instance.ec2_backend" -auto-approve
env:
RDS_CONN_SECURITY_GROUP_NAME: ${{ secrets.RDS_CONN_SECURITY_GROUP_NAME }}
RDS_INSTANCE_USERNAME: ${{ secrets.RDS_INSTANCE_USERNAME }}
RDS_INSTANCE_PASSWORD: ${{ secrets.RDS_INSTANCE_PASSWORD }}
RDS_INSTANCE_ENDPOINT: ${{ secrets.RDS_INSTANCE_ENDPOINT }}
58 changes: 58 additions & 0 deletions .github/workflows/cd-frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: CD for frontend

on:
pull_request:
branches:
- release-*
paths:
- 'frontend/**'


jobs:
cd:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./frontend

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

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '18'

- name: Cache node_modules
uses: actions/cache@v3
with:
path: frontend/node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('package-lock.json') }}
restore-keys: ${{ runner.os }}-node-modules


- name: Install dependencies
run: npm install

- name: Generate environment.ts
run: |
chmod +x ./generate-environment.sh
./generate-environment.sh
env:
OIDC_CLIENT_ID: ${{ secrets.OIDC_CLIENT_ID }}
API_URL: ${{ secrets.API_URL }}
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}

- name: Run ng build
run: npm run build

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Sync to S3
run: aws s3 sync "./dist/fleet-assistant/browser" "s3://fleet-assistant-hosting-bucket/"
57 changes: 57 additions & 0 deletions .github/workflows/ci-backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: CI for Backend

on:
pull_request:
branches:
- master
- develop
paths:
- 'backend/**'

jobs:
ci:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./backend

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: 21
distribution: 'adopt'

- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle

- name: Run Gradle tests
run: ./gradlew test --no-daemon

- name: Generate JaCoCo Report and run Sonar Analysis
run: ./gradlew jacocoTestReport sonar --no-daemon
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

- name: Generate JaCoCo Badge
uses: cicirello/jacoco-badge-generator@v2
with:
generate-branches-badge: true
jacoco-csv-file: backend/build/reports/jacoco/test/jacocoTestReport.csv
47 changes: 47 additions & 0 deletions .github/workflows/ci-frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: CI for frontend

on:
pull_request:
branches:
- master
- develop
paths:
- 'frontend/**'

jobs:
ci:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./frontend

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

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '18'

- name: Cache node_modules
uses: actions/cache@v3
with:
path: frontend/node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('package-lock.json') }}
restore-keys: ${{ runner.os }}-node-modules


- name: Install dependencies
run: npm install

- name: Generate environment.ts
run: |
chmod +x ./generate-environment.sh
./generate-environment.sh
- name: Run tests
run: npm run test

- name: Run linter tests
run: npm run lint
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,10 @@
**/node_modules
**/.angular
*.css
*.css.map
*.css.map
**/package-lock.json
**/dist
environment.ts
**terraform**
**/.venv
**/coverage
74 changes: 74 additions & 0 deletions backend/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.3.3'
id 'io.spring.dependency-management' version '1.1.6'
id "org.sonarqube" version "4.4.1.3373"
id 'jacoco'
}

group = 'org.fleetassistant'
version = '0.1'

java {
sourceCompatibility = '21'
}

repositories {
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.security:spring-security-oauth2-jose'
implementation 'org.springframework.security:spring-security-oauth2-resource-server'
implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'org.zalando:problem-spring-web:0.27.0'
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.3.0'
implementation 'org.projectlombok:lombok'
implementation 'org.liquibase:liquibase-core'
implementation 'org.mapstruct:mapstruct:1.5.3.Final'
implementation 'org.apache.commons:commons-lang3:3.12.0'
implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
implementation 'io.jsonwebtoken:jjwt-impl:0.11.5'
implementation 'io.jsonwebtoken:jjwt-jackson:0.11.5'
implementation 'com.github.ben-manes.caffeine:caffeine:3.0.4'
implementation 'org.springframework.boot:spring-boot-starter-cache:3.1.0'
annotationProcessor 'org.projectlombok:lombok'
annotationProcessor 'org.mapstruct:mapstruct-processor:1.5.3.Final'
runtimeOnly 'org.postgresql:postgresql'

testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.junit.jupiter:junit-jupiter:5.9.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.2'
testImplementation 'org.mockito:mockito-core:5.2.0'
testImplementation 'org.mockito:mockito-junit-jupiter:5.2.0'
testImplementation 'com.h2database:h2:2.1.214'
}

test {
useJUnitPlatform()
finalizedBy jacocoTestReport
}

jacocoTestReport {
dependsOn test
reports {
xml.required = true
csv.required = true
}
}

sonar {
properties {
property "sonar.projectKey", "pwr-thesis_fleet-assistant"
property "sonar.organization", "pwr-thesis"
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.gradle.skipCompile", true
property "sonar.coverage.exclusions", "**/BackendApplication.java,**/DefaultExceptionHandler.java,**/nonrest/*.java,**/rest/*.java,**/controller/*.java,**/model/*.java"
}
}
30 changes: 30 additions & 0 deletions backend/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
services:
postgres:
container_name: postgres
image: postgres
environment:
POSTGRES_USER: admin
POSTGRES_PASSWORD: admin
POSTGRES_DB: fleet_assistant
volumes:
- postgres:/data/postgres
ports:
- '5432:5432'

pgadmin:
container_name: pgadmin
image: dpage/pgadmin4
environment:
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:[email protected]}
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-admin}
PGADMIN_CONFIG_SERVER_MODE: 'False'
volumes:
- pgadmin:/var/lib/pgadmin
ports:
- '5050:80'
depends_on:
- postgres
restart: always
volumes:
postgres:
pgadmin:
Binary file added backend/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions backend/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit c53430b

Please sign in to comment.