Skip to content
This repository was archived by the owner on Jan 3, 2025. It is now read-only.

Commit 1f1bfd3

Browse files
committed
👷 Enhance CI workflow with manylinux container
1 parent 33783ea commit 1f1bfd3

File tree

1 file changed

+89
-29
lines changed

1 file changed

+89
-29
lines changed

.github/workflows/ci.yml

Lines changed: 89 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,20 @@ on:
99

1010
jobs:
1111
build-opencv:
12-
name: Build OpenCV
12+
name: Build OpenCV (${{ matrix.os.artifact-name || matrix.os.runner }})
1313

1414
strategy:
1515
matrix:
1616
os:
17-
- ubuntu-latest
18-
- windows-latest
19-
- macos-13
20-
- macos-latest
17+
- runner: ubuntu-latest
18+
container: quay.io/pypa/manylinux_2_34_x86_64
19+
artifact-name: linux
20+
- runner: ubuntu-latest
21+
container: quay.io/pypa/musllinux_1_2_x86_64
22+
artifact-name: linux-musl
23+
- runner: windows-latest
24+
- runner: macos-13
25+
- runner: macos-latest
2126

2227
defaults:
2328
run:
@@ -26,16 +31,16 @@ jobs:
2631
env:
2732
SCCACHE_GHA_ENABLED: true
2833

29-
runs-on: ${{ matrix.os }}
34+
runs-on: ${{ matrix.os.runner }}
35+
container: ${{ matrix.os.container }}
3036

3137
steps:
3238
- name: Get latest release
3339
id: latest-release
3440
run: |
35-
curl -s https://api.github.com/repos/opencv/opencv/releases/latest \
36-
-H "Accept: application/vnd.github.v3+json" \
37-
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
38-
| jq -r '.tag_name' | tee latest-release.txt
41+
curl -Ls -o /dev/null -w %{url_effective} \
42+
https://github.com/opencv/opencv/releases/latest \
43+
| sed 's#.*tag/\(.*\)$#\1#' > latest-release.txt
3944
echo "tag=$(cat latest-release.txt)" >> $GITHUB_OUTPUT
4045
4146
- uses: actions/checkout@main
@@ -52,6 +57,8 @@ jobs:
5257
- name: Setup MSVC environment
5358
if: steps.msvc-env.conclusion == 'success'
5459
run: |
60+
choco install -y ninja
61+
5562
echo "CMAKE_GENERATOR=Ninja" >> $GITHUB_ENV
5663
echo "CC=cl" >> $GITHUB_ENV
5764
echo "CXX=cl" >> $GITHUB_ENV
@@ -81,24 +88,29 @@ jobs:
8188
-D WITH_PNG=OFF \
8289
-D WITH_TIFF=OFF
8390
84-
cmake --build . --target install --parallel 4
91+
cmake --build . --target install --parallel $(nproc)
8592
8693
- uses: actions/upload-artifact@main
8794
with:
88-
name: opencv-${{ matrix.os }}
95+
name: opencv-${{ matrix.os.artifact-name || matrix.os.runner }}
8996
path: ./opencv
9097

9198
build:
92-
name: Build Wheel
99+
name: Build Wheel (${{ matrix.os.artifact-name || matrix.os.runner }}, Python ${{ matrix.python }})
93100
needs: [build-opencv]
94101

95102
strategy:
96103
matrix:
97104
os:
98-
- ubuntu-latest
99-
- windows-latest
100-
- macos-13
101-
- macos-latest
105+
- runner: ubuntu-latest
106+
container: quay.io/pypa/manylinux_2_34_x86_64
107+
artifact-name: linux
108+
- runner: ubuntu-latest
109+
container: quay.io/pypa/musllinux_1_2_x86_64
110+
artifact-name: linux-musl
111+
- runner: windows-latest
112+
- runner: macos-13
113+
- runner: macos-latest
102114
python: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
103115
exclude:
104116
- os: macos-latest
@@ -111,17 +123,38 @@ jobs:
111123
run:
112124
shell: bash
113125

114-
runs-on: ${{ matrix.os }}
126+
runs-on: ${{ matrix.os.runner }}
127+
container: ${{ matrix.os.container }}
115128

116129
steps:
117130
- uses: actions/checkout@main
118131

119132
- uses: actions/download-artifact@main
120133
with:
121-
name: opencv-${{ matrix.os }}
134+
name: opencv-${{ matrix.os.artifact-name || matrix.os.runner }}
122135
path: ./opencv
123136

137+
- name: Manually install PDM
138+
id: install-pdm
139+
if: matrix.os.container
140+
run: |
141+
set -xve
142+
143+
curl -fsSL https://pdm.fming.dev/install-pdm.py | python
144+
set PYTHONPATH=$(python${{matrix.python}} -c 'import sys; print(sys.exec_prefix)')
145+
146+
echo "$PYTHONPATH" >> $GITHUB_PATH
147+
echo "$PYTHONPATH/bin" >> $GITHUB_PATH
148+
echo "LD_LIBRARY_PATH=$PYTHONPATH/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" >> $GITHUB_ENV
149+
150+
echo "pythonLocation=$PYTHONPATH" >> $GITHUB_ENV
151+
echo "PKG_CONFIG_PATH=$PYTHONPATH/lib/pkgconfig" >> $GITHUB_ENV
152+
echo "PYTHON_ROOT_DIR=$PYTHONPATH" >> $GITHUB_ENV
153+
echo "PYTHON2_ROOT_DIR=$PYTHONPATH" >> $GITHUB_ENV
154+
echo "PYTHON3_ROOT_DIR=$PYTHONPATH" >> $GITHUB_ENV
155+
124156
- uses: pdm-project/setup-pdm@main
157+
if: steps.install-pdm.conclusion == 'skipped'
125158
with:
126159
python-version: ${{ matrix.python }}
127160
cache: true
@@ -136,6 +169,8 @@ jobs:
136169
- name: Setup MSVC environment
137170
if: steps.msvc-env.conclusion == 'success'
138171
run: |
172+
choco install -y ninja
173+
139174
CV_DIR=$(find ./opencv/x64 | grep -i '\.cmake$' | head -n 1)
140175
echo "OpenCV_DIR=$(realpath $(dirname $CV_DIR))" >> $GITHUB_ENV
141176
echo "OpenCV_STATIC=ON" >> $GITHUB_ENV
@@ -151,20 +186,25 @@ jobs:
151186

152187
- uses: actions/upload-artifact@main
153188
with:
154-
name: wheel-${{matrix.os}}-${{matrix.python}}
189+
name: wheel-${{ matrix.os.artifact-name || matrix.os.runner }}-${{ matrix.python }}
155190
path: ./dist/*.whl
156191

157192
test:
158-
name: Test Wheel
193+
name: Test Wheel (${{ matrix.os.artifact-name || matrix.os.runner }}, Python ${{ matrix.python }})
159194
needs: [build]
160195

161196
strategy:
162197
matrix:
163198
os:
164-
- ubuntu-latest
165-
- windows-latest
166-
- macos-13
167-
- macos-latest
199+
- runner: ubuntu-latest
200+
container: quay.io/pypa/manylinux_2_34_x86_64
201+
artifact-name: linux
202+
- runner: ubuntu-latest
203+
container: quay.io/pypa/musllinux_1_2_x86_64
204+
artifact-name: linux-musl
205+
- runner: windows-latest
206+
- runner: macos-13
207+
- runner: macos-latest
168208
python: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
169209
exclude:
170210
- os: macos-latest
@@ -177,26 +217,47 @@ jobs:
177217
run:
178218
shell: bash
179219

180-
runs-on: ${{ matrix.os }}
220+
runs-on: ${{ matrix.os.runner }}
221+
container: ${{ matrix.os.container }}
181222

182223
steps:
183224
- uses: actions/checkout@main
184225

185226
- name: Download wheel
186227
uses: actions/download-artifact@main
187228
with:
188-
name: wheel-${{matrix.os}}-${{matrix.python}}
229+
name: wheel-${{ matrix.os.artifact-name || matrix.os.runner }}-${{ matrix.python }}
189230
path: ./dist
190231

232+
- name: Manually install PDM
233+
id: install-pdm
234+
if: matrix.os.container
235+
run: |
236+
set -xve
237+
238+
curl -fsSL https://pdm.fming.dev/install-pdm.py | python
239+
set PYTHONPATH=$(python${{matrix.python}} -c 'import sys; print(sys.exec_prefix)')
240+
241+
echo "$PYTHONPATH" >> $GITHUB_PATH
242+
echo "$PYTHONPATH/bin" >> $GITHUB_PATH
243+
echo "LD_LIBRARY_PATH=$PYTHONPATH/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" >> $GITHUB_ENV
244+
245+
echo "pythonLocation=$PYTHONPATH" >> $GITHUB_ENV
246+
echo "PKG_CONFIG_PATH=$PYTHONPATH/lib/pkgconfig" >> $GITHUB_ENV
247+
echo "PYTHON_ROOT_DIR=$PYTHONPATH" >> $GITHUB_ENV
248+
echo "PYTHON2_ROOT_DIR=$PYTHONPATH" >> $GITHUB_ENV
249+
echo "PYTHON3_ROOT_DIR=$PYTHONPATH" >> $GITHUB_ENV
250+
191251
- uses: pdm-project/setup-pdm@main
252+
if: steps.install-pdm.conclusion == 'skipped'
192253
with:
193254
python-version: ${{ matrix.python }}
194255
cache: true
195256

196257
- name: Install dependencies
197258
run: |
198259
pdm install -G test --no-self
199-
pdm add dist/*.whl --no-lock
260+
pdm add -v dist/*.whl --frozen-lockfile
200261
201262
- name: Run tests
202263
run: |
@@ -246,7 +307,6 @@ jobs:
246307

247308
- uses: pdm-project/setup-pdm@main
248309
with:
249-
python-version: "3"
250310
cache: true
251311

252312
- name: Publish to PyPI

0 commit comments

Comments
 (0)