--- # Local CI/CD Testing Workflow # Simulates the CI/CD pipeline but builds Docker image locally # Use this for local development and testing name: Local CI/CD Test on: workflow_dispatch: {} push: branches: - 'test/**' - 'feature/**' paths-ignore: - 'README.md' - 'doc/**' - 'adr/**' - '.gitea/**' # Arcodange-specific environment variables env: GITEA_INTERNAL: "https://gitea.arcodange.lab/" GITEA_EXTERNAL: "https://gitea.arcodange.fr/" GITEA_ORG: "arcodange" GITEA_REPO: "DanceLessonsCoach" CI_REGISTRY: "gitea.arcodange.lab" jobs: local-test: name: Local CI/CD Test runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - name: Set up Go uses: actions/setup-go@v4 with: go-version: '1.26.1' cache: true - name: Install dependencies run: go mod tidy - name: Install swag run: go install github.com/swaggo/swag/cmd/swag@latest - name: Generate Swagger Docs run: cd pkg/server && go generate - name: Build all packages run: go build ./... - name: Run tests with coverage run: go test ./... -cover -v - name: Build binaries run: ./scripts/build.sh - name: List artifacts run: ls -la bin/ - name: Version Bump Simulation run: | echo "📋 Simulating version bump based on commit type..." LAST_COMMIT=$(git log -1 --pretty=%B | head -1) echo "Last commit: $LAST_COMMIT" if echo "$LAST_COMMIT" | grep -q "^feat:"; then echo "🎯 Feature commit detected - would bump MINOR version" echo "Run: ./scripts/version-bump.sh minor" elif echo "$LAST_COMMIT" | grep -q "^fix:"; then echo "🐛 Fix commit detected - would bump PATCH version" echo "Run: ./scripts/version-bump.sh patch" elif echo "$LAST_COMMIT" | grep -q "BREAKING CHANGE"; then echo "💥 Breaking change detected - would bump MAJOR version" echo "Run: ./scripts/version-bump.sh major" else echo "⏭️ No automatic version bump needed" fi # Show current version source VERSION echo "📊 Current version: $MAJOR.$MINOR.$PATCH${PRERELEASE:+-$PRERELEASE}" - name: Local Docker Build Instructions run: | echo "🐳 LOCAL DOCKER BUILD INSTRUCTIONS" echo "================================" echo "" # Get current version source VERSION CURRENT_VERSION="$MAJOR.$MINOR.$PATCH${PRERELEASE:+-$PRERELEASE}" echo "1. Build Docker image locally:" echo " docker build -t dance-lessons-coach:$CURRENT_VERSION ." echo "" echo "2. Tag the image:" echo " docker tag dance-lessons-coach:$CURRENT_VERSION dance-lessons-coach:latest" echo "" echo "3. Test the local image:" echo " docker run -p 8080:8080 dance-lessons-coach:$CURRENT_VERSION" echo "" echo "4. Test API endpoints:" echo " curl http://localhost:8080/api/health" echo " curl http://localhost:8080/api/v1/greet/YourName" echo "" echo "5. Clean up:" echo " docker stop && docker rm " echo "" echo "💡 Tip: Use 'docker images' to see your built images" echo "💡 Use 'docker ps' to see running containers" - name: Show Swagger UI Access run: | echo "📖 SWAGGER UI ACCESS" echo "====================" echo "" echo "After starting the container, access Swagger UI at:" echo " http://localhost:8080/swagger/" echo "" echo "Swagger JSON spec available at:" echo " http://localhost:8080/swagger/doc.json" echo "" echo "Generated Swagger files:" ls -la pkg/server/docs/ 2>/dev/null || echo " (Swagger docs will be generated during Docker build)" - name: Test Summary run: | echo "✅ LOCAL CI/CD TEST COMPLETE" echo "============================" echo "" echo "📋 What was tested:" echo " ✅ Go dependencies installation" echo " ✅ Swagger documentation generation" echo " ✅ Code compilation" echo " ✅ Unit tests with coverage" echo " ✅ Binary build" echo " ✅ Version bump simulation" echo "" echo "🐳 Next steps:" echo " 1. Build Docker image locally (see instructions above)" echo " 2. Test the container" echo " 3. Verify API endpoints" echo " 4. Test Swagger UI" echo "" echo "🎯 When ready for production:" echo " Push to main branch to trigger full CI/CD pipeline" echo " Docker image will be built and pushed to Gitea Container Registry"