-
Notifications
You must be signed in to change notification settings - Fork 33
120 lines (118 loc) · 4.46 KB
/
test.yml
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
name: test-mocpy
on:
push:
branches:
- master
pull_request:
branches:
- master
# Allows to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
# Linux is specific: because of manylinux, we have to use a docker file
test-linux64-wheels:
runs-on: ubuntu-latest
# CentOS 7 64 bits Docker Hub image that 'build-linux64-wheels' executes in.
# See https://github.com/pypa/manylinux for this particular container:
# * CPython 3.7, 3.8, 3.9, 3.10 and 3.11 installed in /opt/python/<python tag>-<abi tag>
container: quay.io/pypa/manylinux2014_x86_64
steps:
- name: "Checkout branch ${{ github.head_ref }}"
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
- name: "Install Rust"
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
# Build and install locally wheels for all pre-installed python version (in /opt/python/, see docker image comment)
# We use maturin: https://github.com/PyO3/maturin#pypy
- name: "Build and test wheels"
run: |
source $HOME/.cargo/env
for PYBIN in /opt/python/cp{37,38,39,310,311}-*/bin; do
echo "Loop on PYBIN: $PYBIN"
# With maturin develop, we have to use virtualenv
"${PYBIN}/pip" install virtualenv
"${PYBIN}/virtualenv" mocpy-env
source mocpy-env/bin/activate
pip install --upgrade pip
pip install maturin
maturin build --release --compatibility manylinux2014
maturin develop --release
pip install -r requirements/tests.txt
python -m pytest -v -s python/mocpy
pip freeze > requirements-uninstall.txt
pip uninstall -r requirements-uninstall.txt -y
deactivate
rm -r mocpy-env/
done
test-macos-wheels:
runs-on: macOS-latest
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
steps:
# Checkout the project
- name: "Checkout branch ${{ github.head_ref }}"
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
# Set up python, see https://docs.github.com/en/actions/guides/building-and-testing-python
- name: "Set up Python ${{ matrix.python-version }} on MacOS"
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
# Test python code
- name: "Build and test wheel for Python ${{ matrix.python-version }} on MacOS"
run: |
# Install, create and activate a python virtualenv
rustup target add aarch64-apple-darwin
pip install virtualenv
virtualenv mocpy-env
source mocpy-env/bin/activate
pip install --upgrade pip
# Install and use maturin
pip install maturin
maturin build --release --target universal2-apple-darwin
maturin develop --release
# Install dependencies
pip install -r requirements/tests.txt
# Run tests
python -m pytest -v -s python/mocpy
# Clean
pip freeze > requirements-uninstall.txt
pip uninstall -r requirements-uninstall.txt -y
deactivate
rm -r mocpy-env/
test-windows-wheels:
runs-on: windows-latest
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
steps:
# Checkout the project
- name: "Checkout branch ${{ github.head_ref }}"
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
# Set up python, see https://docs.github.com/en/actions/guides/building-and-testing-python
- name: "Set up Python ${{ matrix.python-version }} on Windows"
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
# Test python code
- name: "Build and test wheel for Python ${{ matrix.python-version }} on Windows"
run: |
# Install, create and activate a python virtualenv
# See: https://mothergeo-py.readthedocs.io/en/latest/development/how-to/venv-win.html
pip install virtualenv
virtualenv mocpy-env
.\mocpy-env\Scripts\activate
# Install and use maturin
pip install maturin
maturin develop --release
# Install dependencies
pip install -r requirements\tests.txt
# Run tests
python -m pytest -v -s python\mocpy
deactivate