Pin dependencies, create and cache venvs

This commit is contained in:
Jason Lawrence 2020-12-03 10:23:44 -06:00
parent 81f7f9a6fc
commit 9dd13c8872
2 changed files with 94 additions and 38 deletions

View file

@ -13,8 +13,44 @@ env:
DEFAULT_PYTHON: 3.7 DEFAULT_PYTHON: 3.7
jobs: jobs:
prepare-venv:
name: Prepare Python ${{ matrix.python-version }} virtual environment
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
steps:
- name: Check out code from GitHub
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
id: python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache@v2
with:
path: venv
key: ${{ env.CACHE_VERSION}}-${{ runner.os }}-venv-${{ steps.python.outputs.python-version }}-${{ hashFiles('requirements_dev.txt') }}
restore-keys: |
${{ env.CACHE_VERSION}}-${{ runner.os }}-venv-${{ steps.python.outputs.python-version }}-
- name: Create Python virtual environment
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
python -m venv venv
. venv/bin/activate
pip install -U pip
pip install -r requirements_dev.txt
pip install -e .
lint-flake8: lint-flake8:
name: Check flake8 name: Check flake8
needs: prepare-venv
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Check out code from Github - name: Check out code from Github
@ -25,16 +61,23 @@ jobs:
with: with:
python-version: ${{ env.DEFAULT_PYTHON }} python-version: ${{ env.DEFAULT_PYTHON }}
- name: Cache dependencies - name: Restore Python ${{ env.DEFAULT_PYTHON }} virtual environment
id: cache-venv
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: ~/.cache/pip path: venv
key: ${{ runner.os }}-${{ env.DEFAULT_PYTHON }}-pip-flake8 key: >-
${{ env.CACHE_VERSION}}-${{ runner.os }}-venv-${{
steps.python.outputs.python-version }}-${{
hashFiles('requirements_dev.txt') }}
restore-keys: |
${{ env.CACHE_VERSION}}-${{ runner.os }}-venv-${{ steps.python.outputs.python-version }}-
- name: Install dependencies - name: Fail job if Python cache restore failed
if: steps.cache-venv.outputs.cache-hit != 'true'
run: | run: |
pip install -U pip echo "Failed to restore Python virtual environment from cache"
pip install flake8 exit 1
- name: Lint with flake8 - name: Lint with flake8
run: | run: |
@ -67,22 +110,28 @@ jobs:
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }} - name: Set up Python ${{ matrix.python-version }}
id: python
uses: actions/setup-python@v2 uses: actions/setup-python@v2
with: with:
python-version: ${{ matrix.python-version }} python-version: ${{ matrix.python-version }}
- name: Cache dependencies - name: Restore Python ${{ env.DEFAULT_PYTHON }} virtual environment
id: cache-venv
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: ~/.cache/pip path: venv
key: ${{ runner.os }}-${{ matrix.python-version }}-pip-${{ hashFiles('requirements_dev.txt') }} key: >-
restore-keys: ${{ runner.os }}-${{ matrix.python-version }}-pip- ${{ env.CACHE_VERSION}}-${{ runner.os }}-venv-${{
steps.python.outputs.python-version }}-${{
hashFiles('requirements_dev.txt') }}
restore-keys: |
${{ env.CACHE_VERSION}}-${{ runner.os }}-venv-${{ steps.python.outputs.python-version }}-
- name: Install dependencies - name: Fail job if Python cache restore failed
if: steps.cache-venv.outputs.cache-hit != 'true'
run: | run: |
pip install -U pip echo "Failed to restore Python virtual environment from cache"
pip install -r requirements_dev.txt exit 1
pip install -e .
- name: Get PMS Docker image digest - name: Get PMS Docker image digest
id: docker-digest id: docker-digest
@ -186,21 +235,29 @@ jobs:
- name: Check out code from GitHub - name: Check out code from GitHub
uses: actions/checkout@v2 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 }} - name: Set up Python ${{ env.DEFAULT_PYTHON }}
id: python
uses: actions/setup-python@v2 uses: actions/setup-python@v2
with: with:
python-version: ${{ env.DEFAULT_PYTHON }} python-version: ${{ env.DEFAULT_PYTHON }}
- name: Install dependencies - name: Restore Python ${{ env.DEFAULT_PYTHON }} virtual environment
id: cache-venv
uses: actions/cache@v2
with:
path: venv
key: >-
${{ env.CACHE_VERSION}}-${{ runner.os }}-venv-${{
steps.python.outputs.python-version }}-${{
hashFiles('requirements_dev.txt') }}
restore-keys: |
${{ env.CACHE_VERSION}}-${{ runner.os }}-venv-${{ steps.python.outputs.python-version }}-
- name: Fail job if Python cache restore failed
if: steps.cache-venv.outputs.cache-hit != 'true'
run: | run: |
pip install -U pip echo "Failed to restore Python virtual environment from cache"
pip install coverage exit 1
- name: Download all coverage artifacts - name: Download all coverage artifacts
uses: actions/download-artifact@v2 uses: actions/download-artifact@v2

View file

@ -2,19 +2,18 @@
# PlexAPI requirements to run py.test. # PlexAPI requirements to run py.test.
# pip install -r requirements_dev.txt # pip install -r requirements_dev.txt
#--------------------------------------------------------- #---------------------------------------------------------
coveralls coveralls==2.2.0
flake8 flake8==3.8.4
pillow pillow==8.0.1
pytest pytest==6.1.2
pytest-cache pytest-cache==1.0
pytest-cov pytest-cov==2.10.1
pytest-mock<=1.11.1 pytest-mock<=1.11.1
recommonmark recommonmark==0.6.0
requests requests==2.25.0
requests-mock requests-mock==1.8.0
sphinx sphinx==3.3.1
sphinxcontrib-napoleon sphinxcontrib-napoleon==0.7
sphinx-rtd-theme sphinx-rtd-theme==0.5.0
tqdm tqdm==4.54.0
websocket-client websocket-client==0.57.0
mock; python_version < '3.3'