Add setuptools_scm for pyproject.toml, setup.cfg and setup.py #2
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# documentation: https://help.github.com/en/articles/workflow-syntax-for-github-actions | ||
name: Test version for tarball without git metadata | ||
on: [push, pull_request, workflow_dispatch] | ||
permissions: read-all | ||
jobs: | ||
test_pip_install: | ||
# ubuntu <= 20.04 is required for python 3.6 | ||
runs-on: ubuntu-20.04 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10', '3.11'] | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
with: | ||
persist-credentials: false | ||
fetch-depth: 0 | ||
- name: Set up Python | ||
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install setuptools | ||
run: | | ||
if [[ "${{ matrix.python-version }}" == "3.6" ]]; then | ||
# system installed setuptools version in RHEL8 and CO7 | ||
python -m pip install --user setuptools==39.2.0 | ||
fi | ||
- name: Install setuptools_scm | ||
run: | | ||
if [[ "${{ matrix.python-version }}" == "3.6" ]]; then | ||
python -m pip install --user 'setuptools_scm>=4.0.0,<=4.1.2' | ||
else | ||
python -m pip install --user setuptools_scm | ||
fi | ||
- name: Check python and setuptools versions | ||
python --version | ||
python -m pip --version | ||
python -c 'import setuptools; print("setuptools", setuptools.__version__)' | ||
python -c 'import setuptools_scm; print("setuptools_scm", setuptools_scm.__version__)' | ||
- name: Download and extract tarball for current commit | ||
wget "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/archive/$GITHUB_SHA.tar.gz" | ||
tar -xzf "$GITHUB_SHA.tar.gz" | ||
- name: Check version when running against uninstalled git clone | ||
uninstalled_version=$(PYTHONPATH="$PWD/tests-suite-$GITHUB_SHA" python3 -c "import eessi.testsuite; print(eessi.testsuite.__version__)") | ||
echo "Version from uninstalled git clone: $uninstalled_version" | ||
fallback_version=$(grep -oP 'fallback_version\s*=\s*"\K[^"]+' "test-suite-$GITHUB_SHA/pyproject.toml") | ||
echo "Testing if this version is the fallback version from pyproject.toml ..." | ||
if [[ "$uninstalled_version" -ne "$fallback_version" ]]; then | ||
exit 1 | ||
else | ||
echo "... yes!" | ||
fi | ||
- name: Install from extracted tarball | ||
run: | | ||
# Make it easier to figure out CI issues in case of CI failures related to SCM versioning | ||
export SETUPTOOLS_SCM_DEBUG=1 | ||
# Change dir to the extracted tarball | ||
cd "test-suite-$GITHUB_SHA" | ||
python -m pip install . --user | ||
echo "Checking contents of .local" | ||
find $HOME/.local | ||
# make sure we are not in the source directory | ||
cd $HOME | ||
echo "Checking if file 'eessi/testsuite/_version.py' was generated by setuptools_scm": | ||
cat .local/lib/python${{ matrix.python-version}}/site-packages/eessi/testsuite/_version.py | ||
echo "Checking if we can import the __version__ from eessi.testsuite" | ||
installed_version=$(python -c 'import eessi.testsuite; print("eessi.testsuite:", eessi.testsuite.__version__)') | ||
echo "Version from installed testsuite: $installed_version" | ||
echo "Testing if this is the fallback version from pyproject.toml ..." | ||
if [[ "$installed_version" -ne "$fallback_version" ]]; then | ||
exit 1 | ||
else | ||
echo "... yes!" | ||
fi | ||
echo "Checking if we can import eessi.testsuite.utils" | ||
python -c 'import eessi.testsuite.utils' | ||
echo "Checking if we can import eessi.testsuite.tests.apps" | ||
python -c 'import eessi.testsuite.tests.apps' |