Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
3cbf974
chore: Add required modules for Jaeger
magley Sep 21, 2025
3f3def7
feat: Initialize Jaeger tracer in `main()`
magley Sep 21, 2025
91acf0a
feat: Set tracer variables from the environment
magley Sep 21, 2025
5a47732
refactor: Extract tracing code in `utils/` package
magley Sep 21, 2025
692c0c5
feat: Add tracing at the API level
magley Sep 21, 2025
68ca6e0
feat: Propagate Registration context to service layer (and add servic…
magley Sep 21, 2025
3b721fa
refactor: Create a "telemetry" object abstracting tracing and logging
magley Sep 21, 2025
e8ad598
refactor: Migrate to the telemetry object
magley Sep 21, 2025
daef987
feat: Prepare telemetry for tests
magley Sep 24, 2025
6eae6a0
feat: Add tracing to the external client methods
magley Sep 24, 2025
44f2265
feat: Add tracing to the rest of the microservice
magley Sep 24, 2025
39589d8
feat: Install `slog-multi` package
magley Oct 2, 2025
7e6ee8e
feat: Add structured logging support in Telemetry
magley Oct 2, 2025
4750a31
feat: Pass error message to logger
magley Oct 2, 2025
6fc9b72
feat: Migrate to new tracing/logging API
magley Oct 2, 2025
5d6eb7e
fix: Don't use `err` if it's `nil`
magley Oct 2, 2025
ad705d9
feat: Write logs to log file
magley Oct 2, 2025
83a9d2f
fix: Add empty stack check in Telemetry
magley Oct 5, 2025
71bd62e
fix: Trigger the Actions bot
magley Oct 5, 2025
4833309
feat: Support `reservation-service` and `room_service` in integration…
Vasilijez Oct 11, 2025
6e7bbe6
feat: Ignore `services` and `override.env`, and enforce `eol=lf`
Vasilijez Oct 11, 2025
42cbb8a
feat: Run `test_integration` with `MODE=ci` in GitHub Actions
Vasilijez Oct 11, 2025
b13b285
feat: Add required libraries for sending data to Prometheus
magley Oct 9, 2025
eade30e
feat: Create Prometheus middleware
magley Oct 9, 2025
5ae983f
feat: Add Prometheus middleware to the server
magley Oct 9, 2025
ac2614f
feat: Add user agent and timestamp to logs
magley Oct 9, 2025
b4bab9c
fix: Don't push response size that's < 0 to Prometheus
magley Oct 11, 2025
e26ce4e
feat: Add `reservationclient` to directly check active guest reservat…
Vasilijez Sep 26, 2025
30d2224
feat: Logged-in user deletes themselves
Vasilijez Sep 26, 2025
f99abc7
test: Retune unit tests mostly due to `ReservationClient`
Vasilijez Sep 28, 2025
d814cf2
test: Add and update integration tests for `TestIntegration_Delete`
Vasilijez Oct 9, 2025
3152979
feat: Update `reservation-client` to use new logging
Vasilijez Oct 11, 2025
a67158e
feat: Add forgotten error messages in `reservation-client`
Vasilijez Oct 11, 2025
2723bdb
test: Update unit tests with `context.Background()` parameter
Vasilijez Oct 11, 2025
ab14c0c
fix: Untar private key for CI
Vasilijez Oct 11, 2025
8d02e26
feat: Use branches with latest changes
Vasilijez Oct 11, 2025
1b669b1
feat: Move logic of `GetActiveHostReservations` to `reservation-service`
Vasilijez Oct 13, 2025
dc1ba25
feat: Add empty `client.go` file
Vasilijez Oct 13, 2025
0ac5b3d
feat: Use develop as latest branch from other microservices
Vasilijez Oct 13, 2025
c101577
feat: Inject `RoomClient` in service and tests
Vasilijez Oct 13, 2025
d0ac2b6
feat: Use Kaniko for building and publishing Docker images to the reg…
magley Oct 14, 2025
23a7b5a
feat: Add AutoApprove field into room dtos
nadazaric Oct 23, 2025
231862c
feat: Add SonarQube analysis
magley Oct 26, 2025
cca72f9
feat: Prepare for PR analysis
magley Oct 26, 2025
0a39c77
feat: Update user (host rooms) deletion and `repo.Delete` to perform …
Vasilijez Oct 28, 2025
bb4b1cd
feat: Verify if user account is deleted on login
Vasilijez Oct 28, 2025
34a225e
feat: Retune terminology
Vasilijez Oct 28, 2025
d0989bc
feat: Update unit tests for `Delete` of user
Vasilijez Oct 28, 2025
eb2e52b
fix: Add missing error handling for `login`
Vasilijez Oct 28, 2025
b9d9404
feat: Add JWT utility for integration tests
Vasilijez Oct 28, 2025
08b89b9
test: Update integration tests for user deletion
Vasilijez Oct 28, 2025
327c5ff
fix: Use latest changes during CI integration testing
Vasilijez Oct 28, 2025
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.sh text eol=lf
*.env text eol=lf
Makefile text eol=lf
18 changes: 7 additions & 11 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,17 @@ jobs:

- name: Set VERSION environment variable
run: echo "VERSION=${{ steps.version.outputs.version }}" >> $GITHUB_ENV

- name: Log in to DockerHub
uses: docker/login-action@v2
- name: Build and push Docker image using Kaniko
uses: aevea/action-kaniko@master
with:
image: ${{ secrets.USER_SERVICE_NAME }}
tag: ${{ env.VERSION }}
path: ./src/
build_file: Dockerfile
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build Docker image
run: |
docker build -t ${{ secrets.USER_SERVICE_NAME }}:${{ env.VERSION }} ./src

- name: Push Docker image
run: |
docker push ${{ secrets.USER_SERVICE_NAME }}:${{ env.VERSION }}

- name: Push tag
run: |
git config user.name "github-actions"
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/sonarqube.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Sonarqube Analysis

on:
push:
branches:
- feature-sonarqube # Temporary
pull_request:
branches:
- master
- develop

jobs:
sonarqube:
name: SonarQube
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.24

- name: Cache Go modules
uses: actions/cache@v4
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-

- name: SonarQube Scan
uses: SonarSource/sonarqube-scan-action@v6
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,6 @@ jobs:
run: chmod 400 keys/private_key.key

- name: Run tests
run: make test_integration
run: |
chmod +x ./run-integration.sh
make test_integration MODE=ci
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ test-out/
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
# Binaries for programs and plugins.
*.exe
*.exe~
*.dll
Expand All @@ -28,6 +28,7 @@ go.work.sum

# env file
.env
override.env

# Editor/IDE
# .idea/
Expand Down
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
.PHONY: run

# Usage:
# make [command] {MODE}
#
# command := run (default) / test / test_unit / test_integration
# MODE := ci / local
#

run:
echo "Run using infrastructure/"

Expand All @@ -9,5 +16,4 @@ test_unit:
./run-tests.sh

test_integration:
docker compose -f compose.integration.yml up --build --abort-on-container-exit --exit-code-from test-runner
docker compose -f compose.integration.yml down
./run-integration.sh $(MODE)
7 changes: 7 additions & 0 deletions ci.override.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
RESERVATION_SERVICE_PATH=./services/reservation-service
RESERVATION_SERVICE_REPO=https://github.com/book-em/reservation-service.git
RESERVATION_SERVICE_BRANCH=feature-delete-user-complete

ROOM_SERVICE_PATH=./services/room-service
ROOM_SERVICE_REPO=https://github.com/book-em/room-service.git
ROOM_SERVICE_BRANCH=feature-delete-user-complete
124 changes: 122 additions & 2 deletions compose.integration.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
services:
test-runner:
build:
context: ./src
context: ${TEST_RUNNER_PATH}/src
dockerfile: test.Dockerfile
depends_on:
db:
condition: service_healthy
user-service:
condition: service_healthy
room-db:
condition: service_healthy
room-service:
condition: service_healthy
room-images:
condition: service_healthy
reservation-db:
condition: service_healthy
reservation-service:
condition: service_healthy
environment:
JWT_PUBLIC_KEY_PATH: /app/keys/public_key.pem
volumes:
- go-mod-cache:/go/pkg/mod
- ${USER_SERVICE_PATH}/keys/public_key.pem:/app/keys/public_key.pem:ro

user-service:
build:
Expand All @@ -27,6 +40,8 @@ services:
JWT_PRIVATE_KEY_PATH: /app/keys/private_key.key
JWT_PUBLIC_KEY_PATH: /app/keys/public_key.pem
ENABLE_TEST_MODE: "true"
SERVICE_NAME: user-service
DEPLOYMENT_ENV: test
depends_on:
db:
condition: service_healthy
Expand Down Expand Up @@ -56,5 +71,110 @@ services:
timeout: 3s
retries: 5

room-service:
build:
context: ${ROOM_SERVICE_PATH}/src
dockerfile: Dockerfile
image: room-service-test
ports:
- "${ROOM_SERVICE_PORT}:8080"
environment:
DB_HOST: room-db
DB_PORT: 5432
DB_NAME: bookem_roomdb_test
DB_USER: bookem_roomdb_user
DB_PASSWORD: testpass
JWT_PUBLIC_KEY_PATH: /app/keys/public_key.pem
ENABLE_TEST_MODE: "true"
depends_on:
room-db:
condition: service_healthy
volumes:
- ${ROOM_SERVICE_PATH}/keys/public_key.pem:/app/keys/public_key.pem:ro
- room_images:/app/images/

healthcheck:
test: ["CMD-SHELL", "wget --spider --tries=1 --no-verbose http://room-service:8080/healthz || exit 1"]
interval: 3s
timeout: 3s
retries: 5

room-db:
image: postgres:15-alpine
environment:
POSTGRES_DB: bookem_roomdb_test
POSTGRES_USER: bookem_roomdb_user
POSTGRES_PASSWORD: testpass
ports:
- "${ROOM_SERVICE_DB_PORT}:5432"
volumes:
- type: tmpfs
target: /var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"]
interval: 3s
timeout: 3s
retries: 5

room-images:
restart: always
build:
context: ${ROOM_SERVICE_PATH}/nginx
dockerfile: Dockerfile
ports:
- "${ROOM_SERVICE_IMAGES_PORT}:80"
volumes:
- room_images:/usr/share/nginx/html/images/
healthcheck:
test: service nginx status || exit 1
interval: 15s
timeout: 3s
retries: 2

reservation-service:
build:
context: ${RESERVATION_SERVICE_PATH}/src
dockerfile: Dockerfile
image: reservation-service-test
ports:
- "${RESERVATION_SERVICE_PORT}:8080"
environment:
DB_HOST: reservation-db
DB_PORT: 5432
DB_NAME: bookem_reservationdb_test
DB_USER: bookem_reservationdb_user
DB_PASSWORD: testpass
JWT_PUBLIC_KEY_PATH: /app/keys/public_key.pem
ENABLE_TEST_MODE: "true"
depends_on:
reservation-db:
condition: service_healthy
volumes:
- ${RESERVATION_SERVICE_PATH}/keys/public_key.pem:/app/keys/public_key.pem:ro

healthcheck:
test: ["CMD-SHELL", "wget --spider --tries=1 --no-verbose http://reservation-service:8080/healthz || exit 1"]
interval: 3s
timeout: 3s
retries: 5

reservation-db:
image: postgres:15-alpine
environment:
POSTGRES_DB: bookem_reservationdb_test
POSTGRES_USER: bookem_reservationdb_user
POSTGRES_PASSWORD: testpass
ports:
- "${RESERVATION_SERVICE_DB_PORT}:5432"
volumes:
- type: tmpfs
target: /var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"]
interval: 3s
timeout: 3s
retries: 5

volumes:
go-mod-cache:
go-mod-cache:
room_images:
14 changes: 14 additions & 0 deletions default.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
TEST_RUNNER_PATH=.

RESERVATION_SERVICE_PATH=../reservation-service
RESERVATION_SERVICE_PORT=0
RESERVATION_SERVICE_DB_PORT=0

USER_SERVICE_PATH=.
USER_SERVICE_PORT=0
USER_SERVICE_DB_PORT=0

ROOM_SERVICE_PATH=../room-service
ROOM_SERVICE_PORT=0
ROOM_SERVICE_DB_PORT=0
ROOM_SERVICE_IMAGES_PORT=0
58 changes: 58 additions & 0 deletions run-integration.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash
set -e

# run-tests.sh [ci|local]
#
# - ci: Loads default + ci.override.env
# - local: Loads default + override.env

# Determine mode

mode="$1"
if [[ "$mode" != "ci" && "$mode" != "local" ]]; then
echo "Must specify 'ci' or 'local' as first argument"
exit 1
fi

# Determine which env files to read

ENV_FILES=("./default.env")

if [[ "$mode" == "ci" ]]; then
echo "Loading CI overrides..."
ENV_FILES+=("./ci.override.env")
else
echo "Loading local overrides..."
ENV_FILES+=("./override.env")
fi

# Load env files

for file in "${ENV_FILES[@]}"; do
if [[ -f "$file" ]]; then
echo "Loading env vars from $file"
set -o allexport
source "$file"
set +o allexport
else
echo "Skipping missing optional env file: $file"
fi
done

# Clone repos if CI

if [[ "$mode" == "ci" ]]; then
echo "Extracting the test private key for $USER_SERVICE_REPO"
tar -xvzf "$USER_SERVICE_PATH/keys/keys.tar.gz" -C "$USER_SERVICE_PATH/keys"

echo "Cloning $RESERVATION_SERVICE_REPO branch $RESERVATION_SERVICE_REPO into $RESERVATION_SERVICE_PATH"
git clone --branch "$RESERVATION_SERVICE_BRANCH" "$RESERVATION_SERVICE_REPO" "$RESERVATION_SERVICE_PATH"

echo "Cloning $ROOM_SERVICE_REPO branch $ROOM_SERVICE_BRANCH into $ROOM_SERVICE_PATH"
git clone --branch "$ROOM_SERVICE_BRANCH" "$ROOM_SERVICE_REPO" "$ROOM_SERVICE_PATH"
fi

# Run integration tests

docker compose -f ./compose.integration.yml up --build --abort-on-container-exit --exit-code-from test-runner
docker compose -f ./compose.integration.yml down
1 change: 1 addition & 0 deletions services/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*/
14 changes: 14 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
sonar.projectKey=book-em_user-service
sonar.organization=book-em


# This is the name and version displayed in the SonarCloud UI.
sonar.projectName=user-service
sonar.projectVersion=1.0


# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
sonar.sources=.

# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8
Loading
Loading