name: Quick Test
on:
  push:
    branches: ['master']
  # This workflow contains required checks and needs to run for EVERY pull_request
  pull_request:
    branches: ['**']

permissions: {}

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

jobs:
  tests:
    # Required check; do not change name
    name: Core test
    if: ${{ !contains(github.event.head_commit.message, ':ci skip all') }}
    permissions:
      contents: read
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0  # v7.0.0
      with:
        persist-credentials: false
    - name: Set up Python 3.10
      uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1  # v6.3.0
      with:
        python-version: '3.10'
    - name: Install test requirements
      shell: bash
      run: |
        python -m pip install -U --require-hashes -r "bundle/requirements/pip.txt"
        python -m pip install -U --require-hashes -r "bundle/requirements/test.txt"
    - 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:
    # Required check; do not change name
    name: Code check
    if: ${{ !contains(github.event.head_commit.message, ':ci skip all') }}
    permissions:
      contents: read
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0  # v7.0.0
      with:
        persist-credentials: false
    - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1  # v6.3.0
      with:
        python-version: '3.14'
    - name: Install dev dependencies
      run: |
        python -m pip install -U --require-hashes -r "bundle/requirements/pip.txt"
        python -m pip install -U --require-hashes -r "bundle/requirements/static-analysis.txt"
    - 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" )
