5
branches: [ master, development, ci-test* ]
7
- '.github/workflows/autogpt-ci.yml'
8
- 'autogpts/autogpt/**'
9
- '!autogpts/autogpt/tests/vcr_cassettes'
11
branches: [ master, development, release-* ]
13
- '.github/workflows/autogpt-ci.yml'
14
- 'autogpts/autogpt/**'
15
- '!autogpts/autogpt/tests/vcr_cassettes'
18
group: ${{ format('autogpt-ci-{0}', github.head_ref && format('{0}-{1}', github.event_name, github.event.pull_request.number) || github.sha) }}
19
cancel-in-progress: ${{ startsWith(github.event_name, 'pull_request') }}
24
working-directory: autogpts/autogpt
28
runs-on: ubuntu-latest
30
min-python-version: "3.10"
33
- name: Checkout repository
34
uses: actions/checkout@v4
38
- name: Set up Python ${{ env.min-python-version }}
39
uses: actions/setup-python@v5
41
python-version: ${{ env.min-python-version }}
45
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
47
- name: Set up Python dependency cache
48
uses: actions/cache@v4
50
path: ~/.cache/pypoetry
51
key: ${{ runner.os }}-poetry-${{ hashFiles('autogpts/autogpt/pyproject.toml') }}-${{ steps.get_date.outputs.date }}
53
- name: Install Python dependencies
55
curl -sSL https://install.python-poetry.org | python3 -
58
- name: Lint with flake8
59
run: poetry run flake8
61
- name: Check black formatting
62
run: poetry run black . --check
63
if: success() || failure()
65
- name: Check isort formatting
66
run: poetry run isort . --check
67
if: success() || failure()
69
# - name: Check mypy formatting
70
# run: poetry run mypy
71
# if: success() || failure()
73
# - name: Check for unused imports and pass statements
75
# cmd="autoflake --remove-all-unused-imports --recursive --ignore-init-module-imports --ignore-pass-after-docstring autogpt tests"
76
# poetry run $cmd --check || (echo "You have unused imports or pass statements, please run '${cmd} --in-place'" && exit 1)
85
python-version: ["3.10"]
86
platform-os: [ubuntu, macos, macos-arm64, windows]
87
runs-on: ${{ matrix.platform-os != 'macos-arm64' && format('{0}-latest', matrix.platform-os) || 'macos-14' }}
90
# Quite slow on macOS (2~4 minutes to set up Docker)
91
# - name: Set up Docker (macOS)
92
# if: runner.os == 'macOS'
93
# uses: crazy-max/ghaction-setup-docker@v3
95
- name: Start MinIO service (Linux)
96
if: runner.os == 'Linux'
97
working-directory: '.'
99
docker pull minio/minio:edge-cicd
100
docker run -d -p 9000:9000 minio/minio:edge-cicd
102
- name: Start MinIO service (macOS)
103
if: runner.os == 'macOS'
104
working-directory: ${{ runner.temp }}
106
brew install minio/stable/minio
108
minio server ./data &
110
# No MinIO on Windows:
111
# - Windows doesn't support running Linux Docker containers
112
# - It doesn't seem possible to start background processes on Windows. They are
113
# killed after the step returns.
114
# See: https://github.com/actions/runner/issues/598#issuecomment-2011890429
116
- name: Checkout repository
117
uses: actions/checkout@v4
122
- name: Configure git user Auto-GPT-Bot
124
git config --global user.name "Auto-GPT-Bot"
125
git config --global user.email "github-bot@agpt.co"
127
- name: Checkout cassettes
128
if: ${{ startsWith(github.event_name, 'pull_request') }}
130
PR_BASE: ${{ github.event.pull_request.base.ref }}
131
PR_BRANCH: ${{ github.event.pull_request.head.ref }}
132
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
134
cassette_branch="${PR_AUTHOR}-${PR_BRANCH}"
135
cassette_base_branch="${PR_BASE}"
136
cd tests/vcr_cassettes
138
if ! git ls-remote --exit-code --heads origin $cassette_base_branch ; then
139
cassette_base_branch="master"
142
if git ls-remote --exit-code --heads origin $cassette_branch ; then
143
git fetch origin $cassette_branch
144
git fetch origin $cassette_base_branch
146
git checkout $cassette_branch
148
# Pick non-conflicting cassette updates from the base branch
149
git merge --no-commit --strategy-option=ours origin/$cassette_base_branch
150
echo "Using cassettes from mirror branch '$cassette_branch'," \
151
"synced to upstream branch '$cassette_base_branch'."
153
git checkout -b $cassette_branch
154
echo "Branch '$cassette_branch' does not exist in cassette submodule." \
155
"Using cassettes from '$cassette_base_branch'."
158
- name: Set up Python ${{ matrix.python-version }}
159
uses: actions/setup-python@v5
161
python-version: ${{ matrix.python-version }}
165
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
167
- name: Set up Python dependency cache
168
# On Windows, unpacking cached dependencies takes longer than just installing them
169
if: runner.os != 'Windows'
170
uses: actions/cache@v4
172
path: ${{ runner.os == 'macOS' && '~/Library/Caches/pypoetry' || '~/.cache/pypoetry' }}
173
key: poetry-${{ runner.os }}-${{ hashFiles('autogpts/autogpt/poetry.lock') }}
175
- name: Install Poetry (Unix)
176
if: runner.os != 'Windows'
178
curl -sSL https://install.python-poetry.org | python3 -
180
if [ "${{ runner.os }}" = "macOS" ]; then
181
PATH="$HOME/.local/bin:$PATH"
182
echo "$HOME/.local/bin" >> $GITHUB_PATH
185
- name: Install Poetry (Windows)
186
if: runner.os == 'Windows'
189
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python -
191
$env:PATH += ";$env:APPDATA\Python\Scripts"
192
echo "$env:APPDATA\Python\Scripts" >> $env:GITHUB_PATH
194
- name: Install Python dependencies
197
- name: Run pytest with coverage
199
poetry run pytest -vv \
200
--cov=autogpt --cov-branch --cov-report term-missing --cov-report xml \
201
--numprocesses=logical --durations=10 \
202
tests/unit tests/integration
206
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
207
S3_ENDPOINT_URL: ${{ runner.os != 'Windows' && 'http://127.0.0.1:9000' || '' }}
208
AWS_ACCESS_KEY_ID: minioadmin
209
AWS_SECRET_ACCESS_KEY: minioadmin
211
- name: Upload coverage reports to Codecov
212
uses: codecov/codecov-action@v4
214
token: ${{ secrets.CODECOV_TOKEN }}
215
flags: autogpt-agent,${{ runner.os }}
218
name: Set up git token authentication
219
# Cassettes may be pushed even when tests fail
220
if: success() || failure()
222
config_key="http.${{ github.server_url }}/.extraheader"
223
if [ "${{ runner.os }}" = 'macOS' ]; then
224
base64_pat=$(echo -n "pat:${{ secrets.PAT_REVIEW }}" | base64)
226
base64_pat=$(echo -n "pat:${{ secrets.PAT_REVIEW }}" | base64 -w0)
229
git config "$config_key" \
230
"Authorization: Basic $base64_pat"
232
cd tests/vcr_cassettes
233
git config "$config_key" \
234
"Authorization: Basic $base64_pat"
236
echo "config_key=$config_key" >> $GITHUB_OUTPUT
239
name: Push updated cassettes
240
# For pull requests, push updated cassettes even when tests fail
241
if: github.event_name == 'push' || (! github.event.pull_request.head.repo.fork && (success() || failure()))
243
PR_BRANCH: ${{ github.event.pull_request.head.ref }}
244
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
246
if [ "${{ startsWith(github.event_name, 'pull_request') }}" = "true" ]; then
248
cassette_branch="${PR_AUTHOR}-${PR_BRANCH}"
250
cassette_branch="${{ github.ref_name }}"
253
cd tests/vcr_cassettes
254
# Commit & push changes to cassettes if any
255
if ! git diff --quiet; then
257
git commit -m "Auto-update cassettes"
258
git push origin HEAD:$cassette_branch
259
if [ ! $is_pull_request ]; then
261
git add tests/vcr_cassettes
262
git commit -m "Update cassette submodule"
263
git push origin HEAD:$cassette_branch
265
echo "updated=true" >> $GITHUB_OUTPUT
267
echo "updated=false" >> $GITHUB_OUTPUT
268
echo "No cassette changes to commit"
271
- name: Post Set up git token auth
272
if: steps.setup_git_auth.outcome == 'success'
274
git config --unset-all '${{ steps.setup_git_auth.outputs.config_key }}'
275
git submodule foreach git config --unset-all '${{ steps.setup_git_auth.outputs.config_key }}'
277
- name: Apply "behaviour change" label and comment on PR
278
if: ${{ startsWith(github.event_name, 'pull_request') }}
280
PR_NUMBER="${{ github.event.pull_request.number }}"
281
TOKEN="${{ secrets.PAT_REVIEW }}"
282
REPO="${{ github.repository }}"
284
if [[ "${{ steps.push_cassettes.outputs.updated }}" == "true" ]]; then
285
echo "Adding label and comment..."
286
echo $TOKEN | gh auth login --with-token
287
gh issue edit $PR_NUMBER --add-label "behaviour change"
288
gh issue comment $PR_NUMBER --body "You changed AutoGPT's behaviour on ${{ runner.os }}. The cassettes have been updated and will be merged to the submodule when this Pull Request gets merged."
291
- name: Upload logs to artifact
293
uses: actions/upload-artifact@v4
296
path: autogpts/autogpt/logs/