# This workflow will install Python dependencies, run tests and lint with a variety of Python versions # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions name: CI on: push: branches: [ $default-branch, add_github_actions ] pull_request: branches: [ $default-branch ] env: DEFAULT_PYTHON: 3.7 jobs: lint-flake8: name: Check flake8 runs-on: ubuntu-latest steps: - name: Check out code from Github uses: actions/checkout@v2 - name: Set up Python ${{ env.DEFAULT_PYTHON }} uses: actions/setup-python@v2 with: python-version: ${{ env.DEFAULT_PYTHON }} - name: Cache dependencies uses: actions/cache@v2 with: path: ~/.cache/pip key: ${{ runner.os }}-${{ env.DEFAULT_PYTHON }}-pip-flake8 - name: Install dependencies run: | pip install -U pip pip install flake8 - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names flake8 plexapi --count --select=E9,F63,F7,F82 --show-source --statistics # The GitHub editor is 127 chars wide flake8 plexapi --count --max-complexity=12 --max-line-length=127 --statistics pytest: name: pytest ${{ matrix.python-version }} (${{ matrix.plex }}) needs: lint-flake8 runs-on: ubuntu-latest env: PLEXAPI_AUTH_SERVER_BASEURL: http://127.0.0.1:32400 PLEX_CONTAINER_TAG: latest strategy: fail-fast: false matrix: python-version: [3.6, 3.7, 3.8, 3.9] plex: ['unclaimed', 'claimed'] is-master: - ${{ github.ref == 'refs/heads/master' }} exclude: - is-master: false plex: claimed steps: - name: Check out code from Github uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - name: Cache dependencies uses: actions/cache@v2 with: path: ~/.cache/pip key: ${{ runner.os }}-${{ matrix.python-version }}-pip-${{ hashFiles('requirements_dev.txt') }} restore-keys: ${{ runner.os }}-${{ matrix.python-version }}-pip- - name: Install dependencies run: | pip install -U pip pip install -r requirements_dev.txt pip install -e . - name: Set Plex credentials if: matrix.plex == 'claimed' run: | echo "PLEXAPI_AUTH_MYPLEX_USERNAME=${{ secrets.PLEXAPI_AUTH_MYPLEX_USERNAME }}" >> $GITHUB_ENV echo "PLEXAPI_AUTH_MYPLEX_PASSWORD=${{ secrets.PLEXAPI_AUTH_MYPLEX_PASSWORD }}" >> $GITHUB_ENV - name: Bootstrap ${{ matrix.plex }} Plex server run: | python \ -u tools/plex-bootstraptest.py \ --destination plex \ --advertise-ip=127.0.0.1 \ --bootstrap-timeout 540 \ --docker-tag ${{ env.PLEX_CONTAINER_TAG }} \ --${{ matrix.plex }} - name: Main tests with ${{ matrix.plex }} server env: TEST_ACCOUNT_ONCE: ${{ matrix.plex == 'unclaimed' }} run: | pytest \ -rxXs \ --ignore=tests/test_sync.py \ --tb=native \ --verbose \ --cov=plexapi \ tests - name: Sync tests with ${{ matrix.plex }} server if: matrix.plex == 'claimed' env: PLEXAPI_HEADER_PROVIDES: 'controller,sync-target' PLEXAPI_HEADER_PLATFORM: iOS PLEXAPI_HEADER_PLATFORM_VERSION: 11.4.1 PLEXAPI_HEADER_DEVICE: iPhone run: | pytest \ -rxXs \ --tb=native \ --verbose \ --cov=plexapi \ --cov-append \ tests/test_sync.py - name: Unlink PMS from MyPlex account if: matrix.plex == 'claimed' && always() run: python -u tools/plex-teardowntest.py - name: Upload coverage artifact uses: actions/upload-artifact@v2 with: name: coverage-${{ matrix.plex }}-${{ matrix.python-version }} path: .coverage coverage: name: Process test coverage runs-on: ubuntu-latest needs: pytest if: always() steps: - name: Check out code from GitHub uses: actions/checkout@v2 - name: Cache dependencies uses: actions/cache@v2 with: path: ~/.cache/pip key: ${{ runner.os }}-${{ env.DEFAULT_PYTHON }}-pip-coverage - name: Set up Python ${{ env.DEFAULT_PYTHON }} uses: actions/setup-python@v2 with: python-version: ${{ env.DEFAULT_PYTHON }} - name: Install dependencies run: | pip install -U pip pip install coverage - name: Download all coverage artifacts uses: actions/download-artifact@v2 - name: Combine coverage results run: | coverage combine coverage*/.coverage* coverage report --fail-under=50 coverage xml - name: Upload coverage to Codecov uses: codecov/codecov-action@v1