Automatically run a server in a subprocess if no API URL is specified #16065
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: Integration tests | |
on: | |
pull_request: | |
paths: | |
- .github/workflows/integration-tests.yaml | |
- "src/prefect/**/*.py" | |
- requirements.txt | |
- requirements-client.txt | |
- requirements-dev.txt | |
- ui/** | |
- .nvmrc | |
- Dockerfile | |
- flows/* | |
push: | |
branches: | |
- main | |
paths: | |
- .github/workflows/integration-tests.yaml | |
- "**/*.py" | |
- requirements.txt | |
- requirements-client.txt | |
- requirements-dev.txt | |
- ui/** | |
- .nvmrc | |
- Dockerfile | |
jobs: | |
compatibility-tests: | |
name: Integration tests @${{ matrix.server-version.version }} | |
timeout-minutes: 10 | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
server-version: [ | |
# These versions correspond to Prefect image tags, the patch version is | |
# excluded to always pull the latest patch of each minor version. The ref | |
# should generally be set to the latest patch release for that version. | |
{version: "2.19", ref: "2.19.2", image: "prefecthq/prefect:2.19-python3.10"}, | |
{version: "main", ref: "main"}, | |
] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
fetch-depth: 0 | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v5 | |
id: setup_python | |
with: | |
python-version: "3.10" | |
- name: UV Cache | |
# Manually cache the uv cache directory | |
# until setup-python supports it: | |
# https://github.com/actions/setup-python/issues/822 | |
uses: actions/cache@v4 | |
id: cache-uv | |
with: | |
path: ~/.cache/uv | |
key: uvcache-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles('requirements-client.txt', 'requirements.txt', 'requirements-dev.txt') }} | |
- name: Install python packages | |
run: | | |
python -m pip install -U uv | |
uv pip install --upgrade --system . | |
- name: Start server@${{ matrix.server-version.version }} | |
if: ${{ matrix.server-version.version != 'main' }} | |
env: | |
PREFECT_API_URL: http://127.0.0.1:4200/api | |
PREFECT_LOGGING_SERVER_LEVEL: DEBUG | |
PREFECT_EXPERIMENTAL_EVENTS: "true" | |
run: > | |
docker run \ | |
--name "prefect-server" \ | |
-d \ | |
-p 4200:4200 \ | |
-e PREFECT_API_URL=${{ env.PREFECT_API_URL }} \ | |
-e PREFECT_LOGGING_SERVER_LEVEL=${{ env.PREFECT_LOGGING_SERVER_LEVEL }} \ | |
-e PREFECT_EXPERIMENTAL_EVENTS=${{ env.PREFECT_EXPERIMENTAL_EVENTS }} \ | |
${{ matrix.server-version.image }} \ | |
prefect server start --analytics-off --host 0.0.0.0 | |
./scripts/wait-for-server.py | |
# TODO: Replace `wait-for-server` with dedicated command | |
# https://github.com/PrefectHQ/prefect/issues/6990 | |
- name: Start server | |
if: ${{ matrix.server-version.version == 'main' }} | |
env: | |
PREFECT_API_URL: http://127.0.0.1:4200/api | |
PREFECT_LOGGING_SERVER_LEVEL: DEBUG | |
run: > | |
prefect server start --analytics-off --host 0.0.0.0 2>&1 > server.log & | |
./scripts/wait-for-server.py | |
# TODO: Replace `wait-for-server` with dedicated command | |
# https://github.com/PrefectHQ/prefect/issues/6990 | |
- name: Run integration flows | |
env: | |
PREFECT_API_URL: http://127.0.0.1:4200/api | |
SERVER_VERSION: ${{ matrix.server-version.version }} | |
run: > | |
./scripts/run-integration-flows.py flows/ | |
- name: Show server logs | |
if: always() | |
run: | | |
cat server.log || echo "No logs available" | |
docker logs prefect-server || echo "No logs available" |