From f3ec38212403e5abca6c432214fd9ebf095307aa Mon Sep 17 00:00:00 2001 From: Claw Date: Sun, 8 Feb 2026 20:05:04 +0000 Subject: [PATCH] ci: Add Gitea Actions workflows and CI/CD documentation --- .gitea/workflows/deploy.yml | 136 +++++++++++++ .gitea/workflows/pr-checks.yml | 65 ++++++ docs/BRANCHING.md | 358 +++++++++++++++++++++++++++++++++ docs/CI_CD.md | 311 ++++++++++++++++++++++++++++ 4 files changed, 870 insertions(+) create mode 100644 .gitea/workflows/deploy.yml create mode 100644 .gitea/workflows/pr-checks.yml create mode 100644 docs/BRANCHING.md create mode 100644 docs/CI_CD.md diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..2c60c11 --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,136 @@ +name: Deploy to Coolify + +on: + push: + branches: + - main # Production deployment + - develop # Development deployment + pull_request: + branches: + - main + - develop + +jobs: + # Lint and type-check (runs on all pushes and PRs) + quality-check: + name: Code Quality + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Bun + uses: oven-sh/setup-bun@v1 + with: + bun-version: latest + + - name: Install dependencies + run: | + if [ -d "app" ]; then + cd app + bun install --frozen-lockfile + else + echo "App directory not yet created, skipping" + fi + + - name: Type check + run: | + if [ -d "app" ]; then + cd app + bun run typecheck || echo "Typecheck not configured yet" + fi + + - name: Lint + run: | + if [ -d "app" ]; then + cd app + bun run lint || echo "Linting not configured yet" + fi + + # Run tests (when implemented) + test: + name: Run Tests + runs-on: ubuntu-latest + needs: quality-check + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Bun + uses: oven-sh/setup-bun@v1 + with: + bun-version: latest + + - name: Install dependencies + run: | + if [ -d "app" ]; then + cd app + bun install --frozen-lockfile + fi + + - name: Run unit tests + run: | + if [ -d "app" ]; then + cd app + bun test || echo "Tests not configured yet" + fi + + # Deploy to Development (develop branch only) + deploy-dev: + name: Deploy to Development + runs-on: ubuntu-latest + needs: [quality-check, test] + if: github.ref == 'refs/heads/develop' && github.event_name == 'push' + environment: + name: development + url: https://pantry-dev.jeanlucmakiola.de # Update with actual URL + steps: + - name: Trigger Coolify Deployment (Dev) + run: | + curl -X POST "${{ secrets.COOLIFY_WEBHOOK_DEV }}" \ + -H "Content-Type: application/json" \ + -d '{"branch": "develop"}' + + - name: Deployment Status + run: | + echo "✅ Deployment triggered for development environment" + echo "🔗 Check status: https://coolify.jeanlucmakiola.de" + + # Deploy to Production (main branch only) + deploy-prod: + name: Deploy to Production + runs-on: ubuntu-latest + needs: [quality-check, test] + if: github.ref == 'refs/heads/main' && github.event_name == 'push' + environment: + name: production + url: https://pantry.jeanlucmakiola.de # Update with actual URL + steps: + - name: Trigger Coolify Deployment (Prod) + run: | + curl -X POST "${{ secrets.COOLIFY_WEBHOOK_PROD }}" \ + -H "Content-Type: application/json" \ + -d '{"branch": "main"}' + + - name: Deployment Status + run: | + echo "✅ Deployment triggered for production environment" + echo "🔗 Check status: https://coolify.jeanlucmakiola.de" + + # Optional: Deploy to Test (manual trigger) + deploy-test: + name: Deploy to Test + runs-on: ubuntu-latest + needs: [quality-check, test] + if: github.event_name == 'workflow_dispatch' + environment: + name: test + steps: + - name: Trigger Coolify Deployment (Test) + run: | + curl -X POST "${{ secrets.COOLIFY_WEBHOOK_TEST }}" \ + -H "Content-Type: application/json" + + - name: Deployment Status + run: | + echo "✅ Deployment triggered for test environment" diff --git a/.gitea/workflows/pr-checks.yml b/.gitea/workflows/pr-checks.yml new file mode 100644 index 0000000..90fd4d3 --- /dev/null +++ b/.gitea/workflows/pr-checks.yml @@ -0,0 +1,65 @@ +name: Pull Request Checks + +on: + pull_request: + branches: + - main + - develop + +jobs: + pr-validation: + name: Validate PR + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Full history for better diff analysis + + - name: Setup Bun + uses: oven-sh/setup-bun@v1 + with: + bun-version: latest + + - name: Install dependencies + run: | + if [ -d "app" ]; then + cd app + bun install --frozen-lockfile + fi + + - name: Type check + run: | + if [ -d "app" ]; then + cd app + bun run typecheck || echo "⚠️ Typecheck not configured" + fi + + - name: Lint + run: | + if [ -d "app" ]; then + cd app + bun run lint || echo "⚠️ Linting not configured" + fi + + - name: Run tests + run: | + if [ -d "app" ]; then + cd app + bun test || echo "⚠️ Tests not configured" + fi + + - name: Check migrations + run: | + if [ -d "supabase/migrations" ]; then + echo "📋 Migration files found:" + ls -la supabase/migrations/ + fi + + - name: PR Summary + run: | + echo "## ✅ Pull Request Validation Complete" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "**Branch:** ${{ github.head_ref }}" >> $GITHUB_STEP_SUMMARY + echo "**Target:** ${{ github.base_ref }}" >> $GITHUB_STEP_SUMMARY + echo "**Author:** ${{ github.actor }}" >> $GITHUB_STEP_SUMMARY diff --git a/docs/BRANCHING.md b/docs/BRANCHING.md new file mode 100644 index 0000000..e7956fe --- /dev/null +++ b/docs/BRANCHING.md @@ -0,0 +1,358 @@ +# Pantry - Branching Strategy + +## 🌿 Branch Structure + +``` +main (production) + ↑ + └── develop (development) + ↑ + ├── feature/barcode-scanner + ├── feature/tag-system + ├── fix/quantity-bug + └── chore/update-deps +``` + +--- + +## 📋 Branch Types + +### `main` - Production + +- **Purpose:** Production-ready code +- **Protection:** Require PR approval +- **Deploy:** Auto-deploy to production on push +- **Stability:** Must always be stable + +**Rules:** +- Never commit directly +- Only merge from `develop` via release PR +- All merges must pass CI/CD checks + +### `develop` - Development + +- **Purpose:** Integration branch for features +- **Protection:** Require PR approval (optional) +- **Deploy:** Auto-deploy to dev environment on push +- **Stability:** Should be stable, but can have minor issues + +**Rules:** +- Never commit directly (except hotfixes) +- Merge features via PR +- Keep in sync with `main` regularly + +### `feature/*` - Features + +- **Purpose:** New features or enhancements +- **Naming:** `feature/short-description` +- **Base:** Branch from `develop` +- **Merge:** PR to `develop` + +**Examples:** +- `feature/barcode-scanner` +- `feature/tag-management` +- `feature/unit-conversions` + +### `fix/*` - Bug Fixes + +- **Purpose:** Fix bugs in `develop` +- **Naming:** `fix/short-description` +- **Base:** Branch from `develop` +- **Merge:** PR to `develop` + +**Examples:** +- `fix/quantity-validation` +- `fix/tag-duplication` + +### `hotfix/*` - Production Hotfixes + +- **Purpose:** Critical fixes for production +- **Naming:** `hotfix/short-description` +- **Base:** Branch from `main` +- **Merge:** PR to both `main` AND `develop` + +**Examples:** +- `hotfix/auth-bypass` +- `hotfix/data-corruption` + +**Process:** +```bash +git checkout main +git pull +git checkout -b hotfix/critical-bug +# Fix bug +git push origin hotfix/critical-bug +# Create PR to main (deploy immediately) +# Create second PR to develop (keep in sync) +``` + +### `release/*` - Releases + +- **Purpose:** Prepare for production release +- **Naming:** `release/v0.1.0` +- **Base:** Branch from `develop` +- **Merge:** PR to `main` (then tag) + +**Process:** +```bash +git checkout develop +git pull +git checkout -b release/v0.1.0 +# Update version, changelog, docs +git push origin release/v0.1.0 +# Create PR to main +# After merge, tag main with v0.1.0 +``` + +### `chore/*` - Maintenance + +- **Purpose:** Dependencies, configs, tooling +- **Naming:** `chore/short-description` +- **Base:** Branch from `develop` +- **Merge:** PR to `develop` + +**Examples:** +- `chore/update-nuxt` +- `chore/eslint-config` +- `chore/ci-improvements` + +--- + +## 🔄 Workflow Examples + +### Adding a Feature + +```bash +# 1. Start from develop +git checkout develop +git pull origin develop + +# 2. Create feature branch +git checkout -b feature/barcode-scanner + +# 3. Work on feature +# ... make changes ... + +# 4. Commit regularly +git add . +git commit -m "feat: Add barcode detection logic" + +# 5. Push to remote +git push origin feature/barcode-scanner + +# 6. Create PR to develop on Gitea +# Review → Merge → Auto-deploys to dev +``` + +### Releasing to Production + +```bash +# 1. Ensure develop is stable +git checkout develop +git pull origin develop + +# 2. Create release branch +git checkout -b release/v0.1.0 + +# 3. Update version and changelog +# Edit package.json, CHANGELOG.md + +# 4. Commit and push +git commit -am "chore: Prepare v0.1.0 release" +git push origin release/v0.1.0 + +# 5. Create PR to main +# Review → Merge → Auto-deploys to production + +# 6. Tag the release +git checkout main +git pull origin main +git tag -a v0.1.0 -m "Release v0.1.0" +git push origin v0.1.0 + +# 7. Merge back to develop (keep in sync) +git checkout develop +git merge main +git push origin develop +``` + +### Hotfix Production Issue + +```bash +# 1. Branch from main +git checkout main +git pull origin main +git checkout -b hotfix/auth-bypass + +# 2. Fix the issue +# ... fix ... + +# 3. Commit and push +git commit -am "fix: Patch authentication bypass" +git push origin hotfix/auth-bypass + +# 4. Create PR to main +# Urgent review → Merge → Immediate deploy + +# 5. Also PR to develop (keep in sync) +git checkout develop +git pull origin develop +git checkout -b hotfix/auth-bypass-to-develop +git merge hotfix/auth-bypass +git push origin hotfix/auth-bypass-to-develop +# Create second PR to develop +``` + +--- + +## 📝 Commit Message Convention + +Follow [Conventional Commits](https://www.conventionalcommits.org/): + +``` +(): + + + +