Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix github action #104

Closed
dodgyrabbit opened this issue Mar 24, 2021 · 10 comments · Fixed by #105
Closed

Fix github action #104

dodgyrabbit opened this issue Mar 24, 2021 · 10 comments · Fixed by #105

Comments

@dodgyrabbit
Copy link
Collaborator

If anyone has experience to help here that would be appreciated.
Looks like the test requires there to be a display attached but the tests are running headless.
Any ideas how to work around this?

ImportError while loading conftest '/home/runner/work/streamdeck-ui/streamdeck-ui/tests/conftest.py'.
tests/conftest.py:3: in <module>
    from streamdeck_ui import api
streamdeck_ui/api.py:11: in <module>
    from pynput.keyboard import Controller, Key
../../../.cache/pypoetry/virtualenvs/streamdeck-ui-HnNvaQR4-py3.8/lib/python3.8/site-packages/pynput/__init__.py:40: in <module>
    from . import keyboard
../../../.cache/pypoetry/virtualenvs/streamdeck-ui-HnNvaQR4-py3.8/lib/python3.8/site-packages/pynput/keyboard/__init__.py:31: in <module>
    backend = backend(__name__)
../../../.cache/pypoetry/virtualenvs/streamdeck-ui-HnNvaQR4-py3.8/lib/python3.8/site-packages/pynput/_util/__init__.py:76: in backend
    raise ImportError('this platform is not supported: {}'.format(
E   ImportError: this platform is not supported: ('failed to acquire X connection: Bad display name ""', DisplayNameError(''))
E
E   Try one of the following resolutions:
E
E    * Please make sure that you have an X server running, and that the DISPLAY environment variable is set correctly
Error: Process completed with exit code 4.
@dodgyrabbit dodgyrabbit added the help wanted Extra attention is needed label Mar 24, 2021
@dodgyrabbit
Copy link
Collaborator Author

Looks like this may be a workaround:
moses-palmer/pynput#239 (comment)

Alternatively, one would need to Mock the Controller (or potentially avoid pynput).

@tylerjw
Copy link
Collaborator

tylerjw commented Mar 28, 2021

I found a workaround by using xvfb to have a virtual x11 display. Lmk if that's an ok solution to this. The action has some stuff in it for windows/macos but never tests on those platforms. I'm not sure if this project even works on those platforms? I don't think the xvfb thing will work on windows or macos but it does fix the github actions run.

Another thing, why are we also running on travis? Is travis used for more than running the same tests? Looking at the travis config (which is also currently broken) we can probably just drop travis.

@dodgyrabbit
Copy link
Collaborator Author

@tylerjw Would you (or anyone else) have a moment to review the github actions? I'm really not familiar with it and some time ago they all started failing. I think it's because the action is using an old pip version - with known vulnerabilities and failing. Any help would be appreciated.

@dodgyrabbit dodgyrabbit reopened this Feb 23, 2022
@OpenDataAlex
Copy link

@dodgyrabbit In looking at your latest run, it appears there's an issue with your lint.sh script - specifically with some dependencies/imports. The github action looks fine overall, as far as I can tell.

@dodgyrabbit
Copy link
Collaborator Author

Yea there are some lint items to fix - however - even with those fixed the issue that is left is the lint will fail while doing a security check. Somehow the container/image that is used for the test itself needs to be updated since it's using an old version of pip.

@OpenDataAlex
Copy link

OpenDataAlex commented Mar 17, 2022

You can upgrade pip with something akin to:

   - name: Update pip
      run: |
        python -m pip install --upgrade pip

@dodgyrabbit
Copy link
Collaborator Author

That's what I tried a while ago
7aa28ff

@OpenDataAlex
Copy link

OpenDataAlex commented Mar 17, 2022 via email

@OpenDataAlex
Copy link

OpenDataAlex commented Mar 17, 2022 via email

@dodgyrabbit dodgyrabbit removed the help wanted Extra attention is needed label May 10, 2022
@dodgyrabbit
Copy link
Collaborator Author

The root cause here was a little tricky so writing here for posterity sake.

I knew the problem was during the lint.sh stage the safety step detects an old version of pip.

Here is what I did to find root cause:

  1. Install the latest pip in a step 2e410df
    Output said "dependency was already met". Scratch head.

  2. Output the version in a step 859463d
    Output confirmed we're already on latest
    This was puzzling, why would safety fail? Conclusion: They must "see" different versions, but why?

  3. This thread made me realize the poetry installs pip into its own venv and therefore ignores the global version installed in Ubuntu. Solution, check poetry install version.

  4. Don't hard code the version of poetry in cd0b061
    Latest version has a safe version of pip. Small downside is if a new version of poetry breaks things, it could in future break the pipeline but probably better to stay current.

  5. Fix the remaining tests in e8cc045

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants