forked from patched-codes/patchwork
-
Notifications
You must be signed in to change notification settings - Fork 0
227 lines (192 loc) · 7.09 KB
/
test.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
name: Tests
on:
push:
branches-ignore:
- main
- autofix-*
- dependencyupgrade-*
- generatereadme-*
- generatedocstring-*
jobs:
all-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
- uses: jwalton/gh-find-current-pr@master
id: findPr
- name: Set up node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Set up python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: '3.8'
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: ./.venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('./poetry.lock') }}-${{ github.job }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --all-extras
- name: Run tests
run: poetry run pytest
security-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
- uses: jwalton/gh-find-current-pr@master
id: findPr
- name: Set up python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: '3.8'
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: ./.venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('./poetry.lock') }}-${{ github.job }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --only main --extras security
- name: AutoFix Patchwork
run: |
poetry run patchwork AutoFix --log debug \
--openai_api_key=${{ secrets.OPENAI_KEY }} \
--github_api_key=${{ secrets.SCM_GITHUB_KEY }} \
--force_pr_creation \
--disable_telemetry
- name: Dependency Upgrade
run: |
poetry run patchwork DependencyUpgrade --log debug \
--libraries_api_key=${{ secrets.LIBRARIES_KEY }} \
--openai_api_key=${{ secrets.OPENAI_KEY }} \
--github_api_key=${{ secrets.SCM_GITHUB_KEY }} \
--language=python \
--force_pr_creation \
--disable_telemetry
rag-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
- uses: jwalton/gh-find-current-pr@master
id: findPr
- name: Set up python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: '3.8'
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: ./.venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('./poetry.lock') }}-${{ github.job }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --only main --extras rag
- name: Propose relevant file to issues
run: |
poetry run patchwork ResolveIssue --log debug \
--openai_api_key=${{ secrets.OPENAI_KEY }} \
--github_api_key=${{ secrets.SCM_GITHUB_KEY }} \
--issue_url=https://github.com/patched-codes/patchwork/issues/20 \
--disable_telemetry
main-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
- uses: jwalton/gh-find-current-pr@master
id: findPr
- name: Set up python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: '3.8'
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: ./.venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('./poetry.lock') }}-${{ github.job }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --only main
- name: PR Review
run: |
poetry run patchwork PRReview --log debug \
--openai_api_key=${{ secrets.OPENAI_KEY }} \
--github_api_key=${{ secrets.SCM_GITHUB_KEY }} \
--pr_url=https://github.com/patched-codes/patchwork/pull/${{ steps.findPr.outputs.number }} \
--disable_telemetry
- name: Generate Docstring
run: |
poetry run patchwork GenerateDocstring --log debug \
--openai_api_key=${{ secrets.OPENAI_KEY }} \
--github_api_key=${{ secrets.SCM_GITHUB_KEY }} \
--base_path=tests/cicd/generate_docstring \
--disable_telemetry
- name: Generate README
run: |
# Specify the parent folder you want to check
PARENT_FOLDER="./patchwork/steps"
# Command to run if README.md is not found
find "$PARENT_FOLDER" -mindepth 1 -maxdepth 1 -type d | grep -vE '/\.\.?/' | grep -vE '/__' | while read -r dir; do
if [[ ! -f "$dir/README.md" ]]; then
echo "No README.md in $dir"
# Extract the last part of the path to use as a base for the branch name
base_name=$(basename "$dir")
# Convert to a Git-friendly branch name: replace spaces with underscores, remove slashes, etc.
branch_name=$(echo "$base_name" | sed -e 's/[^a-zA-Z0-9]/_/g' -e 's/__*/_/g' -e 's/^_//g' -e 's/_$//g')
poetry run patchwork GenerateREADME --log debug \
--openai_api_key=${{ secrets.OPENAI_KEY }} \
--github_api_key=${{ secrets.SCM_GITHUB_KEY }} \
--filter=*.py \
--folder_path=$dir \
--branch_prefix=generatereadme-$branch_name \
--disable_telemetry
else
echo "Found README.md in $dir"
fi
done