-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add FastAPI tests to Pydantic's CI tests #1075
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1075 +/- ##
======================================
Coverage 100% 100%
======================================
Files 20 20
Lines 3365 3365
Branches 663 663
======================================
Hits 3365 3365 Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks awesome.
Much simpler than I expected it to be, just a few small things.
.travis.yml
Outdated
@@ -82,6 +82,7 @@ jobs: | |||
script: | |||
- pip uninstall -y cython email-validator typing-extensions devtools | |||
- make test | |||
- make test-fastapi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think fastapi tests should be be an entirely new stage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect. This should be corrected in the latest.
test-fastapi.sh
Outdated
@@ -0,0 +1,24 @@ | |||
#! /usr/bin/env bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you're brave you could probably implement this inside the Makefile
.
Makefile even has it's own logic for checking if a file or directory exists.
If it's a pain, leave it for now and I'll fix in future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
otherwise maybe move this into tests
to avoid cluttering up the root directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make the fastapi
directory and any other related files should also live in tests
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About putting it in the Makefile
, I tried first to put all the bash script in it, but I couldn't.
I tried several things, but I couldn't get the inline variables to work, the: latest_tag_commit
and latest_tag
. I also tried getting rid of them and "sub-bashing" the commands, nesting them, but couldn't get that to work either 😞
If you know a Make trick for that, let me know 😅
About the logic to check for the directory, I first had a:
fastapi:
git clone https://github.com/tiangolo/fastapi.git
.PHONY: test-fastapi
test-fastapi: fastapi
bash tests/test-fastapi.sh
To use the automatic directory target fastapi
. But I removed it and put it all in the bash script, trying not to clutter the Makefile
.
If you prefer it like that, with the git clone
in the Makefile
, I can put it there.
The rest of the Bash script... I don't really know what else to try to make those variables to work 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought you would probably prefer the extra Make target, so I just went ahead and refactored that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved the script to ./tests/
.
But I couldn't move the fastapi
repo clone to under tests
, because tests
is already a package, and it seems the imports get confused when trying to run tests inside of a directory inside of a tests
directory.
I can also clone it to a ./tmp/fastapi
dir to make it explicit. Or a ./.tmp/fastapi
to make it a hidden dir.
test-fastapi.sh
Outdated
git checkout "${latest_tag}" | ||
pip install flit | ||
flit install | ||
SKIP_CYTHON=1 pip install -e .. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe this can be achieved by changing the recipe to require install
as a parent-recipe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it wouldn't work, but it it did! 🎉
…rent source and make sure it actually breaks CI.
Thanks! 🚀 🎉 |
fix pydantic#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.
…ydantic#1075) Co-authored-by: David Montague <35119617+dmontagu@users.noreply.github.com>
Change Summary
Add FastAPI testing during Pydantic's CI tests.
It has a new Make target
test-fastapi
.That, in turn, runs a script
test-fastapi.sh
.The script will:
I had to do it in an external Bash script after failing to do it inline in the
Makefile
. I couldn't find a way to create the variableslatest_tag_commit
andlatest_tag
to re-use them in the same Make target.Related issue number
#1041
Checklist
changes/<pull request or issue id>-<github username>.md
file added describing change(see changes/README.md for details)