|
| 1 | +name: AutoGPT Server CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [master, development, ci-test*] |
| 6 | + paths: |
| 7 | + - ".github/workflows/autogpt-server-ci.yml" |
| 8 | + - "rnd/autogpt_server/**" |
| 9 | + - "!autogpt/tests/vcr_cassettes" |
| 10 | + pull_request: |
| 11 | + branches: [master, development, release-*] |
| 12 | + paths: |
| 13 | + - ".github/workflows/autogpt-server-ci.yml" |
| 14 | + - "rnd/autogpt_server/**" |
| 15 | + - "!autogpt/tests/vcr_cassettes" |
| 16 | + |
| 17 | +concurrency: |
| 18 | + group: ${{ format('autogpt-server-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') }} |
| 20 | + |
| 21 | +defaults: |
| 22 | + run: |
| 23 | + shell: bash |
| 24 | + working-directory: rnd/autogpt_server |
| 25 | + |
| 26 | +jobs: |
| 27 | + test: |
| 28 | + permissions: |
| 29 | + contents: read |
| 30 | + timeout-minutes: 30 |
| 31 | + strategy: |
| 32 | + fail-fast: false |
| 33 | + matrix: |
| 34 | + python-version: ["3.10"] |
| 35 | + platform-os: [ubuntu, macos, macos-arm64, windows] |
| 36 | + runs-on: ${{ matrix.platform-os != 'macos-arm64' && format('{0}-latest', matrix.platform-os) || 'macos-14' }} |
| 37 | + |
| 38 | + steps: |
| 39 | + # Quite slow on macOS (2~4 minutes to set up Docker) |
| 40 | + # - name: Set up Docker (macOS) |
| 41 | + # if: runner.os == 'macOS' |
| 42 | + # uses: crazy-max/ghaction-setup-docker@v3 |
| 43 | + |
| 44 | + - name: Start MinIO service (Linux) |
| 45 | + if: runner.os == 'Linux' |
| 46 | + working-directory: "." |
| 47 | + run: | |
| 48 | + docker pull minio/minio:edge-cicd |
| 49 | + docker run -d -p 9000:9000 minio/minio:edge-cicd |
| 50 | +
|
| 51 | + - name: Start MinIO service (macOS) |
| 52 | + if: runner.os == 'macOS' |
| 53 | + working-directory: ${{ runner.temp }} |
| 54 | + run: | |
| 55 | + brew install minio/stable/minio |
| 56 | + mkdir data |
| 57 | + minio server ./data & |
| 58 | +
|
| 59 | + # No MinIO on Windows: |
| 60 | + # - Windows doesn't support running Linux Docker containers |
| 61 | + # - It doesn't seem possible to start background processes on Windows. They are |
| 62 | + # killed after the step returns. |
| 63 | + # See: https://github.com/actions/runner/issues/598#issuecomment-2011890429 |
| 64 | + |
| 65 | + - name: Checkout repository |
| 66 | + uses: actions/checkout@v4 |
| 67 | + with: |
| 68 | + fetch-depth: 0 |
| 69 | + submodules: true |
| 70 | + |
| 71 | + - name: Set up Python ${{ matrix.python-version }} |
| 72 | + uses: actions/setup-python@v5 |
| 73 | + with: |
| 74 | + python-version: ${{ matrix.python-version }} |
| 75 | + |
| 76 | + - id: get_date |
| 77 | + name: Get date |
| 78 | + run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT |
| 79 | + |
| 80 | + - name: Set up Python dependency cache |
| 81 | + # On Windows, unpacking cached dependencies takes longer than just installing them |
| 82 | + if: runner.os != 'Windows' |
| 83 | + uses: actions/cache@v4 |
| 84 | + with: |
| 85 | + path: ${{ runner.os == 'macOS' && '~/Library/Caches/pypoetry' || '~/.cache/pypoetry' }} |
| 86 | + key: poetry-${{ runner.os }}-${{ hashFiles('rnd/autogpt_server/poetry.lock') }} |
| 87 | + |
| 88 | + - name: Install Poetry (Unix) |
| 89 | + if: runner.os != 'Windows' |
| 90 | + run: | |
| 91 | + curl -sSL https://install.python-poetry.org | python3 - |
| 92 | +
|
| 93 | + if [ "${{ runner.os }}" = "macOS" ]; then |
| 94 | + PATH="$HOME/.local/bin:$PATH" |
| 95 | + echo "$HOME/.local/bin" >> $GITHUB_PATH |
| 96 | + fi |
| 97 | +
|
| 98 | + - name: Install Poetry (Windows) |
| 99 | + if: runner.os == 'Windows' |
| 100 | + shell: pwsh |
| 101 | + run: | |
| 102 | + (Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python - |
| 103 | +
|
| 104 | + $env:PATH += ";$env:APPDATA\Python\Scripts" |
| 105 | + echo "$env:APPDATA\Python\Scripts" >> $env:GITHUB_PATH |
| 106 | +
|
| 107 | + - name: Install Python dependencies |
| 108 | + run: poetry install |
| 109 | + |
| 110 | + - name: Generate Prisma Client |
| 111 | + run: poetry run prisma generate |
| 112 | + |
| 113 | + - name: Run Database Migrations |
| 114 | + run: poetry run prisma migrate dev --name updates |
| 115 | + |
| 116 | + - name: Run pytest with coverage |
| 117 | + run: | |
| 118 | + poetry run pytest -vv \ |
| 119 | + test |
| 120 | + env: |
| 121 | + CI: true |
| 122 | + PLAIN_OUTPUT: True |
| 123 | + |
| 124 | + # - name: Upload coverage reports to Codecov |
| 125 | + # uses: codecov/codecov-action@v4 |
| 126 | + # with: |
| 127 | + # token: ${{ secrets.CODECOV_TOKEN }} |
| 128 | + # flags: autogpt-server,${{ runner.os }} |
| 129 | + |
| 130 | + build: |
| 131 | + permissions: |
| 132 | + contents: read |
| 133 | + timeout-minutes: 30 |
| 134 | + strategy: |
| 135 | + fail-fast: false |
| 136 | + matrix: |
| 137 | + python-version: ["3.10"] |
| 138 | + platform-os: [ubuntu, macos, macos-arm64, windows] |
| 139 | + runs-on: ${{ matrix.platform-os != 'macos-arm64' && format('{0}-latest', matrix.platform-os) || 'macos-14' }} |
| 140 | + |
| 141 | + steps: |
| 142 | + - name: Checkout repository |
| 143 | + uses: actions/checkout@v4 |
| 144 | + with: |
| 145 | + fetch-depth: 0 |
| 146 | + submodules: true |
| 147 | + |
| 148 | + - name: Set up Python ${{ matrix.python-version }} |
| 149 | + uses: actions/setup-python@v5 |
| 150 | + with: |
| 151 | + python-version: ${{ matrix.python-version }} |
| 152 | + |
| 153 | + - id: get_date |
| 154 | + name: Get date |
| 155 | + run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT |
| 156 | + |
| 157 | + - name: Set up Python dependency cache |
| 158 | + # On Windows, unpacking cached dependencies takes longer than just installing them |
| 159 | + if: runner.os != 'Windows' |
| 160 | + uses: actions/cache@v4 |
| 161 | + with: |
| 162 | + path: ${{ runner.os == 'macOS' && '~/Library/Caches/pypoetry' || '~/.cache/pypoetry' }} |
| 163 | + key: poetry-${{ runner.os }}-${{ hashFiles('rnd/autogpt_server/poetry.lock') }} |
| 164 | + |
| 165 | + - name: Install Poetry (Unix) |
| 166 | + if: runner.os != 'Windows' |
| 167 | + run: | |
| 168 | + curl -sSL https://install.python-poetry.org | python3 - |
| 169 | +
|
| 170 | + if [ "${{ runner.os }}" = "macOS" ]; then |
| 171 | + PATH="$HOME/.local/bin:$PATH" |
| 172 | + echo "$HOME/.local/bin" >> $GITHUB_PATH |
| 173 | + fi |
| 174 | +
|
| 175 | + - name: Install Poetry (Windows) |
| 176 | + if: runner.os == 'Windows' |
| 177 | + shell: pwsh |
| 178 | + run: | |
| 179 | + (Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python - |
| 180 | +
|
| 181 | + $env:PATH += ";$env:APPDATA\Python\Scripts" |
| 182 | + echo "$env:APPDATA\Python\Scripts" >> $env:GITHUB_PATH |
| 183 | +
|
| 184 | + - name: Install Python dependencies |
| 185 | + run: poetry install |
| 186 | + |
| 187 | + - name: Generate Prisma Client |
| 188 | + run: poetry run prisma generate |
| 189 | + |
| 190 | + - name: Run Database Migrations |
| 191 | + run: poetry run prisma migrate dev --name updates |
| 192 | + |
| 193 | + - name: install rpm |
| 194 | + if: matrix.platform-os == 'ubuntu' |
| 195 | + run: sudo apt-get install -y alien fakeroot rpm |
| 196 | + |
| 197 | + - name: Build distribution |
| 198 | + run: | |
| 199 | + case "${{ matrix.platform-os }}" in |
| 200 | + "macos" | "macos-arm64") |
| 201 | + ${MAC_COMMAND} |
| 202 | + ;; |
| 203 | + "windows") |
| 204 | + ${WINDOWS_COMMAND} |
| 205 | + ;; |
| 206 | + *) |
| 207 | + ${LINUX_COMMAND} |
| 208 | + ;; |
| 209 | + esac |
| 210 | + env: |
| 211 | + MAC_COMMAND: "poetry run poe dist_dmg" |
| 212 | + WINDOWS_COMMAND: "poetry run poe dist_msi" |
| 213 | + LINUX_COMMAND: "poetry run poe dist_appimage" |
| 214 | + |
| 215 | + # break this into seperate steps each with their own name that matches the file |
| 216 | + - name: Upload App artifact |
| 217 | + uses: actions/upload-artifact@v4 |
| 218 | + with: |
| 219 | + name: autogptserver-app-${{ matrix.platform-os }} |
| 220 | + path: /Users/runner/work/AutoGPT/AutoGPT/rnd/autogpt_server/build/*.app |
| 221 | + |
| 222 | + - name: Upload dmg artifact |
| 223 | + uses: actions/upload-artifact@v4 |
| 224 | + with: |
| 225 | + name: autogptserver-dmg-${{ matrix.platform-os }} |
| 226 | + path: /Users/runner/work/AutoGPT/AutoGPT/rnd/autogpt_server/build/AutoGPTServer.dmg |
| 227 | + |
| 228 | + - name: Upload msi artifact |
| 229 | + uses: actions/upload-artifact@v4 |
| 230 | + with: |
| 231 | + name: autogptserver-msi-${{ matrix.platform-os }} |
| 232 | + path: D:\a\AutoGPT\AutoGPT\rnd\autogpt_server\dist\*.msi |
| 233 | + |
| 234 | + - name: Upload deb artifact |
| 235 | + uses: actions/upload-artifact@v4 |
| 236 | + with: |
| 237 | + name: autogptserver-deb-${{ matrix.platform-os }} |
| 238 | + path: /Users/runner/work/AutoGPT/AutoGPT/rnd/autogpt_server/build/*.deb |
| 239 | + |
| 240 | + - name: Upload rpm artifact |
| 241 | + uses: actions/upload-artifact@v4 |
| 242 | + with: |
| 243 | + name: autogptserver-rpm-${{ matrix.platform-os }} |
| 244 | + path: /Users/runner/work/AutoGPT/AutoGPT/rnd/autogpt_server/build/*.rpm |
| 245 | + |
| 246 | + - name: Upload tar.gz artifact |
| 247 | + uses: actions/upload-artifact@v4 |
| 248 | + with: |
| 249 | + name: autogptserver-tar.gz-${{ matrix.platform-os }} |
| 250 | + path: /Users/runner/work/AutoGPT/AutoGPT/rnd/autogpt_server/build/*.tar.gz |
| 251 | + |
| 252 | + - name: Upload zip artifact |
| 253 | + uses: actions/upload-artifact@v4 |
| 254 | + with: |
| 255 | + name: autogptserver-zip-${{ matrix.platform-os }} |
| 256 | + path: /Users/runner/work/AutoGPT/AutoGPT/rnd/autogpt_server/build/*.zip |
| 257 | + |
| 258 | + - name: Upload pkg artifact |
| 259 | + uses: actions/upload-artifact@v4 |
| 260 | + with: |
| 261 | + name: autogptserver-pkg-${{ matrix.platform-os }} |
| 262 | + path: /Users/runner/work/AutoGPT/AutoGPT/rnd/autogpt_server/build/*.pkg |
| 263 | + |
| 264 | + - name: Upload AppImage artifact |
| 265 | + uses: actions/upload-artifact@v4 |
| 266 | + with: |
| 267 | + name: autogptserver-AppImage-${{ matrix.platform-os }} |
| 268 | + path: /Users/runner/work/AutoGPT/AutoGPT/rnd/autogpt_server/build/*.AppImage |
0 commit comments