Skip to content

Commit

Permalink
Re-enable fastapi tests in CI (#6883)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmontagu committed Jul 26, 2023
1 parent 14f27b5 commit 7fefff2
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 26 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -156,6 +156,22 @@ jobs:
name: coverage
path: coverage

test-fastapi:
# If some tests start failing due to out-of-date schemas/validation errors/etc.,
# update the `tests/test_fastapi.sh` script to exclude tests that have known-acceptable failures.
name: test fastapi
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: set up python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: test
run: make test-fastapi

test-mypy:
name: mypy ${{ matrix.mypy-version }} / ${{ matrix.python-version }}
runs-on: ubuntu-latest
Expand Down Expand Up @@ -308,6 +324,7 @@ jobs:
- test
- test-memray
- test-mypy
- test-fastapi

runs-on: ubuntu-latest

Expand Down
17 changes: 0 additions & 17 deletions .github/workflows/integration.yml
Expand Up @@ -23,20 +23,3 @@ jobs:

- name: test
run: make test-pydantic-extra-types

test-fastapi:
name: test fastapi
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: set up python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: install pydantic
run: pip install -e .

- name: test
run: make test-fastapi
4 changes: 1 addition & 3 deletions Makefile
Expand Up @@ -82,9 +82,7 @@ test-examples: .pdm

.PHONY: test-fastapi ## Run the FastAPI tests with this version of pydantic
test-fastapi:
# TODO: Fetch single branch after FastAPI compatible release
# git clone https://github.com/tiangolo/fastapi.git --single-branch
git clone https://github.com/tiangolo/fastapi.git
git clone https://github.com/tiangolo/fastapi.git --single-branch
./tests/test_fastapi.sh

.PHONY: test-pydantic-settings ## Run the pydantic-settings tests with this version of pydantic
Expand Down
22 changes: 16 additions & 6 deletions tests/test_fastapi.sh
Expand Up @@ -6,11 +6,21 @@ set -e
cd fastapi
git fetch --tags

# TODO: Use the proper latest tag once FastAPI stable release is compatible with Pydantic V2.
# latest_tag=$(git describe --tags --abbrev=0)
# git switch -d "${latest_tag}"
git switch "main-pv2"

pip install -r requirements.txt
# Install the version of pydantic from the current branch, not the released version used by fastapi
pip uninstall -y pydantic
cd .. && pip install . && cd fastapi

# ./scripts/test.sh accepts arbitrary arguments and passes them to the pytest call.
# This may be necessary if we make low-consequence changes to pydantic, such as minor changes the details of a JSON
# schema or the contents of a ValidationError
#
# To skip a specific test, add '--deselect path/to/test.py::test_name' to the end of this command
#
# To update the list of deselected tests, remove all deselections, run the tests, and re-add any remaining failures
./scripts/test.sh \
--deselect tests/test_filter_pydantic_sub_model_pv2.py::test_validator_is_cloned \
--deselect tests/test_multi_body_errors.py::test_jsonable_encoder_requiring_error \
--deselect tests/test_multi_body_errors.py::test_put_incorrect_body_multiple \

./scripts/test.sh
# TODO: Update the deselections after https://github.com/tiangolo/fastapi/pull/9943 is merged

0 comments on commit 7fefff2

Please sign in to comment.