Skip to content

Commit

Permalink
Merge branch 'main' into bump-pytest-8
Browse files Browse the repository at this point in the history
  • Loading branch information
hainenber authored Apr 24, 2024
2 parents adc788b + 5e09b0c commit abaa9f6
Show file tree
Hide file tree
Showing 487 changed files with 246,183 additions and 4,684 deletions.
4 changes: 2 additions & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ If changing documentation, a link to a preview of the page is great.

- [ ] This pull request references any related issue by including "closes `<link to issue>`"
- If no issue exists and your change is not a small fix, please [create an issue](https://github.com/PrefectHQ/prefect/issues/new/choose) first.
- [ ] This pull request includes tests or only affects documentation.
- [ ] If this pull request adds new functionality, it includes unit tests that cover the changes
- [ ] This pull request includes a label categorizing the change e.g. `maintenance`, `fix`, `feature`, `enhancement`, `docs`.
<!-- If you do not have permission to add a label, a maintainer will add one for you -->

Expand All @@ -36,4 +36,4 @@ For documentation changes:
For new functions or classes in the Python SDK:

- [ ] This pull request includes helpful docstrings.
- [ ] If a new Python file was added, this pull request contains a stub page in the Python SDK docs and an entry in `mkdocs.yml` navigation.
- [ ] If a new Python file was added, this pull request contains a stub page in the Python SDK docs and an entry in `mkdocs.yml` navigation.
74 changes: 74 additions & 0 deletions .github/workflows/api-compatibility-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
name: Cloud API Compatibility
on:
pull_request:
paths:
- .github/workflows/api-compatibility-tests.yaml
- "**/*.py"
- requirements*.txt
- setup.cfg
- compat-tests
push:
branches:
- main

# Limit concurrency by workflow/branch combination.
#
# For pull request builds, pushing additional changes to the
# branch will cancel prior in-progress and pending builds.
#
# For builds triggered on a branch push, additional changes
# will wait for prior builds to complete before starting.
#
# https://docs.github.com/en/actions/using-jobs/using-concurrency
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
compatibility-tests:

timeout-minutes: 10

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
# Versioneer only generates correct versions with a full fetch
fetch-depth: 0
persist-credentials: false
submodules: true

- name: Set up Python 3.12
uses: actions/setup-python@v5
id: setup_python
with:
python-version: 3.12

- 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 packages
run: |
python -m pip install -U uv
uv pip install --upgrade --system -e .[dev] 'pydantic>=2.4,<3'
- name: Create Cloud OpenAPI JSON
working-directory: compat-tests
run: curl https://api.prefect.cloud/api/openapi.json > cloud_schema.json

- name: Create OSS OpenAPI JSON
working-directory: compat-tests
run: python ../scripts/generate_oss_openapi_schema.py

- name: Run API compatibility tests
working-directory: compat-tests
run: pytest -vv
2 changes: 1 addition & 1 deletion .github/workflows/benchmarks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
pull_request:
paths:
- .github/workflows/python-tests.yaml
- "**/*.py"
- "src/prefect/**/*.py"
- requirements.txt
- requirements-dev.txt
- setup.cfg
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/create-tags-for-changed-integrations.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Create tags for changed integrations

on:
release:
types: [published]
workflow_dispatch:

jobs:
create-integrations-tags:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -U packaging gh-util
- name: Get previous tag
id: get-previous-tag
run: echo "tag=$(git describe --tags --abbrev=0)" >> $GITHUB_OUTPUT

- name: Push tags for changed integrations
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PREVIOUS_TAG: ${{ steps.get-previous-tag.outputs.tag }}
CURRENT_COMMIT: ${{ github.sha }}

run: python scripts/create_tags_for_changed_collections.py
84 changes: 84 additions & 0 deletions .github/workflows/integration-pacakge-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Integrations Packages Tests

on:
pull_request:
paths:
- "src/integrations/*/**"
push:
branches:
- main
paths:
- "src/integrations/*/**"

jobs:
prepare-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Generate matrix
id: set-matrix
run: |
if [[ $GITHUB_EVENT_NAME == 'pull_request' ]]; then
COMMIT_RANGE="${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}"
else
COMMIT_RANGE="${{ github.event.before }}..${{ github.event.after }}"
fi
python scripts/generate_integration_package_tests_matrix.py "$COMMIT_RANGE" > matrix.json
cat matrix.json
echo "matrix=$(cat matrix.json)" >> $GITHUB_OUTPUT
run-tests:
name: Run Tests for ${{ matrix.package }} on Python ${{ matrix.python-version }}
needs: prepare-matrix
runs-on: ubuntu-latest
strategy:
matrix: ${{fromJson(needs.prepare-matrix.outputs.matrix)}}
fail-fast: false
steps:
- name: Display current test matrix
run: echo '${{ toJSON(matrix) }}'

- uses: actions/checkout@v4
with:
persist-credentials: false

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
id: setup_python
with:
python-version: ${{ matrix.python-version }}

- 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(format('src/integrations/{0}/pyproject.toml', matrix.package)) }}

- name: Install dependencies
working-directory: src/integrations/${{ matrix.package }}
run: |
python -m pip install -U uv
uv pip install --upgrade --system -e .[dev]
- name: Run tests
env:
PREFECT_API_DATABASE_CONNECTION_URL: "sqlite+aiosqlite:///./orion-tests.db"
working-directory: src/integrations/${{ matrix.package }}
run: >
pytest tests
--numprocesses auto
--maxprocesses 6
--dist loadscope
71 changes: 71 additions & 0 deletions .github/workflows/integration-package-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Publish integration package to PyPI

on:
push:
tags:
- "prefect-\\w+-[0-9]+.*"

jobs:
build-pypi-dists:
name: Build Python package
runs-on: ubuntu-latest
outputs:
PACKAGE_NAME: ${{ steps.package_name.outputs.PACKAGE_NAME }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.commit }}
fetch-depth: 0
persist-credentials: false

- name: Extract package name
id: package_name
run: |
TAG_NAME=${{ github.ref_name }}
PACKAGE_NAME=$(echo $TAG_NAME | sed 's/-[0-9][.0-9]*$//')
echo "PACKAGE_NAME=$PACKAGE_NAME" >> $GITHUB_OUTPUT
- name: Set up Python 3.8
uses: actions/setup-python@v5
with:
python-version: "3.8"
cache: "pip"
cache-dependency-path: "requirements*.txt"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade build
working-directory: src/integrations/${{ steps.package_name.outputs.PACKAGE_NAME }}

- name: Build a binary wheel and a source tarball
run: |
python -m build --wheel
python -m build --sdist
working-directory: src/integrations/${{ steps.package_name.outputs.PACKAGE_NAME }}

- name: Publish build artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ steps.package_name.outputs.PACKAGE_NAME }}-pypi-dists
path: "./src/integrations/${{ steps.package_name.outputs.PACKAGE_NAME }}/dist"

publish-pypi-dists:
name: Publish to PyPI
environment: "prod"
needs: build-pypi-dists
runs-on: ubuntu-latest
permissions:
# this permission is mandatory for trusted publishing
id-token: write

steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: ${{ needs.build-pypi-dists.outputs.PACKAGE_NAME}}-pypi-dists
path: "./dist"

- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
29 changes: 22 additions & 7 deletions .github/workflows/integration-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
pull_request:
paths:
- .github/workflows/integration-tests.yaml
- "**/*.py"
- "src/prefect/**/*.py"
- requirements.txt
- requirements-client.txt
- requirements-dev.txt
Expand Down Expand Up @@ -51,6 +51,8 @@ jobs:
- "2.14"
- "2.15"
- "2.16"
- "2.17"
- "2.18"

# We can include the following to always test against the last release
# but the value is not particularly clear and we can just append the
Expand Down Expand Up @@ -117,6 +119,10 @@ jobs:
server-disable-csrf: true
- prefect-version: "2.16"
server-incompatible: false
- prefect-version: "2.17"
server-incompatible: false
- prefect-version: "2.18"
server-incompatible: false

steps:
- uses: actions/checkout@v4
Expand All @@ -143,39 +149,47 @@ jobs:
- name: Install python packages
run: |
python -m pip install -U uv
uv pip install --upgrade --system -e .[dev]
uv pip install --upgrade --system .
- name: Start server@${{ matrix.prefect-version }}
if: ${{ ! matrix.server-incompatible }}
env:
PREFECT_EXPERIMENTAL_EVENTS: True
PREFECT_API_URL: http://127.0.0.1:4200/api
run: >
docker run
--name "prefect-server-${{ matrix.prefect-version }}"
--detach
--publish 4200:4200
${{ matrix.extra_docker_run_options }}
--env PREFECT_EXPERIMENTAL_EVENTS=True
prefecthq/prefect:${{ matrix.prefect-version }}-python3.10
${{ matrix.server_command || 'prefect server start --analytics-off' }} --host 0.0.0.0
PREFECT_API_URL="http://127.0.0.1:4200/api"
./scripts/wait-for-server.py
# TODO: Replace `wait-for-server` with dedicated command
# https://github.com/PrefectHQ/prefect/issues/6990
- name: Run integration flows with client@dev, server@${{ matrix.prefect-version }}
if: ${{ ! matrix.server-incompatible }}
env:
PREFECT_API_URL: http://127.0.0.1:4200/api
PREFECT_EXPERIMENTAL_EVENTS: True
run: >
TEST_SERVER_VERSION=${{ matrix.prefect-version }}
PREFECT_API_URL="http://127.0.0.1:4200/api"
TEST_CLIENT_VERSION=$(python -c 'import prefect; print(prefect.__version__)')
./scripts/run-integration-flows.py
./scripts/run-integration-flows.py flows/
- name: Turn off CSRF protection for older clients.
if: ${{ matrix.server-disable-csrf }}
run: |
echo "PREFECT_SERVER_CSRF_PROTECTION_ENABLED=0" >> $GITHUB_ENV
- name: Start server@dev
env:
PREFECT_API_URL: http://127.0.0.1:4200/api
PREFECT_EXPERIMENTAL_EVENTS: True
run: |
# First, we must stop the server container if it exists
# TODO: Once we have `prefect server stop` we can run these tests first and the
Expand All @@ -184,14 +198,15 @@ jobs:
docker stop "prefect-server-${{ matrix.prefect-version }}" || echo "That's okay!"
prefect server start --analytics-off&
PREFECT_API_URL="http://127.0.0.1:4200/api" ./scripts/wait-for-server.py
./scripts/wait-for-server.py
- name: Run integration flows with client@${{ matrix.prefect-version }}, server@dev
run: >
docker run
--env PREFECT_API_URL="http://127.0.0.1:4200/api"
--env TEST_SERVER_VERSION=$(python -c 'import prefect; print(prefect.__version__)')
--env TEST_CLIENT_VERSION=${{ matrix.client_version }}
--env PREFECT_API_URL="http://127.0.0.1:4200/api"
--env PREFECT_EXPERIMENTAL_EVENTS=True
--volume $(pwd)/flows:/opt/prefect/integration/flows
--volume $(pwd)/scripts:/opt/prefect/integration/scripts
--network host
Expand Down
Loading

0 comments on commit abaa9f6

Please sign in to comment.