Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
43 changes: 32 additions & 11 deletions .github/workflows/docker-compose-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,32 @@ jobs:
- name: Wait for services to be healthy
run: |
echo "Waiting for all services to be healthy..."
# Wait for services with health checks to be healthy (4 services) and all services to be up
timeout 300 bash -c 'until [ $(docker compose ps --format "{{.Health}}" | grep -c "healthy") -ge 4 ] && [ $(docker compose ps --format "{{.Status}}" | grep -c "Up") -ge 5 ]; do sleep 5; done'
# Wait for services with health checks to be healthy (7 services) and all services to be up
# Increased timeout to 10 minutes for CI environment
timeout 600 bash -c 'while true; do
echo "=== Detailed Service Status ==="
docker compose ps --format "table {{.Name}}\t{{.Status}}\t{{.Health}}"
echo "=== Unhealthy Services ==="
unhealthy_services=$(docker compose ps --format "{{.Name}} {{.Health}}" | grep -v healthy | grep -v "^[[:space:]]*$" || echo "")
if [ -n "$unhealthy_services" ]; then
echo "$unhealthy_services"
echo "=== Logs for unhealthy services ==="
for service in $(echo "$unhealthy_services" | awk "{print \$1}"); do
echo "--- Logs for $service ---"
docker compose logs --tail=10 "$service" || echo "No logs for $service"
done
else
echo "All services healthy or no health check"
fi
healthy_count=$(docker compose ps --format "{{.Health}}" | grep -c "healthy" || echo "0")
up_count=$(docker compose ps --format "{{.Status}}" | grep -c "Up" || echo "0")
echo "Progress: $healthy_count/7 healthy, $up_count services up"
if [ "$healthy_count" -ge 7 ] && [ "$up_count" -ge 7 ]; then
echo "All services are healthy!"
break
fi
sleep 10
done'
docker compose ps

- name: Test dashboard endpoints
Expand All @@ -45,15 +69,12 @@ jobs:
run: |
echo "=== Docker Compose Services Status ==="
docker compose ps
echo "=== Traefik Logs ==="
docker compose logs traefik
echo "=== Sticker Award Logs ==="
docker compose logs sticker-award
echo "=== User Management Logs ==="
docker compose logs user-management
echo "=== Database Logs ==="
docker compose logs sticker-award-db
docker compose logs user-management-db
echo "=== All Service Logs ==="
docker compose logs --tail=50
echo "=== Health Check Details ==="
docker compose ps --format "table {{.Name}}\t{{.Status}}\t{{.Health}}"
echo "=== Resource Usage ==="
docker stats --no-stream

- name: Cleanup
if: always()
Expand Down
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ services:
QUARKUS_S3_AWS_CREDENTIALS_STATIC_PROVIDER_SECRET_ACCESS_KEY: minioadmin
QUARKUS_S3_PATH_STYLE_ACCESS: "true"
STICKER_IMAGES_BUCKET: sticker-images
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
interval: 10s
timeout: 5s
retries: 5
labels:
- "traefik.enable=true"
- "traefik.http.routers.sticker-award.rule=PathPrefix(`/api/award`)"
Expand All @@ -210,6 +215,11 @@ services:
KAFKA__BOOTSTRAPSERVERS: "redpanda:9092"
KAFKA__SCHEMAREGISTRY: "http://redpanda:8082"
KAFKA__GROUPID: "stickerlandia-user-management"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/api/users/v1/health"]
interval: 10s
timeout: 5s
retries: 5
labels:
- "traefik.enable=true"
- "traefik.http.routers.user-management.rule=PathPrefix(`/api/users`)"
Expand Down
83 changes: 83 additions & 0 deletions sticker-award/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,86 @@ The API returns standard HTTP status codes and follows the RFC 7807 Problem Deta
Full API documentation is available in OpenAPI format:
- Synchronous API: [api.yaml](./docs/api.yaml)
- Asynchronous API: [async_api.json](./docs/async_api.json)

## Building and Running

### Prerequisites
- Java 21+
- Maven 3.8+

### Development

Run in development mode:
```bash
./mvnw compile quarkus:dev
```

### Testing

Run tests:
```bash
./mvnw test
```

Run integration tests:
```bash
./mvnw verify
```

## Code Quality

This project enforces high code quality through multiple static analysis tools:

### Error Prone

This project uses Error Prone to catch common Java programming mistakes at compile time.

**Error Prone Integration:**
- Runs automatically during compilation (`./mvnw compile`)
- Catches bugs like incorrect Date usage, unused variables, and charset issues
- Configured in the Maven compiler plugin
- Uses Error Prone version 2.38.0

**Common Error Prone checks include:**
- `JavaUtilDate` - Flags usage of legacy `java.util.Date` API
- `UnusedVariable` - Detects unused fields and variables
- `DefaultCharset` - Warns about implicit charset usage in string operations

### Checkstyle

This project uses Checkstyle to enforce coding standards based on the Google Java Style Guide.

**Run Checkstyle validation:**
```bash
# Check code style (runs automatically during build)
./mvnw validate

# Run only Checkstyle check
./mvnw checkstyle:check

# Generate Checkstyle report (creates HTML report at target/reports/checkstyle.html)
./mvnw checkstyle:checkstyle
```

### Spotless (Code Formatting)

This project uses Spotless with Google Java Format to automatically fix code style issues.

**Format your code:**
```bash
# Check if code formatting is correct
./mvnw spotless:check

# Automatically fix code formatting issues
./mvnw spotless:apply

# Format and then validate with Checkstyle
./mvnw spotless:apply validate
```

**Checkstyle Configuration:**
- Configuration file: `checkstyle.xml`
- Suppressions file: `checkstyle-suppressions.xml`
- Based on Google Java Style Guide (modified for 4-space indentation)
- Enforces 4-space indentation, 100-character line limit
- Checks import ordering, Javadoc completeness, and naming conventions
42 changes: 42 additions & 0 deletions sticker-award/checkstyle-suppressions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0"?>

<!DOCTYPE suppressions PUBLIC
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
"https://checkstyle.org/dtds/suppressions_1_2.dtd">

<!--
Checkstyle suppressions file for Sticker Award application.

This file allows you to suppress specific Checkstyle violations for certain files or patterns.
Use this sparingly and only when necessary.

Examples:
- Generated code that you don't control
- Third-party code
- Specific patterns that are acceptable in your codebase
-->

<suppressions>
<!-- Suppress all checks for generated files -->
<suppress files=".*[\\/]generated[\\/].*\.java" checks=".*"/>

<!-- Suppress line length checks for test files with long URLs or test data -->
<suppress files=".*Test\.java" checks="LineLength" lines="1-999999"/>

<!-- Allow missing Javadoc for test methods -->
<suppress files=".*Test\.java" checks="MissingJavadocMethod"/>
<suppress files=".*Test\.java" checks="JavadocMethod"/>

<!-- Allow missing Javadoc for test classes -->
<suppress files=".*Test\.java" checks="MissingJavadocType"/>

<!-- Suppress abbreviation checks for common patterns like DTO, API, etc. -->
<suppress files=".*DTO\.java" checks="AbbreviationAsWordInName"/>
<suppress files=".*API\.java" checks="AbbreviationAsWordInName"/>

<!-- Allow longer lines in configuration classes -->
<suppress files=".*Config\.java" checks="LineLength"/>

<!-- Suppress checks for application main classes -->
<suppress files=".*Application\.java" checks="HideUtilityClassConstructor"/>
</suppressions>
Loading
Loading