-
Notifications
You must be signed in to change notification settings - Fork 63
193 lines (169 loc) · 6.14 KB
/
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# On a push to any branch this workflow:
# - builds the Docker image,
# - build wheels for different Python versions,
# - installs the wheel for each Python version and runs the unit tests
# against newest and oldest versions of dependencies.
# On manual dispatch this workflow:
# - pushes the previously built Docker image to DockerHub with tag "dev".
name: ci and release
on:
push:
workflow_dispatch:
jobs:
build_docker:
name: Build Docker image
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/#-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and export
uses: docker/build-push-action@v6
with:
context: .
tags: mv-extractor:local
outputs: type=docker,dest=/tmp/image.tar
cache-from: type=registry,ref=lubo1994/mv-extractor:buildcache
cache-to: type=registry,ref=lubo1994/mv-extractor:buildcache,mode=max
- name: Upload Docker image as artifact
uses: actions/upload-artifact@v4
with:
name: mv-extractor-docker-image
path: /tmp/image.tar
test_docker:
name: Run unit tests in Docker container (only for the Python version used in the Dockerfile command)
runs-on: ubuntu-latest
needs:
- build_docker
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download artifact containing Docker image
uses: actions/download-artifact@v4
with:
name: mv-extractor-docker-image
path: /tmp
- name: Load Docker image
run: |
docker load --input /tmp/image.tar
- name: Run unit tests
run: |
docker run -v ${{ github.workspace }}:/home/video_cap \
mv-extractor:local \
/bin/bash -c ' \
yum install -y compat-openssl10 && \
python3.12 -m unittest discover -s tests -p "*tests.py"
'
build_and_test_wheels:
name: Build wheels for cp${{ matrix.python }}-${{ matrix.platform_id }}
runs-on: ${{ matrix.os }}
needs:
- build_docker
strategy:
# Ensure that a wheel builder finishes even if another fails
fail-fast: false
matrix:
include:
- os: ubuntu-latest
python: 39
bitness: 64
platform_id: manylinux_x86_64
manylinux_image: mv-extractor:local
numpy_min_version: "numpy==1.19.3"
opencv_min_version: "opencv-python==4.4.0.46"
- os: ubuntu-latest
python: 310
bitness: 64
platform_id: manylinux_x86_64
manylinux_image: mv-extractor:local
numpy_min_version: "numpy==1.21.2"
opencv_min_version: "opencv-python==4.5.4.60"
- os: ubuntu-latest
python: 311
bitness: 64
platform_id: manylinux_x86_64
manylinux_image: mv-extractor:local
numpy_min_version: "numpy==1.23.3"
opencv_min_version: "opencv-python==4.7.0.72"
- os: ubuntu-latest
python: 312
bitness: 64
platform_id: manylinux_x86_64
manylinux_image: mv-extractor:local
numpy_min_version: "numpy==1.26.0"
opencv_min_version: "opencv-python==4.9.0.80"
# opencv-python does not yet support Python 3.13 as of Oct 2024
# - os: ubuntu-latest
# python: 313
# bitness: 64
# platform_id: manylinux_x86_64
# manylinux_image: mv-extractor:local
# numpy_min_version: "numpy==2.1.0"
# opencv_min_version: "opencv-python=="
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download artifact containing Docker image
uses: actions/download-artifact@v4
with:
name: mv-extractor-docker-image
path: /tmp
- name: Load Docker image
run: |
docker load --input /tmp/image.tar
- name: Build and test wheels
uses: pypa/cibuildwheel@v2.21.3
env:
CIBW_PLATFORM: linux
CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }}
# Disable building PyPy wheels on all platforms
CIBW_SKIP: pp*
CIBW_ARCHS: x86_64
CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.manylinux_image }}
#CIBW_MANYLINUX_I686_IMAGE: ${{ matrix.manylinux_image }}
CIBW_BUILD_FRONTEND: build
CIBW_TEST_COMMAND: |
echo "Running unit tests" && \
yum install -y compat-openssl10 && \
ls {project} && \
PROJECT_ROOT={project} python3 -m unittest discover -s {project}/tests -p "*tests.py" && \
echo "Running unit tests against oldest supported versions of dependencies" && \
python3 -m pip install ${{ matrix.numpy_min_version }} ${{ matrix.opencv_min_version }} && \
PROJECT_ROOT={project} python3 -m unittest discover -s {project}/tests -p "*tests.py"
CIBW_BUILD_VERBOSITY: 1
- uses: actions/upload-artifact@v4
with:
name: python-wheel-${{ matrix.python }}
path: ./wheelhouse/*.whl
push_docker:
name: Push Docker image to DockerHub
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
needs:
- build_docker
- test_docker
- build_and_test_wheels
steps:
- name: Download artifact containing Docker image
uses: actions/download-artifact@v4
with:
name: mv-extractor-docker-image
path: /tmp
- name: Login to DockerHub
uses: docker/#-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Load and push Docker image
run: |
docker load --input /tmp/image.tar
docker tag mv-extractor:local lubo1994/mv-extractor:dev
docker push lubo1994/mv-extractor:dev