Compare commits
18 Commits
02674dfb50
...
a0d2bd6996
| Author | SHA1 | Date | |
|---|---|---|---|
| a0d2bd6996 | |||
| 07dc72d19e | |||
| 076bc120e0 | |||
| 0026515237 | |||
| 543e9e240a | |||
| 5ffa60ef65 | |||
| f18716d447 | |||
| cf13b44e0d | |||
| f8474b69c1 | |||
| 6c2399bea6 | |||
| a1804d7aec | |||
| 22099d0ac6 | |||
| 18213f365d | |||
| 9528b7d288 | |||
| f54c60c6a3 | |||
| 9213c97da6 | |||
| da0dc0e30f | |||
| 2ca361ccd9 |
@@ -152,58 +152,28 @@ jobs:
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
registry: ${{ env.CI_REGISTRY }}
|
|
||||||
username: ${{ github.actor }}
|
|
||||||
password: ${{ secrets.PACKAGES_TOKEN }}
|
|
||||||
|
|
||||||
- name: Set up build environment
|
- name: Set up build environment
|
||||||
run: |
|
run: |
|
||||||
IMAGE_NAME="${{ env.CI_REGISTRY }}/${{ env.GITEA_ORG }}/${{ env.GITEA_REPO }}-build-cache:${{ needs.build-cache.outputs.deps_hash }}"
|
IMAGE_NAME="${{ env.CI_REGISTRY }}/${{ env.GITEA_ORG }}/${{ env.GITEA_REPO }}-build-cache:${{ needs.build-cache.outputs.deps_hash }}"
|
||||||
echo "Build cache image: $IMAGE_NAME"
|
echo "Build cache image: $IMAGE_NAME"
|
||||||
|
|
||||||
# Try to use Docker cache if available
|
|
||||||
if docker pull "$IMAGE_NAME" >/dev/null 2>&1; then
|
|
||||||
echo "✅ Using Docker build cache"
|
|
||||||
echo "CACHE_AVAILABLE=true" >> $GITHUB_ENV
|
|
||||||
echo "CACHE_IMAGE=$IMAGE_NAME" >> $GITHUB_ENV
|
echo "CACHE_IMAGE=$IMAGE_NAME" >> $GITHUB_ENV
|
||||||
else
|
|
||||||
echo "⚠️ Building without cache (first run or new dependencies)"
|
# Cache is guaranteed to be available since build-cache job succeeded
|
||||||
echo "CACHE_AVAILABLE=false" >> $GITHUB_ENV
|
echo "✅ Using Docker build cache (guaranteed by build-cache job)"
|
||||||
fi
|
echo "CACHE_AVAILABLE=true" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Start build cache container with Docker Compose
|
- name: Start build cache container with Docker Compose
|
||||||
run: |
|
run: |
|
||||||
if [ "${{ env.CACHE_AVAILABLE }}" = "true" ]; then
|
|
||||||
echo "Starting build cache container..."
|
echo "Starting build cache container..."
|
||||||
export DEPS_HASH="${{ needs.build-cache.outputs.deps_hash }}"
|
export DEPS_HASH="${{ needs.build-cache.outputs.deps_hash }}"
|
||||||
docker compose -f docker-compose.build.yml up -d build-cache
|
docker compose -f docker-compose.build.yml up -d build-cache
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Generate Swagger Docs using Docker Compose
|
- name: Generate Swagger Docs using Docker Compose
|
||||||
run: |
|
run: docker compose -f docker-compose.build.yml exec -w /workspace/pkg/server build-cache sh -c "go generate"
|
||||||
if [ "${{ env.CACHE_AVAILABLE }}" = "true" ]; then
|
|
||||||
echo "Running in Docker Compose container..."
|
|
||||||
docker compose -f docker-compose.build.yml exec -w /workspace/pkg/server build-cache sh -c "go generate"
|
|
||||||
else
|
|
||||||
echo "Running natively..."
|
|
||||||
cd pkg/server && go generate
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Build all packages using Docker Compose
|
- name: Build all packages using Docker Compose
|
||||||
run: |
|
run: docker compose -f docker-compose.build.yml exec -w /workspace build-cache sh -c "go build ./..."
|
||||||
if [ "${{ env.CACHE_AVAILABLE }}" = "true" ]; then
|
|
||||||
echo "Running in Docker Compose container..."
|
|
||||||
docker compose -f docker-compose.build.yml exec -w /workspace build-cache sh -c "go build ./..."
|
|
||||||
else
|
|
||||||
echo "Running natively..."
|
|
||||||
go build ./...
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Wait for PostgreSQL to be ready
|
- name: Wait for PostgreSQL to be ready
|
||||||
run: |
|
run: |
|
||||||
@@ -225,7 +195,6 @@ jobs:
|
|||||||
|
|
||||||
- name: Run tests with coverage using Docker Compose
|
- name: Run tests with coverage using Docker Compose
|
||||||
run: |
|
run: |
|
||||||
if [ "${{ env.CACHE_AVAILABLE }}" = "true" ]; then
|
|
||||||
echo "Running in Docker Compose container with PostgreSQL..."
|
echo "Running in Docker Compose container with PostgreSQL..."
|
||||||
docker compose -f docker-compose.build.yml exec \
|
docker compose -f docker-compose.build.yml exec \
|
||||||
-e PGHOST=dance-lessons-coach-postgres \
|
-e PGHOST=dance-lessons-coach-postgres \
|
||||||
@@ -236,16 +205,6 @@ jobs:
|
|||||||
-w /workspace \
|
-w /workspace \
|
||||||
build-cache \
|
build-cache \
|
||||||
sh -c "go test ./... -coverprofile=coverage.out -v && go tool cover -func=coverage.out > coverage.txt"
|
sh -c "go test ./... -coverprofile=coverage.out -v && go tool cover -func=coverage.out > coverage.txt"
|
||||||
else
|
|
||||||
echo "Running natively with Docker Compose PostgreSQL..."
|
|
||||||
export PGHOST=dance-lessons-coach-postgres
|
|
||||||
export PGPORT=5432
|
|
||||||
export PGUSER=postgres
|
|
||||||
export PGPASSWORD=postgres
|
|
||||||
export PGDATABASE=dance_lessons_coach_bdd_test
|
|
||||||
go test ./... -coverprofile=coverage.out -v
|
|
||||||
go tool cover -func=coverage.out > coverage.txt
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Extract coverage percentage
|
# Extract coverage percentage
|
||||||
COVERAGE=$(grep "total:" coverage.txt | grep -oP '\d+\.\d+' | head -1)
|
COVERAGE=$(grep "total:" coverage.txt | grep -oP '\d+\.\d+' | head -1)
|
||||||
@@ -263,7 +222,7 @@ jobs:
|
|||||||
run: swag fmt
|
run: swag fmt
|
||||||
|
|
||||||
- name: Build binaries
|
- name: Build binaries
|
||||||
run: ./scripts/build.sh
|
run: docker compose -f docker-compose.build.yml exec -w /workspace build-cache sh -c "./scripts/build.sh"
|
||||||
|
|
||||||
# NOTE: Artifact upload disabled - actions/upload-artifact@v4 not available on Gitea
|
# NOTE: Artifact upload disabled - actions/upload-artifact@v4 not available on Gitea
|
||||||
# TODO: Replace with Gitea-specific upload action when available
|
# TODO: Replace with Gitea-specific upload action when available
|
||||||
|
|||||||
@@ -13,4 +13,11 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
- GOPATH=/go
|
- GOPATH=/go
|
||||||
- PATH=/go/bin:/usr/local/go/bin:/usr/local/bin:/usr/bin:/bin
|
- PATH=/go/bin:/usr/local/go/bin:/usr/local/bin:/usr/bin:/bin
|
||||||
|
networks:
|
||||||
|
- dance-lessons-coach-network
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
|
networks:
|
||||||
|
dance-lessons-coach-network:
|
||||||
|
name: dance-lessons-coach-network
|
||||||
|
driver: bridge
|
||||||
@@ -15,6 +15,8 @@ services:
|
|||||||
interval: 5s
|
interval: 5s
|
||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 5
|
retries: 5
|
||||||
|
networks:
|
||||||
|
- dance-lessons-coach-network
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
# Application service (for reference)
|
# Application service (for reference)
|
||||||
@@ -38,3 +40,8 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
postgres_data:
|
postgres_data:
|
||||||
driver: local
|
driver: local
|
||||||
|
|
||||||
|
networks:
|
||||||
|
dance-lessons-coach-network:
|
||||||
|
name: dance-lessons-coach-network
|
||||||
|
driver: bridge
|
||||||
@@ -15,6 +15,8 @@ import (
|
|||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// getPostgresHost returns the appropriate PostgreSQL host based on environment
|
||||||
|
|
||||||
type Server struct {
|
type Server struct {
|
||||||
httpServer *http.Server
|
httpServer *http.Server
|
||||||
port int
|
port int
|
||||||
@@ -237,6 +239,11 @@ func (s *Server) GetBaseURL() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func createTestConfig(port int) *config.Config {
|
func createTestConfig(port int) *config.Config {
|
||||||
|
// Load actual config to respect environment variables
|
||||||
|
cfg, err := config.LoadConfig()
|
||||||
|
if err != nil {
|
||||||
|
log.Warn().Err(err).Msg("Failed to load config, using defaults")
|
||||||
|
// Fallback to defaults if config loading fails
|
||||||
return &config.Config{
|
return &config.Config{
|
||||||
Server: config.ServerConfig{
|
Server: config.ServerConfig{
|
||||||
Host: "localhost",
|
Host: "localhost",
|
||||||
@@ -260,7 +267,7 @@ func createTestConfig(port int) *config.Config {
|
|||||||
AdminMasterPassword: "admin123",
|
AdminMasterPassword: "admin123",
|
||||||
},
|
},
|
||||||
Database: config.DatabaseConfig{
|
Database: config.DatabaseConfig{
|
||||||
Host: "localhost",
|
Host: "localhost", // Fallback if env vars not set
|
||||||
Port: 5432,
|
Port: 5432,
|
||||||
User: "postgres",
|
User: "postgres",
|
||||||
Password: "postgres",
|
Password: "postgres",
|
||||||
@@ -272,3 +279,18 @@ func createTestConfig(port int) *config.Config {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Override server port for testing
|
||||||
|
cfg.Server.Port = port
|
||||||
|
cfg.API.V2Enabled = true // Ensure v2 is enabled for testing
|
||||||
|
|
||||||
|
// Set default auth values if not configured
|
||||||
|
if cfg.Auth.JWTSecret == "" {
|
||||||
|
cfg.Auth.JWTSecret = "default-secret-key-please-change-in-production"
|
||||||
|
}
|
||||||
|
if cfg.Auth.AdminMasterPassword == "" {
|
||||||
|
cfg.Auth.AdminMasterPassword = "admin123"
|
||||||
|
}
|
||||||
|
|
||||||
|
return cfg
|
||||||
|
}
|
||||||
|
|||||||
@@ -188,6 +188,14 @@ func LoadConfig() (*Config, error) {
|
|||||||
// API environment variables
|
// API environment variables
|
||||||
v.BindEnv("api.v2_enabled", "DLC_API_V2_ENABLED")
|
v.BindEnv("api.v2_enabled", "DLC_API_V2_ENABLED")
|
||||||
|
|
||||||
|
// Database environment variables
|
||||||
|
v.BindEnv("database.host", "DLC_DATABASE_HOST")
|
||||||
|
v.BindEnv("database.port", "DLC_DATABASE_PORT")
|
||||||
|
v.BindEnv("database.user", "DLC_DATABASE_USER")
|
||||||
|
v.BindEnv("database.password", "DLC_DATABASE_PASSWORD")
|
||||||
|
v.BindEnv("database.name", "DLC_DATABASE_NAME")
|
||||||
|
v.BindEnv("database.ssl_mode", "DLC_DATABASE_SSL_MODE")
|
||||||
|
|
||||||
// Unmarshal into Config struct
|
// Unmarshal into Config struct
|
||||||
var config Config
|
var config Config
|
||||||
if err := v.Unmarshal(&config); err != nil {
|
if err := v.Unmarshal(&config); err != nil {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
# Simulates the CI/CD pipeline but builds Docker image locally
|
# Simulates the CI/CD pipeline but builds Docker image locally
|
||||||
# Use this for local development and testing without Gitea
|
# Use this for local development and testing without Gitea
|
||||||
|
|
||||||
set -e
|
set -eu
|
||||||
|
|
||||||
echo "🚀 Local CI/CD Testing"
|
echo "🚀 Local CI/CD Testing"
|
||||||
echo "======================"
|
echo "======================"
|
||||||
@@ -16,53 +16,162 @@ if ! command -v go >/dev/null 2>&1; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Assume Docker is available (required for this workflow)
|
||||||
if ! command -v docker >/dev/null 2>&1; then
|
if ! command -v docker >/dev/null 2>&1; then
|
||||||
echo "⚠️ Docker not found. Docker build steps will be skipped"
|
echo "❌ Docker is required for this CI/CD workflow"
|
||||||
HAS_DOCKER=false
|
echo "Please install Docker and Docker Compose plugin"
|
||||||
else
|
exit 1
|
||||||
HAS_DOCKER=true
|
fi
|
||||||
|
|
||||||
|
# Check for docker compose plugin
|
||||||
|
if ! docker compose version >/dev/null 2>&1; then
|
||||||
|
echo "⚠️ Docker Compose plugin not found. Installing..."
|
||||||
|
sudo apt-get update && sudo apt-get install -y docker-compose-plugin
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "✅ Environment ready"
|
echo "✅ Environment ready"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# 2. Install dependencies
|
# 2. Calculate dependency hash (match CI workflow)
|
||||||
echo "2. Installing dependencies..."
|
echo "2. Calculating dependency hash..."
|
||||||
go mod tidy
|
# Use shasum on macOS, sha256sum on Linux
|
||||||
echo "✅ Dependencies installed"
|
if command -v sha256sum >/dev/null 2>&1; then
|
||||||
|
export DEPS_HASH=$(sha256sum go.mod go.sum | sha256sum | cut -d' ' -f1 | head -c 12)
|
||||||
|
else
|
||||||
|
export DEPS_HASH=$(shasum -a 256 go.mod go.sum | shasum -a 256 | cut -d' ' -f1 | head -c 12)
|
||||||
|
fi
|
||||||
|
echo "Dependency hash: $DEPS_HASH"
|
||||||
|
echo "✅ Dependency hash calculated"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# 3. Install swag and generate docs
|
# 3. Check for Docker cache
|
||||||
echo "3. Generating Swagger documentation..."
|
echo "3. Checking for Docker build cache..."
|
||||||
if [ ! -f pkg/server/docs/swagger.json ]; then
|
IMAGE_NAME="gitea.arcodange.lab/arcodange/dance-lessons-coach-build-cache:$DEPS_HASH"
|
||||||
echo "📝 Generating Swagger docs..."
|
|
||||||
go install github.com/swaggo/swag/cmd/swag@latest
|
# Try to pull the cache image
|
||||||
cd pkg/server && go generate
|
if docker pull "$IMAGE_NAME" >/dev/null 2>&1; then
|
||||||
cd ../..
|
echo "✅ Cache hit - using existing build cache"
|
||||||
echo "✅ Swagger documentation generated"
|
USE_DOCKER_CACHE=true
|
||||||
else
|
else
|
||||||
echo "✅ Swagger documentation already exists"
|
echo "⚠️ Cache miss - will build without cache"
|
||||||
|
USE_DOCKER_CACHE=false
|
||||||
fi
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# 4. Build and test
|
# 4. Start PostgreSQL with Docker Compose
|
||||||
echo "4. Building and testing..."
|
echo "4. Starting PostgreSQL..."
|
||||||
|
docker compose -f docker-compose.yml up -d postgres
|
||||||
|
|
||||||
|
# Wait for PostgreSQL to be ready
|
||||||
|
echo "Waiting for PostgreSQL to be ready..."
|
||||||
|
for i in {1..30}; do
|
||||||
|
if docker exec dance-lessons-coach-postgres pg_isready -U postgres; then
|
||||||
|
echo "✅ PostgreSQL is ready!"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
echo "Waiting for PostgreSQL... ($i/30)"
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
|
||||||
|
# Set PostgreSQL environment variables for BDD tests
|
||||||
|
export DLC_DATABASE_HOST="localhost" # PostgreSQL port is mapped to host
|
||||||
|
export DLC_DATABASE_PORT=5432
|
||||||
|
export DLC_DATABASE_USER=postgres
|
||||||
|
export DLC_DATABASE_PASSWORD=postgres
|
||||||
|
export DLC_DATABASE_NAME=dance_lessons_coach_bdd_test
|
||||||
|
export DLC_DATABASE_SSL_MODE=disable
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# 5. Install dependencies
|
||||||
|
if [ "$USE_DOCKER_CACHE" = true ]; then
|
||||||
|
echo "5. Checking dependencies..."
|
||||||
|
echo "✅ Using pre-installed dependencies from Docker cache"
|
||||||
|
else
|
||||||
|
echo "5. Installing dependencies..."
|
||||||
|
go mod tidy
|
||||||
|
fi
|
||||||
|
echo "✅ Dependencies ready"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# 6. Generate Swagger Docs
|
||||||
|
if [ "$USE_DOCKER_CACHE" = true ]; then
|
||||||
|
echo "6. Generating Swagger documentation..."
|
||||||
|
echo "Running in Docker container..."
|
||||||
|
docker run --rm \
|
||||||
|
--network dance-lessons-coach-network \
|
||||||
|
-v "$(pwd):/workspace" \
|
||||||
|
-w /workspace/pkg/server \
|
||||||
|
"$IMAGE_NAME" \
|
||||||
|
sh -c "go generate"
|
||||||
|
else
|
||||||
|
echo "6. Generating Swagger documentation..."
|
||||||
|
echo "Running natively..."
|
||||||
|
cd pkg/server && go generate
|
||||||
|
cd ../..
|
||||||
|
fi
|
||||||
|
echo "✅ Swagger documentation generated"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# 7. Build and test
|
||||||
|
if [ "$USE_DOCKER_CACHE" = true ]; then
|
||||||
|
echo "7. Building and testing..."
|
||||||
|
echo "Running in Docker container..."
|
||||||
|
docker run --rm \
|
||||||
|
--network dance-lessons-coach-network \
|
||||||
|
-v "$(pwd):/workspace" \
|
||||||
|
-w /workspace \
|
||||||
|
"$IMAGE_NAME" \
|
||||||
|
sh -c "go build ./..."
|
||||||
|
else
|
||||||
|
echo "7. Building and testing..."
|
||||||
|
echo "Running natively..."
|
||||||
go build ./...
|
go build ./...
|
||||||
|
fi
|
||||||
echo "✅ Code compiled successfully"
|
echo "✅ Code compiled successfully"
|
||||||
|
|
||||||
go test ./... -cover -v
|
if [ "$USE_DOCKER_CACHE" = true ]; then
|
||||||
|
echo "Running in Docker container with PostgreSQL..."
|
||||||
|
docker run --rm \
|
||||||
|
--network dance-lessons-coach-network \
|
||||||
|
-v "$(pwd):/workspace" \
|
||||||
|
-w /workspace \
|
||||||
|
-e DLC_DATABASE_HOST=dance-lessons-coach-postgres \
|
||||||
|
-e DLC_DATABASE_PORT=5432 \
|
||||||
|
-e DLC_DATABASE_USER=postgres \
|
||||||
|
-e DLC_DATABASE_PASSWORD=postgres \
|
||||||
|
-e DLC_DATABASE_NAME=dance_lessons_coach_bdd_test \
|
||||||
|
-e DLC_DATABASE_SSL_MODE=disable \
|
||||||
|
"$IMAGE_NAME" \
|
||||||
|
sh -c "go test ./... -coverprofile=coverage.out -v && go tool cover -func=coverage.out > coverage.txt"
|
||||||
|
else
|
||||||
|
echo "Running natively with Docker Compose PostgreSQL..."
|
||||||
|
go test ./... -coverprofile=coverage.out -v
|
||||||
|
go tool cover -func=coverage.out > coverage.txt
|
||||||
|
fi
|
||||||
echo "✅ Tests passed"
|
echo "✅ Tests passed"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# 5. Build binaries
|
# 8. Build binaries
|
||||||
echo "5. Building binaries..."
|
if [ "$USE_DOCKER_CACHE" = true ]; then
|
||||||
|
echo "8. Building binaries..."
|
||||||
|
echo "Running in Docker container..."
|
||||||
|
docker run --rm \
|
||||||
|
--network dance-lessons-coach-network \
|
||||||
|
-v "$(pwd):/workspace" \
|
||||||
|
-w /workspace \
|
||||||
|
"$IMAGE_NAME" \
|
||||||
|
sh -c "./scripts/build.sh"
|
||||||
|
else
|
||||||
|
echo "8. Building binaries..."
|
||||||
|
echo "Running natively..."
|
||||||
./scripts/build.sh
|
./scripts/build.sh
|
||||||
|
fi
|
||||||
echo "✅ Binaries built"
|
echo "✅ Binaries built"
|
||||||
ls -la bin/
|
ls -la bin/
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# 6. Version bump simulation
|
# 9. Version bump simulation
|
||||||
echo "6. Version bump simulation..."
|
echo "9. Version bump simulation..."
|
||||||
LAST_COMMIT=$(git log -1 --pretty=%B | head -1)
|
LAST_COMMIT=$(git log -1 --pretty=%B | head -1)
|
||||||
echo "Last commit: $LAST_COMMIT"
|
echo "Last commit: $LAST_COMMIT"
|
||||||
|
|
||||||
@@ -85,8 +194,7 @@ CURRENT_VERSION="$MAJOR.$MINOR.$PATCH${PRERELEASE:+-$PRERELEASE}"
|
|||||||
echo "📊 Current version: $CURRENT_VERSION"
|
echo "📊 Current version: $CURRENT_VERSION"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# 7. Local Docker build instructions
|
# 10. Local Docker build instructions
|
||||||
if [ "$HAS_DOCKER" = true ]; then
|
|
||||||
echo "🐳 LOCAL DOCKER BUILD INSTRUCTIONS"
|
echo "🐳 LOCAL DOCKER BUILD INSTRUCTIONS"
|
||||||
echo "================================"
|
echo "================================"
|
||||||
echo ""
|
echo ""
|
||||||
@@ -109,22 +217,22 @@ if [ "$HAS_DOCKER" = true ]; then
|
|||||||
echo " docker tag dance-lessons-coach:$CURRENT_VERSION dance-lessons-coach:latest"
|
echo " docker tag dance-lessons-coach:$CURRENT_VERSION dance-lessons-coach:latest"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
echo "3. Test the local image (check port availability first):"
|
echo "5. Test the local image (check port availability first):"
|
||||||
echo " docker run -d -p 8080:8080 dance-lessons-coach:$CURRENT_VERSION"
|
echo " docker run -d -p 8080:8080 dance-lessons-coach:$CURRENT_VERSION"
|
||||||
echo " # Or use alternative port if 8080 is in use:"
|
echo " # Or use alternative port if 8080 is in use:"
|
||||||
echo " docker run -d -p 8081:8080 dance-lessons-coach:$CURRENT_VERSION"
|
echo " docker run -d -p 8081:8080 dance-lessons-coach:$CURRENT_VERSION"
|
||||||
echo ""
|
echo ""
|
||||||
echo "4. Branch-specific container naming (recommended):"
|
echo "6. Branch-specific container naming (recommended):"
|
||||||
echo " BRANCH=\"(git rev-parse --abbrev-ref HEAD | tr '/' '-')"
|
echo " BRANCH=\"$(git rev-parse --abbrev-ref HEAD | tr '/' '-')\""
|
||||||
echo " docker run -d -p 8080:8080 --name dance-lessons-coach-\"$BRANCH\" dance-lessons-coach:$CURRENT_VERSION"
|
echo " docker run -d -p 8080:8080 --name dance-lessons-coach-\"$BRANCH\" dance-lessons-coach:$CURRENT_VERSION"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
echo "5. Test API endpoints:"
|
echo "7. Test API endpoints:"
|
||||||
echo " curl http://localhost:8080/api/health"
|
echo " curl http://localhost:8080/api/health"
|
||||||
echo " curl http://localhost:8080/api/v1/greet/YourName"
|
echo " curl http://localhost:8080/api/v1/greet/YourName"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
echo "5. Clean up:"
|
echo "8. Clean up:"
|
||||||
echo " docker stop <container_id> && docker rm <container_id>"
|
echo " docker stop <container_id> && docker rm <container_id>"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
@@ -251,29 +359,28 @@ if [ "$HAS_DOCKER" = true ]; then
|
|||||||
echo " Or run: docker stop $CONTAINER_NAME && docker rm $CONTAINER_NAME"
|
echo " Or run: docker stop $CONTAINER_NAME && docker rm $CONTAINER_NAME"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
echo "ℹ️ Docker not available - skipping Docker build instructions"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "✅ LOCAL CI/CD TEST COMPLETE"
|
echo "✅ LOCAL CI/CD TEST COMPLETE"
|
||||||
echo "==========================="
|
echo "==========================="
|
||||||
echo ""
|
echo ""
|
||||||
echo "📋 What was tested:"
|
echo "📋 What was tested:"
|
||||||
|
echo " ✅ Dependency hash calculation (matching CI workflow)"
|
||||||
|
echo " ✅ Docker cache detection and usage"
|
||||||
|
echo " ✅ PostgreSQL service with Docker Compose"
|
||||||
echo " ✅ Go dependencies installation"
|
echo " ✅ Go dependencies installation"
|
||||||
echo " ✅ Swagger documentation generation"
|
echo " ✅ Swagger documentation generation"
|
||||||
echo " ✅ Code compilation"
|
echo " ✅ Code compilation"
|
||||||
echo " ✅ Unit tests with coverage"
|
echo " ✅ Unit tests with coverage"
|
||||||
echo " ✅ Binary build"
|
echo " ✅ Binary build"
|
||||||
echo " ✅ Version bump simulation"
|
echo " ✅ Version bump simulation"
|
||||||
if [ "$HAS_DOCKER" = true ]; then
|
|
||||||
echo " ✅ Docker build (development and/or production if chosen)"
|
echo " ✅ Docker build (development and/or production if chosen)"
|
||||||
fi
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "🎯 When ready for production:"
|
echo "🎯 When ready for production:"
|
||||||
echo " Push to main branch to trigger full CI/CD pipeline"
|
echo " Push to main branch to trigger full CI/CD pipeline"
|
||||||
echo " Docker image will be built and pushed to Gitea Container Registry"
|
echo " Docker image will be built and pushed to Gitea Container Registry"
|
||||||
echo ""
|
echo ""
|
||||||
echo "💡 Local testing complete! Your changes are ready for CI/CD."
|
echo "💡 Local testing complete! Your changes are ready for CI/CD."
|
||||||
|
echo "💡 This script now matches the Gitea workflow structure and behavior."
|
||||||
# ⚠️ IMPORTANT: Local Dockerfile.prod uses 'latest' tag for testing only
|
# ⚠️ IMPORTANT: Local Dockerfile.prod uses 'latest' tag for testing only
|
||||||
# ✅ CI/CD workflow generates correct Dockerfile.prod with dependency hash
|
# ✅ CI/CD workflow generates correct Dockerfile.prod with dependency hash
|
||||||
Reference in New Issue
Block a user