Skip to content

Commit 93c4de9

Browse files
trin94jaseg
authored andcommitted
test: simplify pipeline
1 parent b26b72e commit 93c4de9

File tree

4 files changed

+16
-77
lines changed

4 files changed

+16
-77
lines changed

.github/workflows/tests.yml

Lines changed: 10 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -14,93 +14,30 @@ defaults:
1414

1515

1616
jobs:
17-
test-linux:
17+
test:
1818
runs-on: ubuntu-latest
1919
name: 'Linux - Python'
2020
strategy:
2121
matrix:
22-
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]
22+
python-version: [ '3.13' ]
2323
fail-fast: false
2424
env:
25-
DISPLAY: :0
2625
PY_MPV_SKIP_TESTS: >-
2726
test_wait_for_property_event_overflow
27+
PY_MPV_TEST_VO: 'null'
2828
steps:
2929
- uses: actions/checkout@v4
3030
- name: 'Install Python'
3131
uses: actions/setup-python@v5
3232
with:
3333
python-version: ${{ matrix.python-version }}
34-
- name: 'Update Packages'
35-
run: |
36-
function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }
37-
38-
execute sudo apt update -y
39-
execute sudo apt upgrade -y
40-
- name: 'Install Dependencies'
41-
run: |
42-
function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }
43-
44-
execute sudo apt install -y libmpv1 xvfb
45-
- name: 'Start Xvfb'
46-
run: |
47-
echo -e "\033[0;34msudo /usr/bin/Xvfb $DISPLAY -screen 0 1920x1080x24 &\033[0m";
48-
sudo /usr/bin/Xvfb $DISPLAY -screen 0 1920x1080x24 &
49-
- name: 'Setup Test Environment'
50-
run: |
51-
function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }
52-
53-
execute python -m venv venv
54-
execute source venv/bin/activate
55-
execute python -m pip install --upgrade pip
56-
execute python -m pip install wheel
57-
execute python -m pip install -r tests/requirements.txt
58-
- name: 'Run Python Tests'
59-
run: |
60-
function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }
61-
62-
execute source venv/bin/activate
63-
execute xvfb-run python -m unittest
64-
65-
test-windows:
66-
runs-on: windows-latest
67-
name: 'Windows - Python'
68-
strategy:
69-
matrix:
70-
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]
71-
fail-fast: false
72-
steps:
73-
- uses: actions/checkout@v4
74-
- name: 'Install Python'
75-
uses: actions/setup-python@v5
34+
- name: Install uv
35+
uses: astral-sh/setup-uv@v5
7636
with:
77-
python-version: ${{ matrix.python-version }}
78-
- name: 'Provide libmpv'
79-
run: |
80-
function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }
81-
82-
ARTIFACT="mpv-dev-x86_64-v3-20240121-git-a39f9b6.7z"
83-
SHA1="0764a4b899a7ebb1476e5b491897c5e2eed8a07f"
84-
URL="https://sourceforge.net/projects/mpv-player-windows/files/libmpv/$ARTIFACT"
85-
86-
execute curl -L -O "$URL"
87-
echo -e "\033[0;34mecho -n $SHA1 $ARTIFACT > $ARTIFACT.sha1\033[0m"
88-
echo -n "$SHA1 $ARTIFACT" > "$ARTIFACT.sha1"
89-
execute sha1sum --check "$ARTIFACT.sha1"
90-
execute 7z x "$ARTIFACT"
91-
execute mv libmpv-2.dll tests
37+
enable-cache: false
38+
- name: 'Install Dependencies'
39+
run: sudo apt install -y libmpv2
9240
- name: 'Setup Test Environment'
93-
run: |
94-
function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }
95-
96-
execute python -m venv venv
97-
execute source venv/Scripts/activate
98-
execute python -m pip install --upgrade pip
99-
execute python -m pip install wheel
100-
execute python -m pip install -r tests/requirements.txt
41+
run: uv sync --extra test
10142
- name: 'Run Python Tests'
102-
run: |
103-
function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }
104-
105-
execute source venv/Scripts/activate
106-
execute python -m unittest
43+
run: uv run -m pytest --reruns 3 --reruns-delay 3

pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,8 @@ homepage = "https://github.com/jaseg/python-mpv"
3636

3737
[project.optional-dependencies]
3838
screenshot_raw = ["Pillow"]
39-
test = ['PyVirtualDisplay']
39+
test = [
40+
'PyVirtualDisplay',
41+
'pytest',
42+
'pytest-rerunfailures'
43+
]

tests/requirements.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/test_mpv.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
else:
3838
from pyvirtualdisplay import Display
39-
testvo='x11'
39+
testvo=os.environ.get('PY_MPV_TEST_VO', 'x11')
4040

4141

4242
TESTVID = os.path.join(os.path.dirname(__file__), 'test.webm')
@@ -990,4 +990,3 @@ def t(self, *args, **kw):
990990
m.slang = 'ru'
991991
m.terminate() # needed for synchronization of event thread
992992
handler.assert_has_calls([mock.call('slang', ['jp']), mock.call('slang', ['ru'])])
993-

0 commit comments

Comments
 (0)