I currently have a Jenkins pipeline which builds and tests my python package using tox. If all unittests pass, it will be uploaded to my local devpi index.
Using devpi test <mypackage>
I can attach the test results to the release file on the index.
But this will download the already built package again, repeat all of the already passed test suites defined in the tox.ini
file and only then upload the results in form of a toxresult.json
.
Is there any way to directly upload the toxresult.json
alongside the release files?
According to the quickstart and the documentation of test command there seems to be no command line option, and neither in the upload command.
Of course I could change my Jenkins pipeline to skip the tests before uploading and then build, upload and test the package using devpi. If the devpi test
command fails I can remove the package from the index.
But I would rather not upload a package with failing tests in the first place.
The anonymous uploads
It's relatively easy if you allow the anonymous user to upload test results (which is the default setting IIRC). Make a
POST
request to the URL of the uploaded dist, passingtox
results as JSON payload. Example:On success, you should get a result similar to
You can find the target URL in the
File
column of the files table on the project page. Or query the JSON API and filter the results, e.g.Authenticated uploads
devpi
uses basic auth, so simply pass the base64-encoded credentials in theAuthorization: Basic
header. Example, withcurl
again:If you need details on the test upload authentication, check out my other answer here.