mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 08:39:17 +01:00
Configure integrated lyrics tests to only run on lyrics code changes
This commit is contained in:
parent
fc49902f3a
commit
35dcfe508a
4 changed files with 31 additions and 9 deletions
10
.github/workflows/ci.yaml
vendored
10
.github/workflows/ci.yaml
vendored
|
|
@ -35,6 +35,14 @@ jobs:
|
|||
sudo apt update
|
||||
sudo apt install ffmpeg gobject-introspection libcairo2-dev libgirepository1.0-dev pandoc
|
||||
|
||||
- name: Get changed lyrics files
|
||||
id: lyrics-update
|
||||
uses: tj-actions/changed-files@v45
|
||||
with:
|
||||
files: |
|
||||
beetsplug/lyrics.py
|
||||
test/plugins/test_lyrics.py
|
||||
|
||||
- name: Add pytest annotator
|
||||
uses: liskin/gh-problem-matcher-wrap@v3
|
||||
with:
|
||||
|
|
@ -49,6 +57,8 @@ jobs:
|
|||
|
||||
- if: ${{ env.IS_MAIN_PYTHON == 'true' }}
|
||||
name: Test with coverage
|
||||
env:
|
||||
LYRICS_UPDATED: ${{ steps.lyrics-update.outputs.any_changed }}
|
||||
run: |
|
||||
poetry install --extras=autobpm --extras=lyrics --extras=docs --extras=replaygain --extras=reflink
|
||||
poe docs
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ addopts =
|
|||
-ra
|
||||
--strict-config
|
||||
markers =
|
||||
on_lyrics_update: mark a test to run only after lyrics source code is updated
|
||||
integration_test: mark a test as an integration test
|
||||
|
||||
[coverage:run]
|
||||
|
|
|
|||
|
|
@ -3,10 +3,21 @@ import os
|
|||
import pytest
|
||||
|
||||
|
||||
def pytest_runtest_setup(item: pytest.Item):
|
||||
"""Skip integration tests if INTEGRATION_TEST environment variable is not set."""
|
||||
if os.environ.get("INTEGRATION_TEST"):
|
||||
return
|
||||
def skip_marked_items(items: list[pytest.Item], marker_name: str, reason: str):
|
||||
for item in (i for i in items if i.get_closest_marker(marker_name)):
|
||||
test_name = item.nodeid.split("::", 1)[-1]
|
||||
item.add_marker(pytest.mark.skip(f"{reason}: {test_name}"))
|
||||
|
||||
if next(item.iter_markers(name="integration_test"), None):
|
||||
pytest.skip(f"INTEGRATION_TEST=1 required: {item.nodeid}")
|
||||
|
||||
def pytest_collection_modifyitems(
|
||||
config: pytest.Config, items: list[pytest.Item]
|
||||
):
|
||||
if not os.environ.get("INTEGRATION_TEST") == "true":
|
||||
skip_marked_items(
|
||||
items, "integration_test", "INTEGRATION_TEST=1 required"
|
||||
)
|
||||
|
||||
if not os.environ.get("LYRICS_UPDATED") == "true":
|
||||
skip_marked_items(
|
||||
items, "on_lyrics_update", "No change in lyrics source code"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ class LyricsBackendTest(PluginMixin):
|
|||
encoding="utf-8"
|
||||
)
|
||||
|
||||
@pytest.mark.integration_test
|
||||
@pytest.mark.on_lyrics_update
|
||||
def test_backend_source(self, backend):
|
||||
"""Test default backends with a song known to exist in respective
|
||||
databases.
|
||||
|
|
@ -229,7 +229,7 @@ class TestGoogleLyrics(LyricsBackendTest):
|
|||
def file_name(self):
|
||||
return "examplecom/beetssong"
|
||||
|
||||
@pytest.mark.integration_test
|
||||
@pytest.mark.on_lyrics_update
|
||||
@pytest.mark.parametrize(
|
||||
"title, url",
|
||||
[
|
||||
|
|
@ -325,7 +325,7 @@ class TestGeniusLyrics(LyricsBackendTest):
|
|||
return "genius"
|
||||
|
||||
@xfail_on_ci("Genius returns 403 FORBIDDEN")
|
||||
@pytest.mark.integration_test
|
||||
@pytest.mark.on_lyrics_update
|
||||
def test_backend_source(self, backend):
|
||||
super().test_backend_source(backend)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue