ansys / actions

A collection of reusable workflows
https://actions.docs.ansys.com/
MIT License
10 stars 5 forks source link

tests-pytest and doc-build actions fail for pyansys-advanced with poetry template #348

Closed mkundu1 closed 5 months ago

mkundu1 commented 10 months ago

https://github.com/ansys/pyfluent-reader/actions/runs/6469381862/job/17563451958#step:2:451

/home/runner/work/_temp/98be34b6-060e-4d3a-9fac-879cfefcd336.sh: line 1: pytest: command not found

https://github.com/ansys/pyfluent-reader/actions/runs/6469381862/job/17563344927#step:2:1063

/bin/sh: 1: sphinx-build: not found
philipjusher commented 5 months ago

Hi. I was looking at this recently and had issues pytest: command not found. And it seemed to be because poetry is running in default mode and creating a virtualenv which is not activated in the github actions. I created an environment variable to configure poetry not to do this in the CI/CD so poetry should be found. POETRY_VIRTUALENVS_CREATE = false

RobPasMue commented 5 months ago

Hi @philipjusher thanks for commenting and using our actions! Could you share a Code snippet of the changes you performed so that we understand your issues and solution? Really appreciated! A URL also works =)

philipjusher commented 5 months ago

Here is the snippet from the github action that calls tests-pytest I think it what you need. So you set the POETRY_VIRTUALENVS_CREATE to false either as repo variable or you could write in your pipeline.

   steps:
      - uses: ansys/actions/tests-pytest@v5
        env:
          POETRY_VIRTUALENVS_CREATE: ${{ vars.POETRY_VIRTUALENVS_CREATE }} # false
        with:
          pytest-extra-args: "--cov=ansys --cov-report=term --cov-report=html:.cov/html"

This means that it doesnt create a virtual environment so you dont get the problem of pytest: command not found I'm think this also means you havent got a test for the poetry option of this action.

RobPasMue commented 5 months ago

Hi @philipjusher - the way we have it right now is that poetry (in case of tests) tries to install a group called tests. See https://github.com/ansys/actions/blob/main/tests-pytest/action.yml#L139

If you have pytest defined inside your group, this should solve your issues. You should also define your test dependencies inside it.

RobPasMue commented 5 months ago

Something like this for example:

image

philipjusher commented 5 months ago

I checked that first image However poetry creates in a python virtualenv and there is nothing that activates that before you run the pytest command on line 148. The solution I had was to make sure it didnt create the virtualenv and installed to the system python. Our code is here for now https://github.com/ansys-internal/pyconceptev-core

RobPasMue commented 5 months ago

Gotcha! Thanks for the explanation. I will add this right away directly inside the various poetry actions. Thanks a bunch!