Repository navigation
152 lines (136 loc) · 5.6 KB
/
Copy pathbuild.yml
File metadata and controls
152 lines (136 loc) · 5.6 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
# Build Python Source/Wheel Distributions of DVR-Scan
name: Python Distribution
on:
schedule:
- cron: '0 0 * * *'
pull_request:
paths:
- dist/**
- dvr_scan/**
- tests/**
- pyproject.toml
- setup.py
- requirements*.txt
- uv.lock
- .github/workflows/build.yml
- .github/actions/setup-ffmpeg/**
push:
paths:
- dist/**
- dvr_scan/**
- tests/**
- pyproject.toml
- setup.py
- requirements*.txt
- uv.lock
- .github/workflows/build.yml
- .github/actions/setup-ffmpeg/**
branches:
- main
- release
- 'releases/**'
tags:
- v*-release
workflow_dispatch:
# The workflow token is read-only. No job writes to the repository.
permissions:
contents: read
jobs:
build:
# Skip scheduled runs in forks: GitHub attributes cron runs to the upstream
# workflow author, who then gets emailed when a fork's nightly build fails.
if: github.repository_owner == 'Breakthrough' || github.event_name != 'schedule'
env:
# Set below after building the final package.
dvr_scan_version: ""
UV_SYSTEM_PYTHON: 1
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-15, macos-latest, ubuntu-22.04, ubuntu-latest, windows-latest]
python-version: ["3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v7.0.1
with:
persist-credentials: false
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v7.1.0
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install uv and set the python version
uses: astral-sh/setup-uv@v10.3.3
with:
version: "0.5.11"
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
uv pip install --upgrade build wheel virtualenv
# TODO: Figure out how to avoid installing the original OpenCV package.
uv pip install -e ".[dev]" -r docs/requirements.txt
# Use headless OpenCV variant on CI to reduce download size.
uv pip uninstall opencv-python opencv-contrib-python
uv pip install opencv-contrib-python-headless --only-binary :all:
# `$/` runs this repository's copy of the action at the commit of the workflow.
# The lockfile can then cover the actions that the local action uses. A `./`
# path runs the copy in the workspace, and the lockfile cannot cover that.
- name: Setup FFmpeg
uses: $/.github/actions/setup-ffmpeg
- name: Unit Test
run: |
python -m pytest tests
- name: Build Package
shell: bash
run: |
python dist/pre_release.py
python -m build
# Normalize to the PEP 440 form setuptools uses in sdist/wheel filenames (2.0-rc1 -> 2.0rc1,
# 2.1-dev0 -> 2.1.dev0). `packaging` is installed as a dependency of `build`.
echo "dvr_scan_version=`python -c \"import dvr_scan; from packaging.version import Version; print(Version(dvr_scan.__version__))\"`" >> "$GITHUB_ENV"
- name: Build Package (Headless)
shell: bash
run: |
python dist/build_headless.py
python -m build
git reset --hard HEAD
# *NOTE*: Both OpenCV packages share the same on-disk cv2 package, and the install order is
# not deterministic. Put the contrib modules back so the CNT smoke test passes.
# TODO(https://github.com/Breakthrough/PySceneDetect/issues/601): Coordinate a resolution
# for this issue.
- name: Smoke Test (Source)
run: |
uv pip install dist/dvr_scan-${{ env.dvr_scan_version }}.tar.gz
uv pip install --reinstall --no-deps opencv-contrib-python
python -m dvr_scan --version
python -m dvr_scan -i tests/resources/simple_movement.mp4 -so -df 4 -et 100
python -m dvr_scan -i tests/resources/simple_movement.mp4 -so -df 4 -et 100 -b CNT
uv pip uninstall dvr-scan
uv pip install dist/dvr_scan_headless-${{ env.dvr_scan_version }}.tar.gz
uv pip install --reinstall --no-deps opencv-contrib-python-headless
python -m dvr_scan --version
python -m dvr_scan -i tests/resources/simple_movement.mp4 -so -df 4 -et 100
python -m dvr_scan -i tests/resources/simple_movement.mp4 -so -df 4 -et 100 -b CNT
uv pip uninstall dvr-scan-headless
- name: Smoke Test (Wheel)
run: |
uv pip install dist/dvr_scan-${{ env.dvr_scan_version }}-py3-none-any.whl
uv pip install --reinstall --no-deps opencv-contrib-python
python -m dvr_scan --version
python -m dvr_scan -i tests/resources/simple_movement.mp4 -so -df 4 -et 100
python -m dvr_scan -i tests/resources/simple_movement.mp4 -so -df 4 -et 100 -b CNT
uv pip uninstall dvr-scan
uv pip install dist/dvr_scan_headless-${{ env.dvr_scan_version }}-py3-none-any.whl
uv pip install --reinstall --no-deps opencv-contrib-python-headless
python -m dvr_scan --version
python -m dvr_scan -i tests/resources/simple_movement.mp4 -so -df 4 -et 100
python -m dvr_scan -i tests/resources/simple_movement.mp4 -so -df 4 -et 100 -b CNT
uv pip uninstall dvr-scan-headless
- name: Upload Package
if: ${{ matrix.python-version == '3.13' && matrix.os == 'ubuntu-latest' }}
uses: actions/upload-artifact@v7.0.2
with:
name: dvr-scan-dist
path: |
dist/*.tar.gz
dist/*.whl