Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 89ca6a4

Browse filesBrowse files
sergregoryAndrey Senyaevasenyaev
authored
Add GitHub actions setup for CI instead of Travis & Appveyour (where possible) (opencv#470)
* Add initial config for github actions * Allow actions for all branches and PRs to master by default * Fix typo * Do not set docker image info for multibuild, as we do it in github actions * Do not run github action in docker as multiduild will do it for us * Remove error steps - somehow I've missed them when cleaned for the build * Merge all build logic into one step as somehow build wheel is not known when sourced and used in different steps * Debug: try to change directory to get inside the repo sources * Adjust env variables to enable build * Specify docker image to use in github builds * Enable back all python versions in build matrix * Remove numpy as build dependency as prebuilt docker should handle it for us * Make linux build matrix wider - enable contrib, headless/gui, source/binary distribution * Fix return code setting for skipped tests in case of sdist * Build source distribution with only one version of python - as we do not care abnout python version when doing the source distribution * Try to fix config * Try to fix config * Enable OSX builds * Quickfix to enable OSX build * Temporary disable linux and all pythons execpt one to reduce the build matrix size * Disable cache stage that was implemented for travis * Do not unlink python2 for github osx builds * Fix ffmpeg bottle build command * Disable travis cache stage * Changed build_wheels to Windows platform * Try new pipeline * Try windows with a new configuration * Try bash on Windows * Added ubuntu and macos into pipeline * Fix if condition for windows * Turned on all python versions, uploading artifacts * Fixed Windows and created Release job * Add missed source distribution build * Move x86 python builds to github actions. Travis does only aarch64 now * Split linux and OSX builds to exclude x86 OSX builds from build matrix * Reduce architectures to x64 for both OSX and Ubuntu as x86 is supported for windows only * Add PyPI secrets usage * Publish packages built in PRs to testPyPI * Push to test PyPI on each package build. Remove unneded build on push to master * Apply review comments * Combine all release steps into one job Co-authored-by: Andrey Senyaev <andrey.senyaev@xperience.ai> Co-authored-by: Andrey Senyaev <76472231+asenyaev@users.noreply.github.com>
1 parent fd4e604 commit 89ca6a4
Copy full SHA for 89ca6a4

File tree

5 files changed

+359
-655
lines changed
Filter options

5 files changed

+359
-655
lines changed

‎.github/workflows/build_wheels.yml

Copy file name to clipboard
+279Lines changed: 279 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,279 @@
1+
name: Build PYPI wheels for opencv-python
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
release:
8+
types: [published, edited]
9+
10+
11+
jobs:
12+
build-windows-x86_64:
13+
runs-on: ${{ matrix.os }}
14+
defaults:
15+
run:
16+
shell: powershell
17+
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
os: [windows-latest]
22+
python-version: [3.6, 3.7, 3.8, 3.9]
23+
platform: [x86, x64]
24+
with_contrib: [0, 1]
25+
without_gui: [0, 1]
26+
build_sdist: [0]
27+
28+
env:
29+
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
30+
SDIST: ${{ matrix.build_sdist || 0}}
31+
ENABLE_HEADLESS: ${{ matrix.without_gui }}
32+
ENABLE_CONTRIB: ${{ matrix.with_contrib }}
33+
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v2
37+
with:
38+
submodules: true
39+
fetch-depth: 0
40+
41+
- name: Update submodules
42+
run: |
43+
git submodule update --remote
44+
45+
- name: Set up Python ${{ matrix.python-version }}
46+
uses: actions/setup-python@v2
47+
with:
48+
python-version: ${{ matrix.python-version }}
49+
architecture: ${{ matrix.platform }}
50+
51+
- name: Setup MSBuild.exe
52+
uses: warrenbuckley/Setup-MSBuild@v1
53+
54+
- name: build script
55+
run: |
56+
python --version
57+
python -m pip install --upgrade pip
58+
python -m pip install --upgrade setuptools
59+
set "CI_BUILD=1" && python -m pip wheel --wheel-dir=%cd%\wheelhouse . --verbose
60+
shell: cmd
61+
62+
- name: before test
63+
run: |
64+
cd ${{ github.workspace }}/tests
65+
&python -m pip install --user --no-warn-script-location (ls "../wheelhouse/opencv*.whl")
66+
if ($LastExitCode -ne 0) {throw $LastExitCode}
67+
shell: powershell
68+
69+
- name: run test
70+
run: |
71+
cd ${{ github.workspace }}/tests
72+
python -m unittest test
73+
shell: cmd
74+
75+
- name: saving artifacts
76+
uses: actions/upload-artifact@v2
77+
with:
78+
name: wheels
79+
path: wheelhouse/opencv*.whl
80+
81+
build:
82+
runs-on: ${{ matrix.os }}
83+
defaults:
84+
run:
85+
shell: bash
86+
87+
strategy:
88+
fail-fast: false
89+
matrix:
90+
os: [ubuntu-latest, macos-latest]
91+
python-version: [3.6, 3.7, 3.8, 3.9]
92+
platform: [x64]
93+
with_contrib: [0, 1]
94+
without_gui: [0, 1]
95+
build_sdist: [0]
96+
97+
env:
98+
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
99+
REPO_DIR: .
100+
BUILD_COMMIT: master
101+
PROJECT_SPEC: opencv-python
102+
MB_PYTHON_VERSION: ${{ matrix.python-version }}
103+
TRAVIS_PYTHON_VERSION: ${{ matrix.python-version }}
104+
MB_ML_VER: 2014
105+
NP_TEST_DEP: numpy
106+
TRAVIS_BUILD_DIR: ${{ github.workspace }}
107+
CONFIG_PATH: travis_config.sh
108+
DOCKER_IMAGE: quay.io/skvark/manylinux2014_${PLAT}
109+
USE_CCACHE: 1
110+
UNICODE_WIDTH: 32
111+
SDIST: ${{ matrix.build_sdist || 0}}
112+
ENABLE_HEADLESS: ${{ matrix.without_gui }}
113+
ENABLE_CONTRIB: ${{ matrix.with_contrib }}
114+
115+
steps:
116+
- name: Checkout
117+
uses: actions/checkout@v2
118+
with:
119+
submodules: true
120+
fetch-depth: 0
121+
122+
- name: Update submodules
123+
run: |
124+
git submodule update --remote
125+
126+
- name: Set up Python ${{ matrix.python-version }}
127+
uses: actions/setup-python@v2
128+
if: ${{ 'macos-latest' == matrix.os }}
129+
with:
130+
python-version: ${{ matrix.python-version }}
131+
architecture: ${{ matrix.platform }}
132+
133+
- name: Setup Environment variables
134+
run: |
135+
if [ "macos-latest" == "${{ matrix.os }}" ]; then echo "TRAVIS_OS_NAME=osx" >> $GITHUB_ENV; else echo "TRAVIS_OS_NAME=${{ matrix.os }}" >> $GITHUB_ENV; fi
136+
if [ "schedule" == "${{ github.event_name }}" ]; then echo "TRAVIS_EVENT_TYPE=cron" >> $GITHUB_ENV; else echo "TRAVIS_EVENT_TYPE=${{ github.event_name }}" >> $GITHUB_ENV; fi
137+
if [ "schedule" == "${{ github.event_name }}" ]; then echo "BUILD_COMMIT=master" >> $GITHUB_ENV; else echo "BUILD_COMMIT=$BUILD_COMMIT" >> $GITHUB_ENV; fi
138+
if [ "x64" == "${{ matrix.platform }}" ]; then echo "PLAT=x86_64" >> $GITHUB_ENV; fi
139+
if [ "x86" == "${{ matrix.platform }}" ]; then echo "PLAT=i686" >> $GITHUB_ENV; fi
140+
echo "BUILD_DEPENDS=$(echo $NP_BUILD_DEP)" >> $GITHUB_ENV;
141+
echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV;
142+
143+
- name: before install
144+
run: |
145+
set -e
146+
# Check out and prepare the source
147+
# Multibuild doesn't have releases, so --depth would break eventually (see
148+
# https://superuser.com/questions/1240216/server-does-not-allow-request-for-unadvertised)
149+
git submodule update --init multibuild
150+
source multibuild/common_utils.sh
151+
# https://github.com/matthew-brett/multibuild/issues/116
152+
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export ARCH_FLAGS=" "; fi
153+
source multibuild/travis_steps.sh
154+
# This sets -x
155+
# source travis_multibuild_customize.sh
156+
echo $ENABLE_CONTRIB > contrib.enabled
157+
echo $ENABLE_HEADLESS > headless.enabled
158+
set -x
159+
build_wheel $REPO_DIR $PLAT
160+
install_run $PLAT
161+
set +x
162+
- name: saving artifacts
163+
uses: actions/upload-artifact@v2
164+
with:
165+
name: wheels
166+
path: wheelhouse/opencv*.whl
167+
168+
169+
build_sdist:
170+
runs-on: ${{ matrix.os }}
171+
defaults:
172+
run:
173+
shell: bash
174+
175+
strategy:
176+
fail-fast: false
177+
matrix:
178+
os: [ubuntu-latest]
179+
python-version: [3.8]
180+
platform: [x64]
181+
with_contrib: [0, 1]
182+
without_gui: [0, 1]
183+
build_sdist: [1]
184+
185+
env:
186+
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
187+
REPO_DIR: .
188+
BUILD_COMMIT: master
189+
PROJECT_SPEC: opencv-python
190+
PLAT: x86_64
191+
MB_PYTHON_VERSION: ${{ matrix.python-version }}
192+
TRAVIS_PYTHON_VERSION: ${{ matrix.python-version }}
193+
MB_ML_VER: 2014
194+
NP_TEST_DEP: numpy
195+
TRAVIS_BUILD_DIR: ${{ github.workspace }}
196+
CONFIG_PATH: travis_config.sh
197+
DOCKER_IMAGE: quay.io/skvark/manylinux2014_${PLAT}
198+
USE_CCACHE: 1
199+
UNICODE_WIDTH: 32
200+
SDIST: ${{ matrix.build_sdist || 0}}
201+
ENABLE_HEADLESS: ${{ matrix.without_gui || 0 }}
202+
ENABLE_CONTRIB: ${{ matrix.with_contrib || 0}}
203+
204+
steps:
205+
- name: Checkout
206+
uses: actions/checkout@v2
207+
with:
208+
submodules: true
209+
fetch-depth: 0
210+
211+
- name: Update submodules
212+
run: |
213+
git submodule update --remote
214+
215+
- name: Set up Python ${{ matrix.python-version }}
216+
uses: actions/setup-python@v2
217+
with:
218+
python-version: ${{ matrix.python-version }}
219+
architecture: ${{ matrix.platform }}
220+
221+
- name: Setup Environment variables
222+
run: |
223+
if [ "macos-latest" == "${{ matrix.os }}" ]; then echo "TRAVIS_OS_NAME=osx" >> $GITHUB_ENV; else echo "TRAVIS_OS_NAME=${{ matrix.os }}" >> $GITHUB_ENV; fi
224+
if [ "schedule" == "${{ github.event_name }}" ]; then echo "TRAVIS_EVENT_TYPE=cron" >> $GITHUB_ENV; else echo "TRAVIS_EVENT_TYPE=${{ github.event_name }}" >> $GITHUB_ENV; fi
225+
if [ "schedule" == "${{ github.event_name }}" ]; then echo "BUILD_COMMIT=master" >> $GITHUB_ENV; else echo "BUILD_COMMIT=$BUILD_COMMIT" >> $GITHUB_ENV; fi
226+
echo "BUILD_DEPENDS=$(echo $NP_BUILD_DEP)" >> $GITHUB_ENV;
227+
echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV;
228+
229+
- name: before install
230+
run: |
231+
set -e
232+
# Build and package
233+
set -x
234+
python -m pip install --upgrade pip
235+
python -m pip install scikit-build
236+
python setup.py sdist
237+
set +x
238+
# Install and run tests
239+
set -x
240+
echo "skipping tests because of sdist"
241+
- name: saving artifacts
242+
uses: actions/upload-artifact@v2
243+
with:
244+
name: wheels
245+
path: dist/opencv*.tar.gz
246+
247+
release_opencv_python:
248+
if: startsWith(github.ref, 'refs/tags/v')
249+
needs: [build, build-windows-x86_64, build_sdist]
250+
runs-on: ubuntu-latest
251+
environment: opencv-python-release
252+
defaults:
253+
run:
254+
shell: bash
255+
steps:
256+
- uses: actions/download-artifact@v2
257+
with:
258+
name: wheels
259+
path: wheelhouse/
260+
- name: Upload wheels for opencv_python
261+
run: |
262+
python -m pip install twine
263+
python -m twine upload -u ${{ secrets.OPENCV_PYTHON_USERNAME }} -p ${{ secrets.OPENCV_PYTHON_PASSWORD }} --skip-existing wheelhouse/opencv_python-*
264+
265+
- name: Upload wheels for opencv_contrib_python
266+
run: |
267+
python -m pip install twine
268+
python -m twine upload -u ${{ secrets.OPENCV_CONTRIB_PYTHON_USERNAME }} -p ${{ secrets.OPENCV_CONTRIB_PYTHON_PASSWORD }} --skip-existing wheelhouse/opencv_contrib_python-*
269+
270+
- name: Upload wheels for opencv_python_headless
271+
run: |
272+
python -m pip install twine
273+
python -m twine upload -u ${{ secrets.OPENCV_PYTHON_HEADLESS_USERNAME }} -p ${{ secrets.OPENCV_PYTHON_HEADLESS_PASSWORD }} --skip-existing wheelhouse/opencv_python_headless-*
274+
275+
- name: Upload wheels for opencv_contrib_python_headless
276+
277+
run: |
278+
python -m pip install twine
279+
python -m twine upload -u ${{ secrets.OPENCV_CONTRIB_PYTHON_HEADLESS_USERNAME }} -p ${{ secrets.OPENCV_CONTRIB_PYTHON_HEADLESS_PASSWORD }} --skip-existing wheelhouse/opencv_contrib_python_headless-*

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.