|
| 1 | +# Test installation of the latest version from PyPI works. |
| 2 | +# We make sure that we run the tests that apply to the version we installed, |
| 3 | +# rather than the latest tests in main. |
| 4 | +# The reason we do this, is that we want this workflow to test |
| 5 | +# that installing from PyPI leads to a correct installation. |
| 6 | +# If we tested against main, the tests could fail |
| 7 | +# because the tests from main require the new features in main to pass. |
| 8 | +name: Test installation PyPI |
| 9 | + |
| 10 | +on: |
| 11 | + workflow_dispatch: |
| 12 | + schedule: |
| 13 | + # * is a special character in YAML so you have to quote this string |
| 14 | + # This means At 03:00 on Wednesday. |
| 15 | + # see https://crontab.guru/#0_0_*_*_3 |
| 16 | + - cron: '0 3 * * 3' |
| 17 | + |
| 18 | +jobs: |
| 19 | + test-pypi-install: |
| 20 | + name: Test PyPI install ${{ matrix.install-target }} (${{ matrix.python-version }}, ${{ matrix.os }}) |
| 21 | + strategy: |
| 22 | + fail-fast: false |
| 23 | + matrix: |
| 24 | + os: ["ubuntu-latest", "macos-latest", "windows-latest"] |
| 25 | + # Test SPEC0 supported python versions https://scientific-python.org/specs/spec-0000/ |
| 26 | + python-version: [ "3.11", "3.12", "3.13" ] |
| 27 | + install-target: [ "climate-ref", "climate-ref[aft-providers]"] |
| 28 | + runs-on: "${{ matrix.os }}" |
| 29 | + steps: |
| 30 | + - name: Set up Python "${{ matrix.python-version }}" |
| 31 | + id: setup-python |
| 32 | + uses: actions/setup-python@v4 |
| 33 | + with: |
| 34 | + python-version: "${{ matrix.python-version }}" |
| 35 | + - name: Install |
| 36 | + run: | |
| 37 | + pip install --upgrade pip wheel |
| 38 | + pip install "${{ matrix.install-target }}" 2>stderr.txt |
| 39 | + - name: Check no warnings |
| 40 | + if: matrix.os != 'windows-latest' |
| 41 | + run: | |
| 42 | + if grep -q "WARN" stderr.txt; then echo "Warnings in pip install output" && cat stderr.txt && exit 1; else exit 0; fi |
| 43 | + - name: Get version non-windows |
| 44 | + if: matrix.os != 'windows-latest' |
| 45 | + run: | |
| 46 | + INSTALLED_VERSION=`python -c 'import climate_ref; print(f"v{climate_ref.__version__}")'` |
| 47 | + echo $INSTALLED_VERSION |
| 48 | + echo "INSTALLED_VERSION=$INSTALLED_VERSION" >> $GITHUB_ENV |
| 49 | + - name: Get version windows |
| 50 | + if: matrix.os == 'windows-latest' |
| 51 | + run: | |
| 52 | + chcp 65001 # use utf-8 |
| 53 | + python -c 'import climate_ref; f = open("version.txt", "w"); f.write(f"INSTALLED_VERSION=v{climate_ref.__version__}"); f.close()' |
| 54 | + echo "Showing version.txt" |
| 55 | + type version.txt |
| 56 | + type version.txt >> $env:GITHUB_ENV |
| 57 | + - name: Check installed version environment variable |
| 58 | + run: | |
| 59 | + echo "${{ env.INSTALLED_VERSION }}" |
| 60 | + - name: Checkout repository |
| 61 | + uses: actions/checkout@v4 |
| 62 | + with: |
| 63 | + ref: ${{ env.INSTALLED_VERSION }} |
| 64 | + - name: Test installation |
| 65 | + run: | |
| 66 | + which python |
| 67 | + python scripts/test-install.py climate_ref |
| 68 | + test-pypi-install-core: |
| 69 | + name: Test PyPI install ${{ matrix.install-target }} (${{ matrix.python-version }}, ${{ matrix.os }}) |
| 70 | + strategy: |
| 71 | + fail-fast: false |
| 72 | + matrix: |
| 73 | + os: ["ubuntu-latest", "macos-latest", "windows-latest"] |
| 74 | + # Test against all security and bugfix versions: https://devguide.python.org/versions/ |
| 75 | + python-version: [ "3.11", "3.12", "3.13" ] |
| 76 | + install-target: [ "climate-ref-core"] |
| 77 | + runs-on: "${{ matrix.os }}" |
| 78 | + steps: |
| 79 | + - name: Set up Python "${{ matrix.python-version }}" |
| 80 | + id: setup-python |
| 81 | + uses: actions/setup-python@v4 |
| 82 | + with: |
| 83 | + python-version: "${{ matrix.python-version }}" |
| 84 | + - name: Install |
| 85 | + run: | |
| 86 | + pip install --upgrade pip wheel |
| 87 | + pip install "${{ matrix.install-target }}" 2>stderr.txt |
| 88 | + - name: Check no warnings |
| 89 | + if: matrix.os != 'windows-latest' |
| 90 | + run: | |
| 91 | + if grep -q "WARN" stderr.txt; then echo "Warnings in pip install output" && cat stderr.txt && exit 1; else exit 0; fi |
| 92 | + - name: Get version non-windows |
| 93 | + if: matrix.os != 'windows-latest' |
| 94 | + run: | |
| 95 | + INSTALLED_VERSION=`python -c 'import climate_ref_core; print(f"v{climate_ref_core.__version__}")'` |
| 96 | + echo $INSTALLED_VERSION |
| 97 | + echo "INSTALLED_VERSION=$INSTALLED_VERSION" >> $GITHUB_ENV |
| 98 | + - name: Get version windows |
| 99 | + if: matrix.os == 'windows-latest' |
| 100 | + run: | |
| 101 | + chcp 65001 # use utf-8 |
| 102 | + python -c 'import climate_ref_core; f = open("version.txt", "w"); f.write(f"INSTALLED_VERSION=v{climate_ref_core.__version__}"); f.close()' |
| 103 | + echo "Showing version.txt" |
| 104 | + type version.txt |
| 105 | + type version.txt >> $env:GITHUB_ENV |
| 106 | + - name: Check installed version environment variable |
| 107 | + run: | |
| 108 | + echo "${{ env.INSTALLED_VERSION }}" |
| 109 | + - name: Checkout repository |
| 110 | + uses: actions/checkout@v4 |
| 111 | + with: |
| 112 | + ref: ${{ env.INSTALLED_VERSION }} |
| 113 | + - name: Test installation |
| 114 | + run: | |
| 115 | + which python |
| 116 | + python scripts/test-install.py climate_ref_core |
0 commit comments