Skip to content

Commit a3ae991

Browse files
committed
Setup uv-based testing
1 parent 821977b commit a3ae991

File tree

1 file changed

+192
-0
lines changed

1 file changed

+192
-0
lines changed
Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: OpenTimelineIO w/ uv
5+
6+
# for configuring which build will be a C++ coverage build / coverage report
7+
env:
8+
GH_COV_PY: "3.10"
9+
GH_COV_OS: ubuntu-latest
10+
GH_DEPENDABOT: dependabot
11+
12+
on:
13+
push:
14+
branches: [ main ]
15+
pull_request:
16+
branches: [ main ]
17+
18+
concurrency:
19+
group: ${{ github.workflow }}-${{ github.ref }}
20+
cancel-in-progress: true
21+
22+
jobs:
23+
cpp_build:
24+
runs-on: ${{ matrix.os }}
25+
strategy:
26+
matrix:
27+
os: [ubuntu-latest, macos-latest]
28+
# Unfortunately the CMake test target is OS dependent so we set it as
29+
# a variable here.
30+
include:
31+
- os: ubuntu-latest
32+
OTIO_TEST_TARGET: test
33+
- os: macos-latest
34+
OTIO_TEST_TARGET: test
35+
36+
env:
37+
OTIO_BUILD_CONFIG: Release
38+
OTIO_BUILD_DIR: ${{ github.workspace }}/build
39+
OTIO_INSTALL_DIR: ${{ github.workspace }}/install
40+
OTIO_CONSUMER_TEST_BUILD_DIR: ${{ github.workspace }}/consumertest
41+
42+
steps:
43+
- uses: actions/checkout@v4
44+
with:
45+
submodules: 'recursive'
46+
- name: Install coverage dependency
47+
if: matrix.os == env.GH_COV_OS && github.actor != env.GH_DEPENDABOT
48+
run: |
49+
sudo apt-get install lcov
50+
- name: Build
51+
run: |
52+
cmake -E make_directory ${{ env.OTIO_BUILD_DIR }}
53+
cd ${{ env.OTIO_BUILD_DIR }}
54+
cmake ${{ github.workspace }} -DCMAKE_INSTALL_PREFIX=${{ env.OTIO_INSTALL_DIR }} -DOTIO_SHARED_LIBS=OFF -DOTIO_CXX_COVERAGE=ON
55+
cmake --build . --config ${{ env.OTIO_BUILD_CONFIG }}
56+
- name: Run tests
57+
run: |
58+
cd ${{ env.OTIO_BUILD_DIR }}
59+
cmake --build . --target ${{ matrix.OTIO_TEST_TARGET }} --config ${{ env.OTIO_BUILD_CONFIG }}
60+
- name: Collect code coverage
61+
if: matrix.os == env.GH_COV_OS && github.actor != env.GH_DEPENDABOT
62+
run: |
63+
cd ${{ env.OTIO_BUILD_DIR }}
64+
lcov --rc lcov_branch_coverage=1 --rc no_exception_branch=1 --ignore-errors mismatch --capture -b . --directory . --output-file=coverage.info -q
65+
cat coverage.info | sed "s/SF:.*src/SF:src/g" > coverage.filtered.info
66+
lcov --remove coverage.filtered.info '*/tests/*' --output-file=coverage.filtered.info -q
67+
lcov --list coverage.filtered.info
68+
# TODO: Should the Codecov web pages show the results of the C++ or Python tests?
69+
- name: Upload coverage to Codecov
70+
if: matrix.os == env.GH_COV_OS && github.actor != env.GH_DEPENDABOT
71+
uses: codecov/[email protected]
72+
with:
73+
files: ${{ env.OTIO_BUILD_DIR }}/coverage.filtered.info
74+
flags: unittests
75+
name: opentimelineio-codecov
76+
fail_ci_if_error: true
77+
- name: Install
78+
run: |
79+
cd ${{ env.OTIO_BUILD_DIR }}
80+
cmake --build . --target install --config ${{ env.OTIO_BUILD_CONFIG }}
81+
- name: Consumer tests
82+
run: |
83+
cmake -E make_directory ${{ env.OTIO_CONSUMER_TEST_BUILD_DIR }}
84+
cd ${{ env.OTIO_CONSUMER_TEST_BUILD_DIR }}
85+
cmake ${{ github.workspace }}/tests/consumer -DCMAKE_PREFIX_PATH=${{ env.OTIO_INSTALL_DIR }}
86+
87+
py_build_test:
88+
runs-on: ${{ matrix.os }}
89+
strategy:
90+
matrix:
91+
os: [ubuntu-latest, macos-latest]
92+
# python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
93+
python-version: ['3.11', '3.12']
94+
# No include/exclude needed for this simplified matrix yet
95+
# No shell specification needed, uv handles environment activation
96+
97+
env:
98+
OTIO_CXX_COVERAGE_BUILD: ON
99+
OTIO_CXX_BUILD_TMP_DIR: ${{ github.workspace }}/build
100+
101+
steps:
102+
- uses: actions/checkout@v4
103+
with:
104+
submodules: 'recursive'
105+
106+
- name: Install uv
107+
uses: astral-sh/setup-uv@v3
108+
109+
- name: Set up Python ${{ matrix.python-version }}
110+
run: uv python install ${{ matrix.python-version }}
111+
112+
- name: Install C++ coverage dependency (Linux only)
113+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == env.GH_COV_PY && github.actor != env.GH_DEPENDABOT
114+
run: |
115+
echo 'OTIO_CXX_DEBUG_BUILD=1' >> $GITHUB_ENV
116+
sudo apt-get update && sudo apt-get install -y lcov
117+
118+
- name: Install project and development dependencies
119+
run: |
120+
uv sync --all-extras --dev
121+
122+
- name: Run check-manifest and lint check
123+
run: uv run make ci-prebuild
124+
125+
- name: Run tests w/ python coverage
126+
run: uv run make ci-postbuild
127+
128+
# (only on ubuntu/specific python version)
129+
- name: Generate C++ coverage report
130+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == env.GH_COV_PY && github.actor != env.GH_DEPENDABOT
131+
run: uv run make lcov
132+
133+
- name: Upload coverage to Codecov
134+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == env.GH_COV_PY && github.actor != env.GH_DEPENDABOT
135+
uses: codecov/codecov-action@v4
136+
with:
137+
flags: py-unittests
138+
name: py-opentimelineio-codecov
139+
fail_ci_if_error: false
140+
env:
141+
# based on: https://github.com/codecov/codecov-action?tab=readme-ov-file#usage
142+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
143+
144+
package_wheels:
145+
needs: py_build_test
146+
runs-on: ${{ matrix.os }}
147+
strategy:
148+
matrix:
149+
os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest]
150+
python-build: ['cp311', 'cp312']
151+
exclude:
152+
- { os: macos-latest, python-build: 'cp37' }
153+
steps:
154+
- uses: actions/checkout@v4
155+
156+
- name: Build wheels (Python 3)
157+
uses: pypa/[email protected]
158+
with:
159+
output-dir: wheelhouse
160+
env:
161+
CIBW_BUILD: ${{ matrix.python-build }}*
162+
CIBW_SKIP: '*musllinux*'
163+
CIBW_ARCHS_LINUX: native
164+
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
165+
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux2014
166+
MACOSX_DEPLOYMENT_TARGET: 10.14
167+
168+
- uses: actions/upload-artifact@v4
169+
with:
170+
name: wheel-${{ matrix.os }}-${{ matrix.python-build }}
171+
path: ./wheelhouse/*.whl
172+
173+
package_sdist:
174+
needs: py_build_test
175+
runs-on: ubuntu-latest
176+
steps:
177+
- uses: actions/checkout@v4
178+
with:
179+
submodules: 'recursive'
180+
181+
- uses: actions/[email protected]
182+
183+
- name: Install pypa/build
184+
run: python -m pip install build --user
185+
186+
- name: Generate sdist
187+
run: python -m build -s .
188+
189+
- uses: actions/upload-artifact@v4
190+
with:
191+
name: sdist
192+
path: dist

0 commit comments

Comments
 (0)