CI/CD Setup #15
Workflow file for this run
This file contains 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
name: Python CI All | |
on: | |
pull_request: | |
branches: | |
- main | |
- dev | |
# paths: | |
# - 'sweepai/**' | |
# - 'tests/**' | |
push: | |
branches: | |
- main | |
- dev | |
paths: | |
- 'sweepai/**' | |
- 'tests/**' | |
jobs: | |
setup-and-dependencies: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.10"] | |
# python-version: ["3.10", "3.11"] | |
os: [ubuntu-latest] | |
outputs: | |
cache-key: ${{ steps.cache-dependencies.outputs.cache-key }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: 1.67.0 | |
override: true | |
- uses: Swatinem/rust-cache@v1 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Restore dependencies | |
id: restore-dependencies | |
uses: actions/cache/restore@v4 | |
with: | |
path: ~/.cache/uv | |
key: ${{ runner.os }}-python-${{ matrix.python-version }}-${{ hashFiles('**/requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-python-${{ matrix.python-version }}- | |
${{ runner.os }}-python- | |
- run: echo "VIRTUAL_ENV=${Python_ROOT_DIR}" >> $GITHUB_ENV | |
if: steps.restore-dependencies.outputs.cache-hit != 'true' | |
- run: pip install uv | |
if: steps.restore-dependencies.outputs.cache-hit != 'true' | |
- run: uv pip install -r requirements.txt | |
if: steps.restore-dependencies.outputs.cache-hit != 'true' | |
- name: Cache dependencies | |
id: cache-dependencies | |
uses: actions/cache/save@v4 | |
with: | |
path: ~/.cache/uv | |
key: ${{ runner.os }}-python-${{ matrix.python-version }}-${{ hashFiles('**/requirements.txt') }} | |
code-quality: | |
needs: setup-and-dependencies | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.10"] | |
# python-version: ["3.10", "3.11"] | |
os: [ubuntu-latest] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Use Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.10 | |
- uses: actions/cache@v4 | |
name: Fetch dependencies | |
id: fetch-dependencies | |
with: | |
path: ~/.cache/uv | |
key: ${{ runner.os }}-python-${{ matrix.python-version }}-${{ hashFiles('**/requirements.txt') }} | |
- run: echo "VIRTUAL_ENV=${Python_ROOT_DIR}" >> $GITHUB_ENV | |
- name: Lint with Ruff | |
run: ruff check sweepai | |
- name: Lint with Pylint | |
run: pylint sweepai --errors-only | |
unit-tests: | |
needs: setup-and-dependencies | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.10"] | |
# python-version: ["3.10", "3.11"] | |
os: [ubuntu-latest] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Use Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.10 # Choose based on your project's needs | |
- run: echo "VIRTUAL_ENV=${Python_ROOT_DIR}" >> $GITHUB_ENV | |
- uses: actions/cache@v4 | |
name: Fetch dependencies | |
id: fetch-dependencies | |
with: | |
path: ~/.cache/uv | |
key: ${{ runner.os }}-python-${{ matrix.python-version }}-${{ hashFiles('**/requirements.txt') }} | |
- name: Run Unit Tests | |
env: | |
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
run: python -m unittest sweepai/**/*_test.py | |
e2e-tests: | |
needs: unit-tests | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.10"] | |
# python-version: ["3.10", "3.11"] | |
os: [ubuntu-latest] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.10 # Choose based on your project's needs | |
- uses: actions/cache@v4 | |
name: Fetch dependencies | |
id: fetch-dependencies | |
with: | |
path: ~/.cache/uv | |
key: ${{ runner.os }}-python-${{ matrix.python-version }}-${{ hashFiles('**/requirements.txt') }} | |
- run: echo "VIRTUAL_ENV=${Python_ROOT_DIR}" >> $GITHUB_ENV | |
- name: Set up Redis (for e2e tests) | |
run: | | |
sudo apt-get update | |
sudo apt-get install redis-server | |
sudo lsof -i :6379 || true | |
- name: Run e2e Tests | |
env: | |
GITHUB_PAT: ${{ secrets.GH_PAT }} | |
GITHUB_APP_ID: ${{ secrets.GH_APP_ID }} | |
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
GITHUB_APP_PEM: ${{ secrets.GH_APP_PEM }} | |
OPENAI_API_TYPE: azure | |
OPENAI_API_BASE: ${{ secrets.GH_OPENAI_API_BASE }} | |
OPENAI_API_VERSION: 2024-02-15-preview | |
AZURE_API_KEY: ${{ secrets.GH_AZURE_API_KEY }} | |
AZURE_OPENAI_DEPLOYMENT: ${{ secrets.GH_AZURE_OPENAI_DEPLOYMENT }} | |
run: PYTHONPATH=. pytest -n 4 tests/e2e -s | |
timeout-minutes: 30 |