From 0fa06fcffd83b3fa61df43ee0701b77c51f5484b Mon Sep 17 00:00:00 2001 From: Jenifer Date: Fri, 13 Nov 2026 18:04:24 +0530 Subject: [PATCH] Upgrade CI/CD workflow to use latest actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **CI/CD Pipeline – Automated Testing and Code Quality** This GitHub Actions workflow automates testing and code quality checks for the Python project whenever changes are pushed or pull requests are created against the `main` or `develop` branches. **Key Features:** - **Multi-Version Testing:** Runs tests using Python 3.11 and 3.12. - **Dependency Installation:** Automatically installs project dependencies from `requirements.txt`. - **Code Linting:** Uses Flake8 to identify syntax errors, undefined names, and code-quality issues. - **Automated Testing:** Executes the test suite using Pytest, including asynchronous tests and code coverage measurement. - **Coverage Reporting:** Uploads test coverage reports to Codecov. - **Code Formatting:** Uses Black to check Python code formatting. - **Import Validation:** Uses isort to verify import ordering. - **Code Analysis:** Uses Pylint and MyPy for code-quality and type-checking analysis. - **Workflow Optimization:** Includes dependency caching, execution timeouts, restricted permissions, and cancellation of outdated workflow runs. This workflow helps maintain code reliability, consistency, and quality through automated testing and continuous integration. --- .github/workflows/ci.yml | 152 +++++++++++++++++++++++---------------- 1 file changed, 90 insertions(+), 62 deletions(-) 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