-
Notifications
You must be signed in to change notification settings - Fork 100
151 lines (135 loc) · 4.61 KB
/
build_pypi_ci.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
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
146
147
148
149
150
151
# Run tests using built wheels.
name: Build PyPI CI (no upload)
# Run when changes to pip wheel
on:
push:
paths:
- "setup.py"
- "requirements.txt"
- "dev_requirements.txt"
- "jupyter_requirements.txt"
- "pypi_requirements.txt"
- "environment_build.yml"
- ".github/workflows/build_pypi_ci.yml" # Run!
jobs:
build:
name: Build wheel (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-22.04"]
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategymatrixinclude
include:
# Use this condarc as default
- condarc: .conda/condarc.yaml
- wheel_name: sleap-wheel-linux
- pyver: "3.7"
steps:
# Setup
- name: Checkout
uses: actions/checkout@v4
- name: Setup Miniconda
uses: conda-incubator/[email protected]
with:
miniforge-version: latest
condarc-file: ${{ matrix.condarc }}
python-version: ${{ matrix.pyver }}
environment-file: environment_build.yml
activate-environment: sleap_ci
conda-solver: "libmamba"
- name: Print build environment info
shell: bash -l {0}
run: |
which python
conda list
pip freeze
# Build pip wheel
- name: Build pip wheel
shell: bash -l {0}
run: |
python setup.py bdist_wheel
# Upload artifact "tests" can use it
- name: Upload wheel artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.wheel_name }}
path: dist/*.whl
retention-days: 1
tests:
name: Run tests using wheel (${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: build # Ensure the build job has completed before starting this job.
strategy:
fail-fast: false
matrix:
os: ["ubuntu-22.04", "windows-2022"]
# os: ["ubuntu-22.04", "windows-2022", "macos-14"] # removing macos-14 for now since the setup-python action only support py>=3.10, which is breaking this CI.
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategymatrixinclude
include:
# Default values
- wheel_name: sleap-wheel-linux
- venv_cmd: source venv/bin/activate
- pip_cmd: |
wheel_path=$(find dist -name "*.whl")
echo $wheel_path
pip install '$wheel_path'[dev]
- test_args: pytest --durations=-1 tests/
- condarc: .conda/condarc.yaml
- pyver: "3.7"
# Use special condarc if macos
- os: "macos-14"
condarc: .conda_mac/condarc.yaml
pyver: "3.10"
# Ubuntu specific values
- os: ubuntu-22.04
# Otherwise core dumped in github actions
test_args: |
sudo apt install xvfb libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0
sudo Xvfb :1 -screen 0 1024x768x24 </dev/null &
export DISPLAY=":1"
pytest tests -k 'not exclude_from_linux_pip_test'
# Windows specific values
- os: windows-2022
venv_cmd: .\venv\Scripts\activate
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.pyver }}
# Download wheel
- name: Download wheel artifact
uses: actions/download-artifact@v4
id: download
with:
name: ${{ matrix.wheel_name }}
path: dist
- name: Create virtual environment
run: python -m venv venv
- name: Activate virtual environment
run: ${{ matrix.venv_cmd }}
- name: Install the built wheel (not Mac)
if: runner.os != 'macOS'
shell: bash -l {0}
run: |
wheel_path=$(find dist -name "*.whl")
echo wheel_path
pip install "$wheel_path"[dev]
- name: Install the built wheel (Mac)
if: runner.os == 'macOS'
shell: bash -e {0}
run: |
wheel_path=$(find dist -name "*.whl")
echo wheel_path
pip install "$wheel_path"[dev]
- name: Print test environment info
shell: bash -l {0}
run: |
which python
pip freeze
# Install and test the wheel
- name: Test the built wheel
run: |
${{ matrix.test_args}}