ytdl-sub/.github/workflows/ci.yaml
2022-09-26 10:25:45 -07:00

153 lines
No EOL
3.3 KiB
YAML

name: ytld-sub CI
on:
pull_request:
branches:
- master
push:
branches:
- master
jobs:
test-build:
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: ["3.10"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
sudo apt-get install -y --download-only ffmpeg
python -m venv /opt/env
source /opt/env/bin/activate
pip install -e .[lint,test]
- name: Save Python build cache
uses: actions/cache@v3
with:
path: /opt/env
key: ${{github.sha}}-env
- name: Save ffmpeg download cache
uses: actions/cache@v3
with:
path: /var/cache/apt/archives
key: ${{github.sha}}-ffmpeg
test-lint:
runs-on: ubuntu-22.04
needs: [
test-build
]
permissions:
contents: read
steps:
- uses: actions/checkout@v3
- name: Restore Python build cache
uses: actions/cache@v3
with:
path: /opt/env
key: ${{github.sha}}-env
- name: Run linters
run: |
source /opt/env/bin/activate
./tools/linter check
test-unit:
runs-on: ubuntu-22.04
needs: [
test-lint
]
permissions:
contents: read
steps:
- uses: actions/checkout@v3
- name: Restore Python build cache
uses: actions/cache@v3
with:
path: /opt/env
key: ${{github.sha}}-env
- name: Run unit tests with coverage
run: |
source /opt/env/bin/activate
coverage run -m pytest tests/unit && coverage xml -o coverage-unit.xml
test-soundcloud:
runs-on: ubuntu-22.04
needs: [
test-lint
]
permissions:
contents: read
steps:
- name: Restore Python build cache
uses: actions/cache@v3
with:
path: /opt/env
key: ${{github.sha}}-env
- name: Restore ffmpeg cache
uses: actions/cache@v3
with:
path: /var/cache/apt/archives
key: ${{github.sha}}-ffmpeg
- name: Run e2e soundcloud tests with coverage
run: |
sudo apt-get install -y ffmpeg
source /opt/env/bin/activate
coverage run -m pytest tests/e2e/soundcloud && coverage xml -o coverage-soundcloud.xml
test-youtube:
runs-on: ubuntu-22.04
needs: [
test-lint
]
permissions:
contents: read
steps:
- name: Run e2e youtube tests with coverage
run: |
coverage run -m pytest tests/e2e/youtube && coverage xml -o coverage-youtube.xml
test-plugins:
runs-on: ubuntu-22.04
needs: [
test-lint
]
permissions:
contents: read
steps:
- name: Run e2e plugin tests with coverage
run: |
coverage run -m pytest tests/e2e/plugins && coverage xml -o coverage-plugins.xml
codecov-upload:
runs-on: ubuntu-22.04
needs: [
test-unit,
test-soundcloud,
test-youtube,
test-plugins
]
permissions:
contents: read
steps:
- name: Upload code coverage to codecov.io
uses: codecov/codecov-action@v3
with:
files: ./coverage-unit.xml,./coverage-soundcloud.xml,./coverage-youtube.xml,./coverage-plugins.xml