|
| 1 | +name: CI/CD Pipeline |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main, develop ] |
| 6 | + pull_request: |
| 7 | + branches: [ main, develop ] |
| 8 | + release: |
| 9 | + types: [published] |
| 10 | + |
| 11 | +jobs: |
| 12 | + test: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + strategy: |
| 15 | + matrix: |
| 16 | + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] |
| 17 | + |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v4 |
| 20 | + |
| 21 | + - name: Set up Python ${{ matrix.python-version }} |
| 22 | + uses: actions/setup-python@v4 |
| 23 | + with: |
| 24 | + python-version: ${{ matrix.python-version }} |
| 25 | + |
| 26 | + - name: Cache pip dependencies |
| 27 | + uses: actions/cache@v3 |
| 28 | + with: |
| 29 | + path: ~/.cache/pip |
| 30 | + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }} |
| 31 | + restore-keys: | |
| 32 | + ${{ runner.os }}-pip- |
| 33 | +
|
| 34 | + - name: Install dependencies |
| 35 | + run: | |
| 36 | + python -m pip install --upgrade pip |
| 37 | + pip install -e ".[test]" |
| 38 | +
|
| 39 | + - name: Lint with flake8 |
| 40 | + run: | |
| 41 | + pip install flake8 |
| 42 | + # Stop the build if there are Python syntax errors or undefined names |
| 43 | + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics |
| 44 | + # Exit-zero treats all errors as warnings. GitHub editor is 127 chars wide |
| 45 | + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics |
| 46 | +
|
| 47 | + - name: Type check with mypy |
| 48 | + run: | |
| 49 | + pip install mypy types-requests |
| 50 | + mypy voltagent --ignore-missing-imports || true |
| 51 | +
|
| 52 | + - name: Run tests with pytest |
| 53 | + env: |
| 54 | + VOLTAGENT_BASE_URL: https://api.test.voltagent.dev |
| 55 | + VOLTAGENT_PUBLIC_KEY: test-public-key |
| 56 | + VOLTAGENT_SECRET_KEY: test-secret-key |
| 57 | + run: | |
| 58 | + pytest tests/ -v --tb=short --cov=voltagent --cov-report=xml --cov-report=term-missing |
| 59 | +
|
| 60 | + - name: Upload coverage reports to Codecov |
| 61 | + uses: codecov/codecov-action@v3 |
| 62 | + with: |
| 63 | + file: ./coverage.xml |
| 64 | + flags: unittests |
| 65 | + name: codecov-umbrella |
| 66 | + fail_ci_if_error: false |
| 67 | + |
| 68 | + build: |
| 69 | + runs-on: ubuntu-latest |
| 70 | + needs: test |
| 71 | + |
| 72 | + steps: |
| 73 | + - uses: actions/checkout@v4 |
| 74 | + |
| 75 | + - name: Set up Python |
| 76 | + uses: actions/setup-python@v4 |
| 77 | + with: |
| 78 | + python-version: "3.11" |
| 79 | + |
| 80 | + - name: Install build dependencies |
| 81 | + run: | |
| 82 | + python -m pip install --upgrade pip |
| 83 | + pip install build twine |
| 84 | +
|
| 85 | + - name: Build package |
| 86 | + run: python -m build |
| 87 | + |
| 88 | + - name: Check distribution |
| 89 | + run: twine check dist/* |
| 90 | + |
| 91 | + - name: Upload build artifacts |
| 92 | + uses: actions/upload-artifact@v3 |
| 93 | + with: |
| 94 | + name: python-package-distributions |
| 95 | + path: dist/ |
| 96 | + |
| 97 | + security: |
| 98 | + runs-on: ubuntu-latest |
| 99 | + |
| 100 | + steps: |
| 101 | + - uses: actions/checkout@v4 |
| 102 | + |
| 103 | + - name: Set up Python |
| 104 | + uses: actions/setup-python@v4 |
| 105 | + with: |
| 106 | + python-version: "3.11" |
| 107 | + |
| 108 | + - name: Install security tools |
| 109 | + run: | |
| 110 | + python -m pip install --upgrade pip |
| 111 | + pip install safety bandit |
| 112 | +
|
| 113 | + - name: Run safety check |
| 114 | + run: | |
| 115 | + pip install -e . |
| 116 | + safety check || true |
| 117 | +
|
| 118 | + - name: Run bandit security scan |
| 119 | + run: | |
| 120 | + bandit -r voltagent/ -f json -o bandit-report.json || true |
| 121 | + bandit -r voltagent/ || true |
| 122 | +
|
| 123 | + - name: Upload security reports |
| 124 | + uses: actions/upload-artifact@v3 |
| 125 | + if: always() |
| 126 | + with: |
| 127 | + name: security-reports |
| 128 | + path: | |
| 129 | + bandit-report.json |
| 130 | +
|
| 131 | + publish: |
| 132 | + runs-on: ubuntu-latest |
| 133 | + needs: [test, build, security] |
| 134 | + if: github.event_name == 'release' && github.event.action == 'published' |
| 135 | + |
| 136 | + steps: |
| 137 | + - uses: actions/checkout@v4 |
| 138 | + |
| 139 | + - name: Set up Python |
| 140 | + uses: actions/setup-python@v4 |
| 141 | + with: |
| 142 | + python-version: "3.11" |
| 143 | + |
| 144 | + - name: Install build dependencies |
| 145 | + run: | |
| 146 | + python -m pip install --upgrade pip |
| 147 | + pip install build twine |
| 148 | +
|
| 149 | + - name: Build package |
| 150 | + run: python -m build |
| 151 | + |
| 152 | + - name: Publish to PyPI |
| 153 | + env: |
| 154 | + TWINE_USERNAME: __token__ |
| 155 | + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} |
| 156 | + run: | |
| 157 | + twine upload dist/* |
0 commit comments