-
Notifications
You must be signed in to change notification settings - Fork 440
150 lines (134 loc) · 4.32 KB
/
python.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
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", "3.11"]
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-
- name: Install Python dependencies
if: steps.restore-dependencies.outputs.cache-hit != 'true'
run: |
pip install uv
echo "VIRTUAL_ENV=${Python_ROOT_DIR}" >> $GITHUB_ENV
uv pip install -r requirements.txt
uv pip install black ruff pylint uvicorn pytest
- 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
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Use Python
uses: actions/setup-python@v4
with:
python-version: 3.11
- 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
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Use Python
uses: actions/setup-python@v4
with:
python-version: 3.11 # 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
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11 # 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