Test installation PyPI #41
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
# Test installation of the latest version from PyPI works. | |
# We make sure that we run the tests that apply to the version we installed, | |
# rather than the latest tests in main. | |
# The reason we do this, is that we want this workflow to test | |
# that installing from PyPI/conda leads to a correct installation. | |
# If we tested against main, the tests could fail | |
# because the tests from main require the new features in main to pass. | |
name: Test installation PyPI | |
on: | |
workflow_dispatch: | |
schedule: | |
# * is a special character in YAML so you have to quote this string | |
# This means At 03:00 on Wednesday. | |
# see https://crontab.guru/#0_0_*_*_3 | |
- cron: '0 3 * * 3' | |
jobs: | |
test-pypi-install: | |
name: Test PyPI install ${{ matrix.install-target }} (${{ matrix.python-version }}, ${{ matrix.os }}) | |
runs-on: "${{ matrix.os }}" | |
strategy: | |
fail-fast: false | |
matrix: | |
# Unsure how to make pip install work on MacOS and Windows | |
# given the udunits2 headache, | |
# recommend to use conda instead. | |
# os: ["ubuntu-latest", "macos-latest", "windows-latest"] | |
os: ["ubuntu-latest"] | |
python-version: [ "3.9", "3.10", "3.11" ] | |
# Check both 'library' install and the 'application' (i.e. locked) install | |
install-target: ["input4mips-validation", "input4mips-validation[locked]"] | |
steps: | |
- name: Install udunits2 | |
run: | | |
# This is a faff, but it works. | |
# I guess it's a good illustration of why using conda for this stack is much better. | |
mkdir $HOME/udunits | |
cd $HOME/udunits | |
curl -O https://downloads.unidata.ucar.edu/udunits/2.2.28/udunits-2.2.28.tar.gz | |
tar -xzvf udunits-2.2.28.tar.gz | |
ls -al | |
cd udunits-2.2.28 | |
./configure | |
make all install check | |
cd .. | |
cd .. | |
ls $HOME/udunits/lib/ | |
- name: Install netCDF binaries | |
if: matrix.os == 'ubuntu-latest' | |
run: sudo apt-get install netcdf-bin | |
- name: Set up Python "${{ matrix.python-version }}" | |
id: setup-python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "${{ matrix.python-version }}" | |
- name: Install | |
run: | | |
pip install --upgrade pip wheel | |
pip install cf-units | |
pip install "${{ matrix.install-target }}" 2>stderr.txt | |
- name: Check no warnings | |
if: matrix.os != 'windows-latest' | |
run: | | |
if grep -q "WARN" stderr.txt; then echo "Warnings in pip install output" && cat stderr.txt && exit 1; else exit 0; fi | |
- name: Get version | |
run: | | |
INSTALLED_VERSION=`python -c 'import input4mips_validation; print(f"v{input4mips_validation.__version__}")'` | |
echo $INSTALLED_VERSION | |
echo "INSTALLED_VERSION=$INSTALLED_VERSION" >> $GITHUB_ENV | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ env.INSTALLED_VERSION }} | |
- name: Test installation | |
run: | | |
which python | |
which cfchecks | |
ls $HOME/udunits/lib/ | |
export LD_LIBRARY_PATH="$HOME/udunits/lib/:$LD_LIBRARY_PATH" | |
python -c 'import ctypes.util; print(ctypes.util.find_library("udunits2"))' | |
python scripts/test-install.py | |
- name: Install pytest | |
run: | | |
pip install pytest | |
- name: Run tests | |
run: | | |
export LD_LIBRARY_PATH="$HOME/udunits/lib/:$LD_LIBRARY_PATH" | |
python -c 'import ctypes.util; print(ctypes.util.find_library("udunits2"))' | |
pytest tests -r a -vv -s |