feat: integrate swag fmt and improve CI/CD workflows
Some checks failed
Go CI/CD Pipeline / Lint and Format (push) Successful in 4m51s
Docker Build and Publish / Version Bump (push) Successful in 4m54s
Docker Build and Publish / Build and Push Docker Image (push) Failing after 2m51s
Go CI/CD Pipeline / Build and Test (push) Successful in 9m47s
Go CI/CD Pipeline / Version Management (push) Successful in 12s

- Add swag fmt to git pre-commit hook and CI/CD pipeline
- Create comprehensive CONTRIBUTING.md guide with AI section
- Update ADR-0013 with swag fmt documentation
- Fix swagger generation to include all endpoints
- Improve local testing scripts and workflows
- Update Dockerfile for better swagger handling
- Fix CI/CD workflow file references
This commit is contained in:
2026-04-06 15:36:55 +02:00
parent 48b7051a33
commit 183933b43e
21 changed files with 1500 additions and 78 deletions

View File

@@ -1,4 +1,4 @@
---
---
# DanceLessonsCoach Docker Image Build Workflow
# Based on Arcodange webapp conventions
# Builds and publishes Docker images to Gitea Container Registry
@@ -32,9 +32,66 @@ env:
CI_REGISTRY: "gitea.arcodange.lab"
jobs:
version-bump:
name: Version Bump
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.26.1'
- name: Install swag and generate Swagger Docs
run: |
if [ ! -f pkg/server/docs/swagger.json ]; then
echo "📝 Generating Swagger documentation..."
go install github.com/swaggo/swag/cmd/swag@latest
cd pkg/server && go generate
echo "✅ Swagger documentation generated"
else
echo "✅ Swagger documentation already exists, skipping generation"
fi
- name: Bump version based on commit type
run: |
# Analyze last commit message
LAST_COMMIT=$(git log -1 --pretty=%B | head -1)
if echo "$LAST_COMMIT" | grep -q "^feat:"; then
echo "🎯 Feature commit detected - bumping MINOR version"
./scripts/version-bump.sh minor
elif echo "$LAST_COMMIT" | grep -q "^fix:"; then
echo "🐛 Fix commit detected - bumping PATCH version"
./scripts/version-bump.sh patch
elif echo "$LAST_COMMIT" | grep -q "BREAKING CHANGE"; then
echo "💥 Breaking change detected - bumping MAJOR version"
./scripts/version-bump.sh major
else
echo "⏭️ No automatic version bump needed"
# Still ensure swagger version is updated
source VERSION
NEW_VERSION="$MAJOR.$MINOR.$PATCH${PRERELEASE:+-$PRERELEASE}"
sed -i "s|// @version [0-9.]*|// @version $NEW_VERSION|" cmd/server/main.go
fi
- name: Commit version changes
run: |
git config --global user.name "CI Bot"
git config --global user.email "ci@arcodange.fr"
git add VERSION cmd/server/main.go
git commit -m "chore: auto version bump [skip ci]" || echo "No changes to commit"
git push
build-and-push-image:
name: Build and Push Docker Image
runs-on: ubuntu-latest
needs: version-bump
if: always() && (needs.version-bump.result == 'success' || needs.version-bump.result == 'skipped')
steps:
- name: Login to Gitea Container Registry
@@ -80,4 +137,4 @@ jobs:
else
echo " - ${{ env.CI_REGISTRY }}/${{ env.GITEA_ORG }}/${{ env.GITEA_REPO }}:latest"
echo " - ${{ env.CI_REGISTRY }}/${{ env.GITEA_ORG }}/${{ env.GITEA_REPO }}:${{ github.sha }}"
fi
fi