-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (142 loc) · 6.06 KB
/
install-pypi.yaml
File metadata and controls
145 lines (142 loc) · 6.06 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# 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 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.pip-install-flags }} (${{ matrix.os }}, ${{ matrix.python-version }}, ${{ matrix.compiler }}-${{ matrix.compiler-version }})
runs-on: "${{ matrix.os }}"
strategy:
fail-fast: false
matrix:
os: [
"ubuntu-latest",
"ubuntu-24.04-arm",
"macos-latest",
"macos-13",
"windows-latest",
"windows-11-arm",
]
# Test against all security and bugfix versions: https://devguide.python.org/versions/
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ]
# Check both 'library' install and the 'application' (i.e. locked) install
install-target: [ "example-fgen-basic", "example-fgen-basic[locked]" ]
pip-install-flags: [ "--only-binary example-fgen-basic" ]
toolchain: [ "no-toolchain" ]
compiler: [ "no-compiler-needed" ]
compiler-version: [ "na" ]
include:
# Source installs on all OS for a stable Python version
# (no need to do more than the combinations below)
# (duplicated the config as I can't see how to write this more succintly
# using gitlab's matrix logic)
- os: "ubuntu-latest"
python-version: "3.11"
install-target: "example-fgen-basic"
pip-install-flags: "--no-binary example-fgen-basic"
# TODO: consider adding other compilers
# (see https://github.com/fortran-lang/setup-fortran)
compiler: "gcc"
compiler-version: "13"
- os: "macos-latest"
python-version: "3.11"
install-target: "example-fgen-basic"
pip-install-flags: "--no-binary example-fgen-basic"
# TODO: consider adding other compilers
# (see https://github.com/fortran-lang/setup-fortran)
compiler: "gcc"
compiler-version: "13"
- os: "windows-latest"
python-version: "3.11"
install-target: "example-fgen-basic"
pip-install-flags: "--no-binary example-fgen-basic"
# TODO: consider adding other compilers
# (see https://github.com/fortran-lang/setup-fortran)
compiler: "gcc"
compiler-version: "13"
exclude:
- os: windows-11-arm
python-version: 3.9
- os: windows-11-arm
python-version: 3.10
steps:
- name: Set up Python "${{ matrix.python-version }}"
id: setup-python
uses: actions/setup-python@v4
with:
python-version: "${{ matrix.python-version }}"
- name: Install Fortran compiler
# When building from source, ensure we have a Fortran compiler
if: matrix.pip-install-flags == '--no-binary example-fgen-basic'
uses: fortran-lang/setup-fortran@v1
id: setup-fortran
with:
compiler: ${{ matrix.compiler }}
version: ${{ matrix.compiler-version }}
- name: Install
run: |
pip install --upgrade pip wheel
pip install "${{ matrix.install-target }}" ${{ matrix.pip-install-flags }}
- name: Check no warnings
if: ${{ !(startsWith(matrix.os, 'windows')) }}
run: |
# Install and save stderr to file so we can check for missing target errors
# (re-install is a bit stupid,
# but it doesn't actually do anything except emit the warning in practice)
pip install "${{ matrix.install-target }}" 2>stderr.txt
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: ${{ !(startsWith(matrix.os, 'windows')) }}
run: |
INSTALLED_VERSION=`python -c 'import example_fgen_basic; print(f"v{example_fgen_basic.__version__}")'`
echo $INSTALLED_VERSION
echo "INSTALLED_VERSION=$INSTALLED_VERSION" >> $GITHUB_ENV
- name: Get version windows
if: ${{ startsWith(matrix.os, 'windows') }}
run: |
chcp 65001 # use utf-8
python -c 'import example_fgen_basic; f = open("version.txt", "w"); f.write(f"INSTALLED_VERSION=v{example_fgen_basic.__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 min test dependencies
run: |
pip install -r requirements-only-tests-min-locked.txt
- name: Run tests
run: |
# Can't run doctests here because the paths are different.
# This only runs with minimum test dependencies installed.
# So this is really just a smoke test,
# rather than a super thorough integration test.
# You will have to make sure that your tests run
# without all the extras installed for this to pass.
pytest tests -r a -vv tests
- name: Install all test dependencies
run: |
pip install -r requirements-only-tests-locked.txt
- name: Run tests with extra test dependencies installed
run: |
# Can't run doctests here because the paths are different.
pytest tests -r a -vv tests