From ea709cc66f9f8fcbd60172c0056d6eeaaa3e4dcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Thu, 5 Dec 2019 12:35:56 +0100 Subject: [PATCH] Add FastAPI tests to Pydantic's CI tests (#1075) fix #1041 * Add test-fastapi.sh script, after failing to create reusable variables in Make * Add test-fastapi Make target * Add fastapi dir for tests to gitignore * Add fastapi tests to Travis * Update test-fastapi to run the minimum (pytest) * Move make test-fastapi to normal run, no "Without Deps" * Install Pydantic without Cython for FastAPI tests * Put FastAPI tests in its own Travis job * Add PR changes description * Remove coverage for FastAPI, it's not relevant for Pydantic * Implement code review changes, refactor Makefile use and fastapi tests * Add a bug intentionally, to test that FastAPI tests are using the current source and make sure it actually breaks CI. * Fix intentional bug. Confirmed it breaks Travis for FastAPI. --- .gitignore | 1 + .travis.yml | 6 ++++++ Makefile | 8 ++++++++ changes/1075-tiangolo.md | 1 + tests/test-fastapi.sh | 14 ++++++++++++++ 5 files changed, 30 insertions(+) create mode 100644 changes/1075-tiangolo.md create mode 100644 tests/test-fastapi.sh diff --git a/.gitignore b/.gitignore index 3643ce4..2dfb355 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,4 @@ pydantic/*.so .auto-format /sandbox/ /.ghtopdep_cache/ +/fastapi/ diff --git a/.travis.yml b/.travis.yml index fdd4c35..b2d52b9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -93,6 +93,12 @@ jobs: - make test env: - 'DEPS=no' + + - stage: test + python: 3.7 + name: 'Test FastAPI' + script: + - make test-fastapi - stage: test python: 3.7 diff --git a/Makefile b/Makefile index 84a2460..d9423ad 100644 --- a/Makefile +++ b/Makefile @@ -88,6 +88,7 @@ clean: rm -rf site rm -rf docs/_build rm -rf docs/.changelog.md docs/.version.md docs/.tmp_schema_mappings.html + rm -rf fastapi/test.db .PHONY: docs docs: @@ -108,3 +109,10 @@ publish: docs zip -r site.zip site @curl -H "Content-Type: application/zip" -H "Authorization: Bearer ${NETLIFY}" \ --data-binary "@site.zip" https://api.netlify.com/api/v1/sites/pydantic-docs.netlify.com/deploys + +fastapi: + git clone https://github.com/tiangolo/fastapi.git + +.PHONY: test-fastapi +test-fastapi: install fastapi + bash tests/test-fastapi.sh diff --git a/changes/1075-tiangolo.md b/changes/1075-tiangolo.md new file mode 100644 index 0000000..7de811a --- /dev/null +++ b/changes/1075-tiangolo.md @@ -0,0 +1 @@ +Run FastAPI tests during Pydantic's CI tests diff --git a/tests/test-fastapi.sh b/tests/test-fastapi.sh new file mode 100644 index 0000000..bfdc78a --- /dev/null +++ b/tests/test-fastapi.sh @@ -0,0 +1,14 @@ +#! /usr/bin/env bash + +set -x +set -e + +cd fastapi +git fetch --tags +latest_tag_commit=$(git rev-list --tags --max-count=1) +latest_tag=$(git describe --tags "${latest_tag_commit}") +git checkout "${latest_tag}" +pip install -U flit +flit install + +PYTHONPATH=./docs/src pytest