name: Quick Test
on: [push, pull_request]

permissions: {}

concurrency:
  group: quick-test-${{ github.event.pull_request.number || github.ref }}
  cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
  tests:
    name: Core Test
    if: ${{ !contains(github.event.head_commit.message, ':ci skip all') }}
    permissions:
      contents: read
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd  # v6.0.2
      with:
        persist-credentials: false
    - name: Set up Python 3.10
      uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405  # v6.2.0
      with:
        python-version: '3.10'
    - name: Install test requirements
      shell: bash
      run: python ./devscripts/install_deps.py --omit-default --include-extra test
    - name: Run tests
      timeout-minutes: 15
      shell: bash
      run: |
        python3 -m yt_dlp -v || true
        python3 ./devscripts/run_tests.py --pytest-args '--reruns 2 --reruns-delay 3.0' core
  check:
    name: Code check
    if: ${{ !contains(github.event.head_commit.message, ':ci skip all') }}
    permissions:
      contents: read
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd  # v6.0.2
      with:
        persist-credentials: false
    - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405  # v6.2.0
      with:
        python-version: '3.10'
    - name: Install dev dependencies
      run: python ./devscripts/install_deps.py --omit-default --include-extra static-analysis
    - name: Make lazy extractors
      run: python ./devscripts/make_lazy_extractors.py
    - name: Run ruff
      run: ruff check --output-format github .
    - name: Run autopep8
      run: autopep8 --diff .
    - name: Check file mode
      shell: bash
      run: git ls-files --format="%(objectmode) %(path)" yt_dlp/ | ( ! grep -v "^100644" )
