cclauss / GitHub-Action-for-pytest

A GitHub Action to run a pytest command when new code is pushed into your repo
Apache License 2.0
55 stars 24 forks source link

RequiredDependencyException #5

Closed AdrienLemaire closed 2 years ago

AdrienLemaire commented 2 years ago

I understand that we need to pip install requirements within the args parameter of the pytest step in order to get pytest working, but one of the dependencies is missing zlib headers when github builds the docker image.

During handling of the above exception, another exception occurred:
      Traceback (most recent call last):
        File "<string>", line 36, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-g4vqi3gl/pillow_5ea33d906ea64565911165286d4b5451/setup.py", line 1015, in <module>
          raise RequiredDependencyException(msg)
      __main__.RequiredDependencyException:
      The headers or library files could not be found for zlib,
      a required dependency when compiling Pillow from source.
      Please see the install instructions at:
        [ https://pillow.readthedocs.io/en/latest/installa](https://pillow.readthedocs.io/en/latest/installation.html)
      [end of output]
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
× Encountered error while trying to install package.
╰─> Pillow

my conf

---
name: Pytest Check

on:
  pull_request:
    paths:
      - 'backend/**/*.py'
    types: ['opened', 'synchronize', 'reopened', 'ready_for_review']

jobs:
  pytest:
    if: github.event.pull_request.draft == false
    runs-on: ubuntu-latest
    steps:
    - name: Checkout Code
      uses: actions/checkout@v3
    -  name: GitHub Action for pytest
       uses: cclauss/GitHub-Action-for-pytest@0.5.0
       with:
         args: |
           pip install -r backend/requirements.txt &&
           pip install -r backend/requirements-dev.txt &&
           pytest -c backend/pyproject.toml backend

What do you recommend to circumvent this issue ?

cclauss commented 2 years ago

- run: sudo apt update && sudo apt-get install zlib

AdrienLemaire commented 2 years ago

Got:

E: Unable to locate package zlib
Error: Process completed with exit code 100.

Installing zlib1g returns the same error as previously posted, as expected

      The headers or library files could not be found for zlib,
      a required dependency when compiling Pillow from source.

Why would installing zlib on the github host make it available within the step's docker container ? We need the Dockerfile to run this install, and I was wondering if you could accommodate the options to allow for extra packages to be installed within the container, since not all users will want to have zib or other library to be installed for a pytest check.

cclauss commented 2 years ago

You don't really need the GitHub Action anymore. You can just use...

    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v4
        with:
          python-version: 3.x
      - run: pip install pytest
      - run: pytest --doctest-modules . || pytest .
AdrienLemaire commented 2 years ago

Fair enough :) Thanks for the quick replies.