Merge pull request #218 from TechNickAI/dependabot/github_actions/act… #814
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| # ===================================================================== | |
| # 🤖 AICodeBot CI/CD Pipeline 🤖 | |
| # ===================================================================== | |
| # | |
| # This workflow handles the continuous integration and deployment of | |
| # AICodeBot, the AI-powered coding assistant. | |
| # | |
| # 📊 Flow Structure: | |
| # ----------------- | |
| # 1. lint-code: Quick static code analysis with ruff | |
| # 2. test-python: Python backend tests | |
| # 3. build-package: Build Python package for distribution | |
| # 4. publish-package: Publish to PyPI (only on tags) | |
| # | |
| # 🔄 Job Dependencies: | |
| # ------------------ | |
| # The publish-package job only runs when all other jobs complete successfully | |
| # and only on version tags (v*). | |
| # | |
| # 🎯 Skip Deploy Feature: | |
| # --------------------- | |
| # Add [skip-deploy] anywhere in your commit message to skip PyPI publishing. | |
| # This is useful for documentation updates, test changes, or other non-production changes. | |
| # Example: "📝 Update README with examples [skip-deploy]" | |
| # | |
| # 💫 Caching Strategy: | |
| # ------------------ | |
| # - GitHub Actions cache for pip/uv dependencies | |
| # - Pytest cache for faster test runs | |
| # | |
| # Remember: Helping developers code better, one commit at a time! 🚀 | |
| # ===================================================================== | |
| name: Build AICodeBot 🤖 | |
| on: | |
| # Run on PRs | |
| pull_request: | |
| branches: [main] | |
| # Run on pushes to main | |
| push: | |
| branches: [main] | |
| tags: ['v*'] | |
| # Allow manual triggers | |
| workflow_dispatch: | |
| permissions: read-all | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| lint-code: | |
| name: 🧹 Lint code | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v5 | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.13" | |
| - name: Install uv (Rust-powered Python package manager) | |
| run: | | |
| curl -LsSf https://astral.sh/uv/install.sh | sh | |
| echo "PATH=$HOME/.local/bin:$PATH" >> $GITHUB_ENV | |
| - name: Install ruff | |
| run: uv pip install --system ruff | |
| - name: Run ruff linter | |
| run: ruff check . | |
| - name: Run ruff formatter | |
| run: ruff format --check . | |
| test-python: | |
| name: 🐍 Test Python code | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| strategy: | |
| matrix: | |
| python-version: ["3.12", "3.13"] | |
| env: | |
| # Skip live tests that require API keys in CI | |
| SKIP_LIVE_TESTS: 1 | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v5 | |
| - name: Setup Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Cache uv dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/uv | |
| key: ${{ runner.os }}-uv-py${{ matrix.python-version }}-${{ hashFiles('requirements/requirements-test.txt') }} | |
| restore-keys: | | |
| ${{ runner.os }}-uv-py${{ matrix.python-version }}- | |
| - name: Install uv (Rust-powered Python package manager) | |
| run: | | |
| curl -LsSf https://astral.sh/uv/install.sh | sh | |
| echo "PATH=$HOME/.local/bin:$PATH" >> $GITHUB_ENV | |
| - name: Install dependencies with uv | |
| run: | | |
| uv pip install --system -r requirements/requirements-test.txt | |
| uv pip install --system -e . | |
| - name: Run the tests with coverage | |
| run: pytest -n auto --cov=aicodebot --cov-report=xml --cov-report=term-missing | |
| - name: Upload coverage to Codecov | |
| if: matrix.python-version == '3.13' | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| files: ./coverage.xml | |
| fail_ci_if_error: false | |
| build-package: | |
| name: 🏗️ Build Python package | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| needs: [lint-code, test-python] | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v5 | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.13" | |
| - name: Install build dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install build twine | |
| - name: Build package | |
| run: python -m build | |
| - name: Check package | |
| run: twine check dist/* | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/ | |
| publish-package: | |
| name: 🚀 Publish to PyPI | |
| if: | | |
| github.event_name == 'push' && | |
| startsWith(github.ref, 'refs/tags/v') && | |
| !contains(github.event.head_commit.message, '[skip-deploy]') | |
| needs: [lint-code, test-python, build-package] | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| permissions: | |
| id-token: write # For trusted publishing to PyPI | |
| steps: | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: dist | |
| path: dist/ | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| print-hash: true |