How does one save test artifacts outside of the sa...
# general
a
How does one save test artifacts outside of the sandbox so they can be uploaded to CI (Github)? I'm trying to troubleshoot a tricky test failure. The test passes when executed locally whether via
pytest
or
pants test
as well as inside docker using
nektos/act
. It succeeds when run on Github CI (cloud) if via
pytest
but it fails when run via
pants test
on GitHub CI (cloud). I'm trying to save the output of the function under test to a file so I can inspect what is being produced. The file is saved inside the sandbox but I can't seem to find documentation explaining how to make that available to the CI host for upload.
e
Is the data you need present under
dist/
when running
./pants test --report
?: https://www.pantsbuild.org/docs/reference-test#report IIRC the junit xml capture includes full stdout and stderr of each test.
a
The file I'm looking for is not part of the test report. It's produced as a CSV file during the execution of the test. Normally, I would not desire side effects from tests but in this case it only fails when run under
pants
in the cloud. It succeeds locally via
pants
I'm trying to leave some breadcrumbs to determine why
e
Is the file too big to read and dump to stdout?
There are other ways of course, in
pants.toml
use subprocess-environment to export an env var containing
"%(build root)s"
, and then use that env var in the test to write out a file under the build root. https://www.pantsbuild.org/docs/reference-subprocess-environment#env_vars
a
Thank you. I'll try that.
e
But also don't limit your mind to a pantsism here. You could use any env var. Most CI systems export a plethora you could use to know where you are (checked out to). You can plumb any one of those to the test with https://www.pantsbuild.org/docs/reference-python_tests#codeextra_env_varscode
18 ways to do this.
👍🏽 1
a
Thanks for that point. I was a bit stuck in the idea, "oh no, pants has sandboxed the build directory, how do I get into the sandbox?"