-
Notifications
You must be signed in to change notification settings - Fork 33
115 lines (113 loc) · 4.38 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
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
env: {ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true} # Allow using Node16 actions required for CentOS7
steps:
- name: "Checkout branch ${{ github.head_ref }}"
uses: actions/checkout@v3
- 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*-cp3{8,9,10,11,12,13}/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 .[dev]
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.8', '3.9', '3.10', '3.11', '3.12', '3.13']
steps:
# Checkout the project
- name: "Checkout branch ${{ github.head_ref }}"
uses: actions/checkout@v4
# 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@v5
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 x86_64-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 .[dev]
# 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.8', '3.9', '3.10', '3.11', '3.12', '3.13']
steps:
# Checkout the project
- name: "Checkout branch ${{ github.head_ref }}"
uses: actions/checkout@v4
# 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@v5
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 .[dev]
# Run tests
python -m pytest -v -s python\mocpy
deactivate