integration actions

This commit is contained in:
Jesse Bannon 2024-09-30 23:17:39 -07:00
parent 2417bec691
commit c7b28d9aac
19 changed files with 117 additions and 12 deletions

View file

@ -31,6 +31,53 @@ jobs:
python -m pip install -e .[test]
python -m pytest --reruns 3 --reruns-delay 5 tests/unit
test-integration:
runs-on: ubuntu-22.04
permissions:
contents: read
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Run integration tests with coverage
run: |
curl.exe -L -o ffmpeg.zip https://github.com/yt-dlp/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl.zip
tar -xf ffmpeg.zip
move "ffmpeg-master-latest-win64-gpl\bin\ffmpeg.exe" "ffmpeg.exe"
move "ffmpeg-master-latest-win64-gpl\bin\ffprobe.exe" "ffprobe.exe"
python -m pip install -e .[test]
python -m pytest --reruns 3 --reruns-delay 5 tests/integration --ignore tests/integration/prebuilt_presets
test-integration-prebuilt-presets:
runs-on: ubuntu-22.04
permissions:
contents: read
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Run prebuilt preset integration tests with coverage
run: |
curl.exe -L -o ffmpeg.zip https://github.com/yt-dlp/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl.zip
tar -xf ffmpeg.zip
move "ffmpeg-master-latest-win64-gpl\bin\ffmpeg.exe" "ffmpeg.exe"
move "ffmpeg-master-latest-win64-gpl\bin\ffprobe.exe" "ffprobe.exe"
python -m pip install -e .[test]
python -m pytest --reruns 3 --reruns-delay 5 tests/integration/prebuilt_presets
test-soundcloud:
runs-on: windows-latest
permissions:

View file

@ -52,6 +52,58 @@ jobs:
path: /opt/coverage/unit
key: ${{github.sha}}-coverage-unit
test-integration:
runs-on: ubuntu-22.04
permissions:
contents: read
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Run integration tests with coverage
run: |
pip install -e .[test]
sudo apt-get update
sudo apt-get install -y ffmpeg
coverage run -m pytest --reruns 3 --reruns-delay 5 tests/integration --ignore tests/integration/prebuilt_presets && coverage xml -o /opt/coverage/integration/coverage.xml
- name: Save coverage
uses: actions/cache@v3
with:
path: /opt/coverage/integration
key: ${{github.sha}}-coverage-integration
test-integration-prebuilt-presets:
runs-on: ubuntu-22.04
permissions:
contents: read
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Run prebuilt preset integration tests with coverage
run: |
pip install -e .[test]
sudo apt-get update
sudo apt-get install -y ffmpeg
coverage run -m pytest --reruns 3 --reruns-delay 5 tests/integration/prebuilt_presets && coverage xml -o /opt/coverage/integration-prebuilt-presets/coverage.xml
- name: Save coverage
uses: actions/cache@v3
with:
path: /opt/coverage/integration-prebuilt-presets
key: ${{github.sha}}-coverage-integration-prebuilt-presets
test-soundcloud:
runs-on: ubuntu-22.04
permissions:
@ -154,6 +206,8 @@ jobs:
runs-on: ubuntu-22.04
needs: [
test-unit,
test-integration,
test-integration-prebuilt-presets,
test-soundcloud,
test-bandcamp,
test-youtube,
@ -169,6 +223,18 @@ jobs:
path: /opt/coverage/unit
key: ${{github.sha}}-coverage-unit
- name: Restore integration test coverage
uses: actions/cache@v3
with:
path: /opt/coverage/unit
key: ${{github.sha}}-coverage-integration
- name: Restore integration prebuilt presets test coverage
uses: actions/cache@v3
with:
path: /opt/coverage/unit
key: ${{github.sha}}-coverage-integration-prebuilt-presets
- name: Restore soundcloud test coverage
uses: actions/cache@v3
with:

View file

@ -1,6 +1,5 @@
import pytest
from expected_transaction_log import assert_transaction_log_matches
from unit.conftest import mock_download_collection_entries
from ytdl_sub.subscriptions.subscription import Subscription

View file

@ -9,28 +9,21 @@ from ytdl_sub.utils.file_lock import working_directory_lock
from ytdl_sub.utils.system import IS_WINDOWS
@pytest.fixture
def config() -> ConfigFile:
return ConfigFile(
name="config", value={"configuration": {"working_directory": "test"}, "presets": {}}
)
def test_working_directory_lock(config: ConfigFile):
def test_working_directory_lock(default_config: ConfigFile):
if IS_WINDOWS:
return
new_pid = os.fork()
if new_pid == 0: # is child
with working_directory_lock(config=config):
with working_directory_lock(config=default_config):
time.sleep(3)
return
time.sleep(1)
with pytest.raises(ValidationException, match="Cannot run two instances of ytdl-sub"):
with working_directory_lock(config=config):
with working_directory_lock(config=default_config):
time.sleep(1)
time.sleep(3)
with working_directory_lock(config=config):
with working_directory_lock(config=default_config):
pass