In a Gitlab CI pipeline, I want to check that the package that was just uploaded to a registry is there and works well. What I do is basically:
[…]
stages:
- […]
- deploy
- deploytest
pip-upload:
stage: deploy
rules:
- if: '$CI_COMMIT_TAG && $CI_COMMIT_TAG =~ /v[1-9].+/'
script:
- python3 setup.py sdist
- python3 -m twine upload --repository-url […] dist/*
test-pip:
stage: deploytest
rules:
- if: '$CI_COMMIT_TAG && $CI_COMMIT_TAG =~ /v[1-9].+/'
script:
- python3 -m pip install --extra-index-url […] --upgrade --pre "mypackage==$PACKAGE_VERSION"
- cd /tmp
- python3 -m pytest --pyargs mypackage
This however requires the creation of the Python version from the git tag on the command line. I use setuptools_scm in my package. I there a way to call this package in a way that it returns the version corresponding to a particular git tag?