-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (73 loc) · 2.84 KB
/
install-pypi.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# 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:
pull_request:
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:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: [ "3.9", "3.10", "3.11" ]
# Check both 'library' install and the 'application' (i.e. locked) install
install-target: ["openscm-zenodo", "openscm-zenodo[locked]"]
steps:
- 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 "${{ 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 non-windows
if: matrix.os != 'windows-latest'
run: |
INSTALLED_VERSION=`python -c 'import openscm_zenodo; print(f"v{openscm_zenodo.__version__}")'`
echo $INSTALLED_VERSION
echo "INSTALLED_VERSION=$INSTALLED_VERSION" >> $GITHUB_ENV
- name: Get version windows
if: matrix.os == 'windows-latest'
run: |
chcp 65001 # use utf-8
python -c 'import openscm_zenodo; f = open("version.txt", "w"); f.write(f"INSTALLED_VERSION=v{openscm_zenodo.__version__}"); f.close()'
echo "Showing version.txt"
type version.txt
type version.txt >> $env:GITHUB_ENV
- name: Check installed version environment variable
run: |
echo "${{ env.INSTALLED_VERSION }}"
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ env.INSTALLED_VERSION }}
- name: Test installation
run: |
which python
python scripts/test-install.py
- name: Install pytest
run: |
pip install pytest
- name: Run tests
run: |
# Can't run doctests here because the paths are different
pytest tests -r a -vv tests