name: Run tests

on: [push]

jobs:
  run-tests:
    runs-on: ubuntu-latest
    strategy:
        matrix:
            python-version: ['3.7', '3.8']

    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
      - uses: actions/setup-python@v2
        with:
          python-version: ${{ matrix.python-version }}
      - name: Install pdftotext
        run: sudo apt-get install poppler-utils
      - name: npm ci
        run: npm ci
      - name: Install poetry
        run: |
          curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
          $HOME/.poetry/bin/poetry config virtualenvs.in-project true
      - uses: actions/cache@v1
        with:
          id: cache-venv
          path: .venv
          key: poetry-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}
      - name: Install depencies
        run: $HOME/.poetry/bin/poetry install -E import-json
      - name: Test migrations
        # Ensure our migrations are working (squashing can cause weird problems)
        run: ENV_PATH=etc/test.env .venv/bin/python ./manage.py migrate
      - name: Build assets
        run: |
          npm run build:prod
          npm run build:dev
      - name: Run tests
        run: .venv/bin/pytest

name: Run tests

on: [push]

jobs:
  run-tests:
    runs-on: ubuntu-latest
    strategy:
        matrix:
            python-version: ['3.7', '3.8']

    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
      - uses: actions/setup-python@v2
        with:
          python-version: ${{ matrix.python-version }}
      - name: Install pdftotext
        run: sudo apt-get install poppler-utils
      - name: npm ci
        run: npm ci
      - name: Install poetry
        run: |
          curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
          $HOME/.poetry/bin/poetry config virtualenvs.in-project true
      - uses: actions/cache@v1
        with:
          id: cache-venv
          path: .venv
          key: poetry-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}
          restore-keys: |
              - poetry-${{ runner.os }}-${{ matrix.python-version }}
      - name: Install depencies
        run: $HOME/.poetry/bin/poetry install -E import-json
      - name: Test migrations
        # Ensure our migrations are working (squashing can cause weird problems)
        run: ENV_PATH=etc/test.env .venv/bin/python ./manage.py migrate
      - name: Build assets
        run: |
          npm run build:prod
          npm run build:dev
      - name: Run tests
        run: .venv/bin/pytest

Use restore to reuse old .venv
Use restore to reuse old .venv
