-
Notifications
You must be signed in to change notification settings - Fork 337
263 lines (244 loc) · 10.7 KB
/
Copy pathpython-package.yml
File metadata and controls
263 lines (244 loc) · 10.7 KB
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: OpenTimelineIO
# for configuring which build will be a C++ coverage build / coverage report
env:
GH_COV_PY: "3.10"
GH_COV_OS: ubuntu-latest
GH_DEPENDABOT: dependabot
on:
push:
branches: [main]
pull_request:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
cpp_build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
# Pinned to windows-2022 because the June 2026 migration of
# windows-latest to Windows Server 2025 + Visual Studio 2026 +
# CMake 4.3 breaks the vcpkg-based ZLIB find_package path.
# windows-2022 is supported by GitHub through ~2028.
os: [ubuntu-latest, windows-2022, macos-15]
# Unfortunately the CMake test target is OS dependent so we set it as
# a variable here.
include:
- os: ubuntu-latest
OTIO_TEST_TARGET: test
- os: windows-2022
OTIO_TEST_TARGET: RUN_TESTS
- os: macos-15
OTIO_TEST_TARGET: test
env:
OTIO_BUILD_CONFIG: Release
OTIO_BUILD_DIR: ${{ github.workspace }}/build
OTIO_INSTALL_DIR: ${{ github.workspace }}/install
OTIO_CONSUMER_TEST_BUILD_DIR: ${{ github.workspace }}/consumertest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
submodules: "recursive"
- name: Install coverage dependency
if: matrix.os == env.GH_COV_OS && github.actor != env.GH_DEPENDABOT
run: |
sudo apt-get install lcov
- name: Install ZLIB (Linux)
if: runner.os == 'Linux'
run: sudo apt-get install -y zlib1g-dev
- name: Install ZLIB (Windows)
if: runner.os == 'Windows'
run: |
vcpkg install zlib:x64-windows
echo "CMAKE_PREFIX_PATH=C:/vcpkg/installed/x64-windows" >> $env:GITHUB_ENV
echo "C:/vcpkg/installed/x64-windows/bin" >> $env:GITHUB_PATH
- name: Build
run: |
cmake -E make_directory ${{ env.OTIO_BUILD_DIR }}
cd ${{ env.OTIO_BUILD_DIR }}
cmake ${{ github.workspace }} -DCMAKE_INSTALL_PREFIX=${{ env.OTIO_INSTALL_DIR }} -DOTIO_SHARED_LIBS=OFF -DOTIO_CXX_COVERAGE=ON -DOTIO_CXX_EXAMPLES=ON
cmake --build . --config ${{ env.OTIO_BUILD_CONFIG }}
- name: Run tests
run: |
cd ${{ env.OTIO_BUILD_DIR }}
cmake --build . --target ${{ matrix.OTIO_TEST_TARGET }} --config ${{ env.OTIO_BUILD_CONFIG }}
- name: Collect code coverage
if: matrix.os == env.GH_COV_OS && github.actor != env.GH_DEPENDABOT
run: |
cd ${{ env.OTIO_BUILD_DIR }}
lcov --rc lcov_branch_coverage=1 --rc no_exception_branch=1 --ignore-errors mismatch --capture -b . --directory . --output-file=coverage.info -q
cat coverage.info | sed "s/SF:.*src/SF:src/g" > coverage.filtered.info
lcov --remove coverage.filtered.info '*/tests/*' --output-file=coverage.filtered.info -q
lcov --list coverage.filtered.info
# \todo Should the Codecov web pages show the results of the C++ or Python tests?
# - name: Upload coverage to Codecov
# if: matrix.os == env.GH_COV_OS && github.actor != env.GH_DEPENDABOT
# uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
# with:
# files: ${{ env.OTIO_BUILD_DIR }}/coverage.filtered.info
# flags: unittests
# name: opentimelineio-codecov
# fail_ci_if_error: true
- name: Install
run: |
cd ${{ env.OTIO_BUILD_DIR }}
cmake --build . --target install --config ${{ env.OTIO_BUILD_CONFIG }}
- name: Consumer tests
run: |
cmake -E make_directory ${{ env.OTIO_CONSUMER_TEST_BUILD_DIR }}
cd ${{ env.OTIO_CONSUMER_TEST_BUILD_DIR }}
cmake ${{ github.workspace }}/tests/consumer -DCMAKE_PREFIX_PATH=${{ env.OTIO_INSTALL_DIR }}
py_build_test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
# See note in cpp_build about pinning to windows-2022.
os: [ubuntu-latest, windows-2022, macos-15]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
include:
- { os: ubuntu-latest, shell: bash }
- { os: macos-15, shell: bash }
- { os: windows-2022, shell: pwsh }
- { os: windows-2022, shell: msys2, python-version: "mingw64" }
exclude:
- { os: macos-15, python-version: 3.9 }
defaults:
run:
shell: "${{ matrix.shell }} {0}"
env:
OTIO_CXX_COVERAGE_BUILD: ON
OTIO_CXX_BUILD_TMP_DIR: ${{ github.workspace }}/build
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
submodules: "recursive"
- name: Set up MSYS2
if: matrix.python-version == 'mingw64'
uses: msys2/setup-msys2@4f806de0a5a7294ffabaff804b38a9b435a73bda # v2
with:
msystem: mingw64
install: >-
mingw-w64-x86_64-python
mingw-w64-x86_64-python-pip
mingw-w64-x86_64-gcc
mingw-w64-x86_64-cmake
mingw-w64-x86_64-zlib
make
git
- name: Set up Python ${{ matrix.python-version }}
if: matrix.python-version != 'mingw64'
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: ${{ matrix.python-version }}
- name: Install coverage dependency
if: matrix.python-version == env.GH_COV_PY && matrix.os == env.GH_COV_OS && github.actor != env.GH_DEPENDABOT
run: |
echo 'OTIO_CXX_DEBUG_BUILD=1' >> $GITHUB_ENV
sudo apt-get install lcov
- name: Install ZLIB (Linux)
if: runner.os == 'Linux' && matrix.python-version != 'mingw64'
run: sudo apt-get install -y zlib1g-dev
- name: Install ZLIB (Windows)
if: runner.os == 'Windows' && matrix.python-version != 'mingw64'
run: |
vcpkg install zlib:x64-windows
echo "CMAKE_PREFIX_PATH=C:/vcpkg/installed/x64-windows" >> $env:GITHUB_ENV
echo "C:/vcpkg/installed/x64-windows/bin" >> $env:GITHUB_PATH
- name: Install python build dependencies
run: |
python -m pip install --upgrade pip setuptools wheel "flake8>=3.5" check-manifest
# \todo Temporarily disable check-manifest on MinGW, it is failing
# intermittently with this error:
# ModuleNotFoundError: No module named 'pip._vendor.distlib'
- name: Run check-manifest and lint check
if: matrix.python-version != 'mingw64'
run: make ci-prebuild
- name: Build and Install
run: |
pip install .[dev] -v --break-system-packages
# Python 3.8+ ignores PATH when resolving DLL dependencies of .pyd
# files, so zlib1.dll from vcpkg's bin is not findable at import
# time even though it is on PATH for the C++ tests. Copy it next
# to the installed _otio.pyd, which IS a directory Python's
# restricted DLL search checks.
# (In package_wheels, cibuildwheel does this via delvewheel.)
- name: Copy ZLIB DLL next to _otio.pyd (Windows)
if: runner.os == 'Windows' && matrix.python-version != 'mingw64'
run: |
$target = python -c "import sysconfig, os; print(os.path.join(sysconfig.get_paths()['purelib'], 'opentimelineio'))"
$sourceDir = "C:/vcpkg/installed/x64-windows/bin"
Write-Host "Target: $target"
Write-Host "Contents of ${sourceDir}:"
Get-ChildItem $sourceDir -ErrorAction SilentlyContinue | ForEach-Object { Write-Host " $($_.Name)" }
Copy-Item "$sourceDir/*.dll" "$target/" -ErrorAction Stop
Write-Host "DLLs now in ${target}:"
Get-ChildItem "$target/*.dll" | ForEach-Object { Write-Host " $($_.Name)" }
- name: Run tests w/ python coverage
run: make ci-postbuild
# (only on GH_COV_OS and GH_COV_PY)
- name: Generate C++ coverage report
if: matrix.python-version == env.GH_COV_PY && matrix.os == env.GH_COV_OS && github.actor != env.GH_DEPENDABOT
run: make lcov
- name: Upload coverage to Codecov
if: matrix.python-version == env.GH_COV_PY && matrix.os == env.GH_COV_OS && github.actor != env.GH_DEPENDABOT
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
with:
flags: py-unittests
name: py-opentimelineio-codecov
fail_ci_if_error: false
env:
# based on: https://github.com/codecov/codecov-action?tab=readme-ov-file#usage
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
package_wheels:
needs: py_build_test
runs-on: ${{ matrix.os }}
strategy:
matrix:
# See note in cpp_build about pinning to windows-2022.
os:
[
ubuntu-latest,
ubuntu-24.04-arm,
windows-2022,
macos-15,
]
python-build: ["cp39", "cp310", "cp311", "cp312", "cp313"]
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Build wheels (Python 3)
uses: pypa/cibuildwheel@9c00cb4f6b517705a3794b22395aedc36257242c # v3.2.1
with:
output-dir: wheelhouse
env:
CIBW_BUILD: ${{ matrix.python-build }}*
CIBW_SKIP: "*musllinux*"
CIBW_BEFORE_BUILD_LINUX: "yum install -y zlib-devel"
CIBW_BEFORE_BUILD_WINDOWS: "vcpkg install zlib:x64-windows"
CIBW_ENVIRONMENT_WINDOWS: 'CMAKE_PREFIX_PATH=C:/vcpkg/installed/x64-windows PATH="C:/vcpkg/installed/x64-windows/bin;$PATH"'
CIBW_ARCHS_LINUX: native
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux2014
MACOSX_DEPLOYMENT_TARGET: 10.15
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: wheel-${{ matrix.os }}-${{ matrix.python-build }}
path: ./wheelhouse/*.whl
package_sdist:
needs: py_build_test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
submodules: "recursive"
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
- name: Install pypa/build
run: python -m pip install build --user
- name: Generate sdist
run: python -m build -s .
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: sdist
path: dist