Skip to content
Merged
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
41 changes: 41 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "Java Orders Service Dev",
"image": "mcr.microsoft.com/devcontainers/java:21",
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/devcontainers/features/java:1": {
"version": "21",
"installGradle": "false",
"installMaven": "true"
}
},
"postCreateCommand": "bash .devcontainer/scripts/postCreate.sh",
"customizations": {
"vscode": {
"settings": {
"terminal.integrated.defaultProfile.linux": "bash",
"java.home": "/usr/local/openjdk-21",
"java.configuration.updateBuildConfiguration": "automatic"
},
"extensions": [
"vscjava.vscode-java-pack",
"redhat.java",
"vscjava.vscode-java-debug",
"vscjava.vscode-java-test",
"vscjava.vscode-maven",
"vscjava.vscode-java-dependency"
]
}
},
"mounts": [
"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind"
],
"forwardPorts": [8080],
"portsAttributes": {
"8080": {
"label": "Orders Service",
"onAutoForward": "notify"
}
},
"remoteUser": "vscode"
}
52 changes: 52 additions & 0 deletions .devcontainer/scripts/postCreate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

echo "🚀 Setting up Java retail orders service development environment..."

# Make sure we're in the workspace
cd /workspaces/java-retail-orders-service

# Install dependencies
echo "📚 Installing dependencies..."
mvn dependency:resolve

# Build the project with annotation processing
echo "🔨 Building project with annotation processing..."
if mvn --no-transfer-progress compile; then
echo "✅ Project compiled successfully!"
else
echo "⚠️ Compilation failed. Manual intervention may be required."
echo "💡 Try running: mvn clean compile manually"
fi

# Clean build artifacts for fresh start
echo "🧹 Cleaning build artifacts..."
mvn clean

# Run tests to validate environment
echo "🧪 Running tests to validate environment..."
if mvn test; then
echo "✅ Tests passed successfully!"
else
echo "⚠️ Tests failed, but continuing with setup..."
echo "💡 You may need to fix compilation issues before running tests again"
fi

echo "✅ Java retail orders service development environment setup complete!"
echo ""
echo "🔄 Automatically completed:"
echo " ✅ Dependencies installed"
echo " ✅ Project compiled"
echo " ✅ Build artifacts cleaned"
echo " ✅ Environment validated"
echo ""
echo "📋 Available manual commands:"
echo " mvn spring-boot:run - Start the orders service"
echo " mvn test - Run tests again"
echo " mvn package - Build JAR file"
echo " mvn clean - Clean build artifacts"
echo " mvn compile - Recompile after fixes"
echo ""
echo "🔧 Troubleshooting commands:"
echo " mvn clean compile - Clean and recompile"
echo " mvn dependency:tree - Check dependency conflicts"
echo " mvn validate - Validate project configuration"
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Dockerfile
.dockerignore
docker-compose.yml
.gitignore
chart
scripts
target
.idea
167 changes: 167 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
name: Retail Orders Service CI/CD

on:
pull_request:
branches: [main]
push:
branches: [main]
tags: ["v*"]
paths-ignore:
- "**.md"
- "LICENSE"
- ".gitignore"
- ".vscode/**"
- ".devcontainer/**"

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}/retail-orders-service

permissions:
contents: read
pull-requests: write
security-events: write
checks: write
statuses: write
packages: write

jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "21"
cache: "maven"

- name: Run tests
run: mvn test

validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "21"
cache: "maven"

- name: Build Java application
run: mvn clean package -DskipTests

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Validate container build
run: |
# Test that the container builds successfully
docker build -t retail-orders-service:test .
echo "✅ Container builds successfully"

- name: Validate container health check
run: |
# Test container startup and shutdown
echo "🧪 Testing container startup and shutdown..."
docker run -d --name test-container retail-orders-service:test
sleep 10

# Check if container is running
if docker ps --filter "name=test-container" --filter "status=running" --quiet; then
echo "✅ Container started successfully"
else
echo "❌ Container failed to start"
docker logs test-container
exit 1
fi

# Clean up
docker stop test-container
docker rm test-container
echo "✅ Container health check works"

- name: Security scan
run: |
# Basic security checks
echo "🔍 Checking for common security issues..."

# Check for hardcoded secrets (basic check)
if grep -r "password\|secret\|key\|token" src/ --exclude="*.java" --exclude="*.xml" --exclude="*.yml" 2>/dev/null; then
echo "⚠️ Potential hardcoded secrets found"
fi

# Check Maven dependencies for vulnerabilities
if mvn dependency:check; then
echo "✅ No dependency vulnerabilities found"
else
echo "⚠️ Vulnerabilities found in dependencies"
fi

echo "✅ Basic security checks completed"

- name: Validation Summary
run: |
echo "🎉 All validations passed!"
echo "✅ Dependencies installed successfully"
echo "✅ Java application builds successfully"
echo "✅ Container builds successfully"
echo "✅ Container health check works"
echo "✅ Security checks completed"

build-and-push:
needs: [validate, test]
runs-on: ubuntu-latest
if: github.event_name == 'push'
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "21"
cache: "maven"

- name: Build Java application
run: mvn clean package -DskipTests

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=tag

- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
12 changes: 12 additions & 0 deletions .github/workflows/commitmsg-conform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Commit Message Conformance
on:
pull_request:
branches: [main]
permissions:
statuses: write
checks: write
contents: read
pull-requests: read
jobs:
commitmsg-conform:
uses: actionsforge/actions/.github/workflows/commitmsg-conform.yml@main
15 changes: 15 additions & 0 deletions .github/workflows/markdown-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Markdown Lint

on:
pull_request:
branches: [main]

permissions:
statuses: write
checks: write
contents: read
pull-requests: read

jobs:
markdown-lint:
uses: actionsforge/actions/.github/workflows/markdown-lint.yml@main
31 changes: 31 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
HELP.md
target/
.mvn/wrapper/maven-wrapper.jar
!**/src/main/**
!**/src/test/**

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/

### VS Code ###
.vscode/
14 changes: 14 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"default": true,
"whitespace": false,
"line_length": false,
"ul-start-left": false,
"ul-indent": false,
"no-inline-html": false,
"no-bare-urls": false,
"fenced-code-language": false,
"first-line-h1": false,
"no-duplicate-header": false,
"no-emphasis-as-header": false,
"single-h1": false
}
1 change: 1 addition & 0 deletions .markdownlintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ATTRIBUTION.md
19 changes: 19 additions & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
wrapperVersion=3.3.2
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.1/apache-maven-3.9.1-bin.zip
Loading