Is there an existing way to run python unit tests ...
# general
r
Is there an existing way to run python unit tests in a
docker_image
target or to derive a
docker_environment
from a
docker_image
target?
l
Someone with more knowledge may have a better trick but I’ve done this by creating a
docker_environment
with an
image
field that matches the repository/tag generated by a
docker_image
and then including the image target itself in
runtime_package_dependencies
of my
python_tests
target, which is environment aware.
r
@late-keyboard-89314 When you do that, can you pull the image from local or do you need to pull it from your image registry?
l
It works pulling from local
r
Do you just do
repository:tag
? I'm getting access denied
1
l
Let me put together a minimal example and post a gist or something 🙂
🙏 1
Okay, doing this from scratch again uncovered some behaviour I hadn’t previously noticed. Having the target specified in
runtime_package_dependencies
does trigger a build of the image target, but only after the environment has tried to pull it. So on the first run, it’ll fail because you haven’t run
pants package
yet. This also means unbeknownst to me that my test runs have always been an image version behind. In my case, it’s not a big deal because I don’t change this container often enough to have noticed and I must have just always run package first. The other catch is that you must use a tag for your image that isn’t
latest
since Docker will attempt to pull that tag even if the image already exists locally. https://gist.github.com/jcrumb-u21/5b032cd7b5431a9dd43267f4d1d2adeb
🐐 1
In our CI one of the first things we do is running
pants package ::
as a smoke test, so I’ve never noted the ordering issue wrt
runtime_package_dependencies