Skip to content

Commit

Permalink
Merge branch 'develop' into feature/update-http-stress-test
Browse files Browse the repository at this point in the history
  • Loading branch information
jarali authored Jan 13, 2024
2 parents 74eb662 + d09899a commit b351e6e
Show file tree
Hide file tree
Showing 272 changed files with 20,561 additions and 3,632 deletions.
38 changes: 32 additions & 6 deletions .github/workflows/docker-push-registry.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,40 @@
name: Deploy to docker
name: Push to docker

on:
push:
branches:
- main
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
workflow_dispatch:

jobs:
test:
name: Testing stage (Test before deployment)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.

- name: Setup go
uses: actions/setup-go@v2
with:
go-version: '1.21.0'

- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run Test
run: |
go test -v hsfl.de/group6/hsfl-master-ai-cloud-engineering/...
push:
name: Build and push to docker hub registry
name: Building stage (Build and push to docker hub registry)
needs: [test]
runs-on: ubuntu-latest

steps:
Expand All @@ -31,10 +57,10 @@ jobs:
- name: Check and set release version
run: |
echo "RELEASE_VERSION=$(git tag -l --format='%(contents:subject)'${GITHUB_REF#refs/*/})" >> $GITHUB_ENV
echo "RELEASE_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
echo "RELEASE_VERSION: '$RELEASE_VERSION'"
- if: ${{ env.RELEASE_VERSION != '' && contains(github.ref, 'main') }}
- if: ${{ github.ref_name != '' }}
name: Build and push (versioned)
working-directory: ./
run: |
Expand Down
82 changes: 82 additions & 0 deletions .github/workflows/run-tests-lib-folder.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Run tests (lib folder)

on:
push:
paths:
- 'lib/**'
workflow_dispatch:
workflow_call:

jobs:
test:
name: Test lib folder
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.21

- name: Install dependencies for config
working-directory: ./lib/config
run: go mod tidy

- name: Install dependencies for router
working-directory: ./lib/router
run: go mod tidy

- name: Install dependencies for rpc
working-directory: ./lib/rpc
run: go mod tidy

- name: Build config library
working-directory: ./lib/config
run: go build -v ./...

- name: Build router library
working-directory: ./lib/router
run: go build -v ./...

- name: Build rpc library
working-directory: ./lib/rpc
run: go build -v ./...

- name: Test Go config Module
run: |
cd lib/config
go test ./...
test_exit_code=$? # Capture the exit code of the go test command
if [ $test_exit_code -eq 0 ]; then
echo "Tests passed successfully."
else
echo "Tests failed with exit code $test_exit_code."
exit 1 # Fail the GitHub Actions workflow
fi
- name: Test Go router Module
run: |
cd lib/router
go test ./...
test_exit_code=$? # Capture the exit code of the go test command
if [ $test_exit_code -eq 0 ]; then
echo "Tests passed successfully."
else
echo "Tests failed with exit code $test_exit_code."
exit 1 # Fail the GitHub Actions workflow
fi
- name: Test Go rpc Module
run: |
cd lib/rpc
go test ./...
test_exit_code=$? # Capture the exit code of the go test command
if [ $test_exit_code -eq 0 ]; then
echo "Tests passed successfully."
else
echo "Tests failed with exit code $test_exit_code."
exit 1 # Fail the GitHub Actions workflow
fi
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,8 @@ fabric.properties
.history
.ionide

# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,goland+all,go
# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,goland+all,go

\var
**\.pem
**\.pub
32 changes: 32 additions & 0 deletions .mockery.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
with-expecter: true
packages:
hsfl.de/group6/hsfl-master-ai-cloud-engineering/product-service/products:
config:
dir: "./src/product-service/products/_mock"
interfaces:
Controller:
Repository:
hsfl.de/group6/hsfl-master-ai-cloud-engineering/product-service/prices:
config:
dir: "./src/product-service/prices/_mock"
interfaces:
Controller:
Repository:
hsfl.de/group6/hsfl-master-ai-cloud-engineering/shoppinglist-service/userShoppingList:
config:
dir: "./src/shoppinglist-service/userShoppingList/_mock"
interfaces:
Controller:
Repository:
hsfl.de/group6/hsfl-master-ai-cloud-engineering/shoppinglist-service/userShoppingListEntry:
config:
dir: "./src/shoppinglist-service/userShoppingListEntry/_mock"
interfaces:
Controller:
Repository:
hsfl.de/group6/hsfl-master-ai-cloud-engineering/user-service/user:
config:
dir: "./src/user-service/user/_mock"
interfaces:
Controller:
Repository:
57 changes: 49 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Price Whisper
![Coverage](https://img.shields.io/badge/Coverage-82.5%25-brightgreen)
![Coverage](https://img.shields.io/badge/Coverage-75.1%25-brightgreen)
![GitHub release (by tag)](https://img.shields.io/github/v/tag/onyxmoon/hsfl-master-ai-cloud-engineering.svg?sort=semver&label=Version&color=4ccc93d)
[![Run tests (lib folder)](https://github.com/Onyxmoon/hsfl-master-ai-cloud-engineering/actions/workflows/run-tests-lib-folder.yml/badge.svg)](https://github.com/Onyxmoon/hsfl-master-ai-cloud-engineering/actions/workflows/run-tests-lib-folder.yml)
[![Run tests (http proxy service)](https://github.com/Onyxmoon/hsfl-master-ai-cloud-engineering/actions/workflows/run-tests-http-proxy-service.yml/badge.svg)](https://github.com/Onyxmoon/hsfl-master-ai-cloud-engineering/actions/workflows/run-tests-http-proxy-service.yml)
[![Run tests (product-service)](https://github.com/Onyxmoon/hsfl-master-ai-cloud-engineering/actions/workflows/run-tests-product-service.yml/badge.svg)](https://github.com/Onyxmoon/hsfl-master-ai-cloud-engineering/actions/workflows/run-tests-product-service.yml)
[![Run tests (shoppinglist-service)](https://github.com/Onyxmoon/hsfl-master-ai-cloud-engineering/actions/workflows/run-tests-shoppinglist-service.yml/badge.svg)](https://github.com/Onyxmoon/hsfl-master-ai-cloud-engineering/actions/workflows/run-tests-shoppinglist-service.yml)
Expand All @@ -24,13 +25,55 @@ Key features:

![Architecture](README.assets/CE_Architecture_Prototype.svg)

## Setup for development
1. Clone repository from Github `git clone git@github.com:Onyxmoon/hsfl-master-ai-cloud-engineering.git`
2. Run `docker compose up -d` to startt the containers defined in the Compose file
3. Install dependencies for frontend `cd src/web-service/frontend` and run `npm ci`
4. Call `npm run build` to build your static files
## Requirements
### Development


## Setup the project
### Development setup via docker-compose
> The development setup exposes all ports to the host machine, so you can access each service individually. Docker will build local and database is not persistent in this setup.
1. Clone repository from Github `git clone https://github.com/Onyxmoon/hsfl-master-ai-cloud-engineering.git`
2. Set your own username and password for the database access in compose file (replace `db-username` and `db-pw-changeMe!`).
> Some special characters are not possible because RQLite uses basic auth. Please use url-safe characters like Alphanumeric [0-9a-zA-Z], special characters $-_.+!*'(),.
3. Setup .env files for the following services or add the corresponding environment variables via compose file
- [Product Service](src/product-service)
- [Shopping list Service](src/shoppinglist-service)
- [User Service](src/user-service)
4. Generate a secret private key for JWT token generation for the user service.

Specify the path to an ecdsa private key or provide the content of one directly in environment variable `JWT_PRIVATE_KEY` at user service.

You can generate a key with the following command:
```shell
ssh-keygen -t ecdsa -f ./src/user-service/privateKey.pem -m pem
```
> When step is missing, container will use a random but secure generated key on each start.
5. Run `docker compose -f docker-compose.dev.yml up -d` to start the containers defined in the Compose file
6. Run `docker compopse down` to stop container, networks, volumes, and images created by up.
### Normal setup via docker-compose
> The normal setup isolates the internal communication between services and only the proxy is reachable from the host machine. Prebuild images from Docker Hub will be used and database is persistent in this setup.
1. Use the docker-compose.yml from the root of this repository.
2. It is recommended to set your own username and password for the database access in compose file (replace `db-username` and `db-pw-changeMe!`).
> Some special characters are not possible because RQLite uses basic auth. Please use url-safe characters like Alphanumeric [0-9a-zA-Z], special characters $-_.+!*'(),.
3. Generate a secret private key for JWT token generation for the user service.

Specify the path to an ecdsa private key or provide the content of one directly in environment variable `JWT_PRIVATE_KEY` at user service.

You can generate a key with the following command:
```shell
ssh-keygen -t ecdsa -f privateKey.pem -m pem
```
> When step is missing, container will use a random but secure generated key on each start.
4. Run `docker compose -f docker-compose.yml up -d` to start the containers defined in the Compose file
5. Run `docker compopse down` to stop container, networks, volumes, and images created by up.

### Setup with kubernetes
1. SECRETS
1. Apply the manifests in `kubernetes/manifests`
```shell
kubectl apply -R -f ./kubernetes/manifests
```

## Authors

Dorien Grönwald<br>
Expand All @@ -44,5 +87,3 @@ Hochschule Flensburg
Jannick Lindner<br>
jannick.lindner@stud.hs-flensburg.de<br>
Hochschule Flensburg

## \<Add more sections here\>
44 changes: 0 additions & 44 deletions docker-compose.dev.native.yml

This file was deleted.

Loading

0 comments on commit b351e6e

Please sign in to comment.