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

Commit 3eab0c2

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

File tree

1 file changed

+103
-32
lines changed

1 file changed

+103
-32
lines changed

.github/workflows/ci.yml

Lines changed: 103 additions & 32 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,33 +31,40 @@ 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
4247
with:
4348
repository: opencv/opencv
4449
ref: ${{ steps.latest-release.outputs.tag }}
4550

51+
- uses: seanmiddleditch/gha-setup-ninja@master
52+
id: setup-ninja
53+
if: matrix.os.artifact-name != 'linux-musl'
54+
55+
- name: Manually install ninja
56+
if: steps.setup-ninja.conclusion == 'skipped'
57+
run: apk add samurai
58+
4659
- uses: mozilla-actions/sccache-action@main
4760

4861
- uses: ilammy/msvc-dev-cmd@v1
4962
id: msvc-env
50-
if: startsWith(matrix.os, 'windows')
63+
if: startsWith(matrix.os.runner, 'windows')
5164

5265
- name: Setup MSVC environment
5366
if: steps.msvc-env.conclusion == 'success'
5467
run: |
55-
echo "CMAKE_GENERATOR=Ninja" >> $GITHUB_ENV
5668
echo "CC=cl" >> $GITHUB_ENV
5769
echo "CXX=cl" >> $GITHUB_ENV
5870
@@ -62,6 +74,7 @@ jobs:
6274
cd build
6375
6476
cmake .. \
77+
-D CMAKE_GENERATOR=Ninja \
6578
-D CMAKE_INSTALL_PREFIX=../opencv \
6679
-D CMAKE_BUILD_TYPE=Release \
6780
-D CMAKE_C_COMPILER_LAUNCHER=sccache \
@@ -81,24 +94,29 @@ jobs:
8194
-D WITH_PNG=OFF \
8295
-D WITH_TIFF=OFF
8396
84-
cmake --build . --target install --parallel 4
97+
cmake --build . --target install --parallel $(nproc)
8598
8699
- uses: actions/upload-artifact@main
87100
with:
88-
name: opencv-${{ matrix.os }}
101+
name: opencv-${{ matrix.os.artifact-name || matrix.os.runner }}
89102
path: ./opencv
90103

91104
build:
92-
name: Build Wheel
105+
name: Build Wheel (${{ matrix.os.artifact-name || matrix.os.runner }}, Python ${{ matrix.python }})
93106
needs: [build-opencv]
94107

95108
strategy:
96109
matrix:
97110
os:
98-
- ubuntu-latest
99-
- windows-latest
100-
- macos-13
101-
- macos-latest
111+
- runner: ubuntu-latest
112+
container: quay.io/pypa/manylinux_2_34_x86_64
113+
artifact-name: linux
114+
- runner: ubuntu-latest
115+
container: quay.io/pypa/musllinux_1_2_x86_64
116+
artifact-name: linux-musl
117+
- runner: windows-latest
118+
- runner: macos-13
119+
- runner: macos-latest
102120
python: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
103121
exclude:
104122
- os: macos-latest
@@ -111,27 +129,56 @@ jobs:
111129
run:
112130
shell: bash
113131

114-
runs-on: ${{ matrix.os }}
132+
runs-on: ${{ matrix.os.runner }}
133+
container: ${{ matrix.os.container }}
115134

116135
steps:
117136
- uses: actions/checkout@main
118137

119138
- uses: actions/download-artifact@main
120139
with:
121-
name: opencv-${{ matrix.os }}
140+
name: opencv-${{ matrix.os.artifact-name || matrix.os.runner }}
122141
path: ./opencv
123142

124143
- uses: pdm-project/setup-pdm@main
144+
id: install-pdm
145+
if: ${{ !matrix.os.container }}
125146
with:
126147
python-version: ${{ matrix.python }}
127148
cache: true
128149

150+
- name: Manually install PDM
151+
if: steps.install-pdm.conclusion == 'skipped'
152+
run: |
153+
set -xve
154+
155+
pipx install pdm
156+
export PYTHONPATH=$(python${{matrix.python}} -c 'import sys; print(sys.exec_prefix)')
157+
158+
echo "$PYTHONPATH" >> $GITHUB_PATH
159+
echo "$PYTHONPATH/bin" >> $GITHUB_PATH
160+
echo "LD_LIBRARY_PATH=$PYTHONPATH/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" >> $GITHUB_ENV
161+
162+
echo "pythonLocation=$PYTHONPATH" >> $GITHUB_ENV
163+
echo "PKG_CONFIG_PATH=$PYTHONPATH/lib/pkgconfig" >> $GITHUB_ENV
164+
echo "PYTHON_ROOT_DIR=$PYTHONPATH" >> $GITHUB_ENV
165+
echo "PYTHON2_ROOT_DIR=$PYTHONPATH" >> $GITHUB_ENV
166+
echo "PYTHON3_ROOT_DIR=$PYTHONPATH" >> $GITHUB_ENV
167+
129168
- name: Install dependencies
130169
run: pdm install -G :all --no-self
131170

171+
- uses: seanmiddleditch/gha-setup-ninja@master
172+
id: setup-ninja
173+
if: matrix.os.artifact-name != 'linux-musl'
174+
175+
- name: Manually install ninja
176+
if: steps.setup-ninja.conclusion == 'skipped'
177+
run: apk add samurai
178+
132179
- uses: ilammy/msvc-dev-cmd@v1
133180
id: msvc-env
134-
if: startsWith(matrix.os, 'windows')
181+
if: startsWith(matrix.os.runner, 'windows')
135182

136183
- name: Setup MSVC environment
137184
if: steps.msvc-env.conclusion == 'success'
@@ -151,20 +198,25 @@ jobs:
151198

152199
- uses: actions/upload-artifact@main
153200
with:
154-
name: wheel-${{matrix.os}}-${{matrix.python}}
201+
name: wheel-${{ matrix.os.artifact-name || matrix.os.runner }}-${{ matrix.python }}
155202
path: ./dist/*.whl
156203

157204
test:
158-
name: Test Wheel
205+
name: Test Wheel (${{ matrix.os.artifact-name || matrix.os.runner }}, Python ${{ matrix.python }})
159206
needs: [build]
160207

161208
strategy:
162209
matrix:
163210
os:
164-
- ubuntu-latest
165-
- windows-latest
166-
- macos-13
167-
- macos-latest
211+
- runner: ubuntu-latest
212+
container: quay.io/pypa/manylinux_2_34_x86_64
213+
artifact-name: linux
214+
- runner: ubuntu-latest
215+
container: quay.io/pypa/musllinux_1_2_x86_64
216+
artifact-name: linux-musl
217+
- runner: windows-latest
218+
- runner: macos-13
219+
- runner: macos-latest
168220
python: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
169221
exclude:
170222
- os: macos-latest
@@ -177,26 +229,46 @@ jobs:
177229
run:
178230
shell: bash
179231

180-
runs-on: ${{ matrix.os }}
232+
runs-on: ${{ matrix.os.runner }}
233+
container: ${{ matrix.os.container }}
181234

182235
steps:
183236
- uses: actions/checkout@main
184237

185238
- name: Download wheel
186239
uses: actions/download-artifact@main
187240
with:
188-
name: wheel-${{matrix.os}}-${{matrix.python}}
241+
name: wheel-${{ matrix.os.artifact-name || matrix.os.runner }}-${{ matrix.python }}
189242
path: ./dist
190243

191244
- uses: pdm-project/setup-pdm@main
245+
id: install-pdm
246+
if: ${{ !matrix.os.container }}
192247
with:
193248
python-version: ${{ matrix.python }}
194249
cache: true
195250

251+
- name: Manually install PDM
252+
if: steps.install-pdm.conclusion == 'skipped'
253+
run: |
254+
set -xve
255+
256+
pipx install pdm
257+
export PYTHONPATH=$(python${{matrix.python}} -c 'import sys; print(sys.exec_prefix)')
258+
259+
echo "$PYTHONPATH" >> $GITHUB_PATH
260+
echo "$PYTHONPATH/bin" >> $GITHUB_PATH
261+
echo "LD_LIBRARY_PATH=$PYTHONPATH/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" >> $GITHUB_ENV
262+
263+
echo "pythonLocation=$PYTHONPATH" >> $GITHUB_ENV
264+
echo "PKG_CONFIG_PATH=$PYTHONPATH/lib/pkgconfig" >> $GITHUB_ENV
265+
echo "PYTHON_ROOT_DIR=$PYTHONPATH" >> $GITHUB_ENV
266+
echo "PYTHON2_ROOT_DIR=$PYTHONPATH" >> $GITHUB_ENV
267+
196268
- name: Install dependencies
197269
run: |
198270
pdm install -G test --no-self
199-
pdm add dist/*.whl --no-lock
271+
pdm add -v dist/*.whl --frozen-lockfile
200272
201273
- name: Run tests
202274
run: |
@@ -246,7 +318,6 @@ jobs:
246318

247319
- uses: pdm-project/setup-pdm@main
248320
with:
249-
python-version: "3"
250321
cache: true
251322

252323
- name: Publish to PyPI

0 commit comments

Comments
 (0)