diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3300655..a4df247 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,80 +1,108 @@ + name: CI/CD Pipeline on: push: - branches: [ main, develop ] + branches: [main, develop] pull_request: - branches: [ main, develop ] + branches: [main, develop] + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: ci-cd-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: test: + name: Python Tests (${{ matrix.python-version }}) runs-on: ubuntu-latest + timeout-minutes: 15 + strategy: + fail-fast: false matrix: python-version: ['3.11', '3.12'] steps: - - uses: actions/checkout@v3 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - - - name: Lint with flake8 - continue-on-error: true - run: | - pip install flake8 - # Stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # Exit-code is 0 even if there are warnings, for CI to pass - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - - name: Run tests with pytest - run: | - pip install pytest pytest-asyncio pytest-cov - pytest tests/ -v --cov=agents --cov=schemas --cov=utils --cov=providers --cov-report=xml - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3 - with: - file: ./coverage.xml - fail_ci_if_error: false + - name: Checkout repository + uses: actions/checkout@v6 + with: + persist-credentials: false + + - name: Set up Python + uses: actions/setup-python@v6 + with: + python-version: ${{ matrix.python-version }} + cache: pip + cache-dependency-path: requirements.txt + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install flake8 pytest pytest-asyncio pytest-cov + + - name: Lint with flake8 + continue-on-error: true + run: | + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + + - name: Run tests with pytest + run: | + pytest tests/ -v \ + --cov=agents \ + --cov=schemas \ + --cov=utils \ + --cov=providers \ + --cov-report=xml + + - name: Upload coverage to Codecov + if: always() + uses: codecov/codecov-action@v5 + with: + files: ./coverage.xml + fail_ci_if_error: false code-quality: + name: Code Quality Checks runs-on: ubuntu-latest - + timeout-minutes: 15 + steps: - - uses: actions/checkout@v3 - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.11' - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - pip install black isort pylint - - - name: Check code formatting with black - continue-on-error: true - run: | - black --check . || true - - - name: Check import ordering with isort - continue-on-error: true - run: | - isort --check-only . || true - - - name: Type checking with mypy - continue-on-error: true - run: | - pip install mypy - mypy agents providers schemas utils --ignore-missing-imports || true + - name: Checkout repository + uses: actions/checkout@v6 + with: + persist-credentials: false + + - name: Set up Python + uses: actions/setup-python@v6 + with: + python-version: '3.11' + cache: pip + cache-dependency-path: requirements.txt + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install black isort pylint mypy + + - name: Check code formatting with black + continue-on-error: true + run: black --check . + + - name: Check import ordering with isort + continue-on-error: true + run: isort --check-only . + + - name: Run pylint + continue-on-error: true + run: pylint agents providers schemas utils + + - name: Type checking with mypy + continue-on-error: true + run: mypy agents providers schemas utils --ignore-missing-imports