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

The new GitHub action does not work? #643

Closed
lewoudar opened this issue Aug 9, 2022 · 7 comments · Fixed by #662
Closed

The new GitHub action does not work? #643

lewoudar opened this issue Aug 9, 2022 · 7 comments · Fixed by #662
Labels

Comments

@lewoudar
Copy link
Contributor

lewoudar commented Aug 9, 2022

Current Behavior

I'm trying the new GitHub action in a dummy project and I ended up with this ci file

name: CI

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  build:
    timeout-minutes: 20
    runs-on: ${{ matrix.os }}
    strategy:
      max-parallel: 6
      matrix:
        os: [ 'ubuntu-latest', 'macos-latest' ]
        python: [ pypy-3.7, pypy-3.8, 3.7, 3.8, 3.9, '3.10' ]
    steps:
      - uses: actions/checkout@v2
      - name: Set up Python ${{ matrix.python }}
        uses: actions/setup-python@v2
        with:
          python-version: ${{ matrix.python }}
      # here's where things go wrong
      - name: Set up nox
        uses: wntrblm/nox
        with:
          python-versions: ${{ matrix.python }}
      - name: Set up poetry
        uses: abatilo/actions-poetry@v2.1.3
      - name: Lint
        run: nox -s lint
      - name: Security checks
        run: nox -t security
      - name: Tests
        run: nox -s tests

When GitHub action is launched, I immediately receive this message:

[Error: .github#L1](https://github.com/lewoudar/noxtest/commit/5882afe8c4c57f35b4c6e2cb5249d5bffff34c2d#annotation_4253444940)
the `uses' attribute must be a path, a Docker image, or owner/repo@ref

Expected Behavior

The GitHub action should run without error.

Steps To Reproduce

Use a GitHub action file like the previous one I put.

Environment

- OS: Ubuntu's latest version
- Python: 3.7 - 3.10
- Nox: 2022.8.7

Anything else?

No response

@lewoudar lewoudar added the bug label Aug 9, 2022
@FollowTheProcess
Copy link
Collaborator

FollowTheProcess commented Aug 9, 2022

Hmm, looks like it's saying you need e.g wntrblm/nox@latest. Maybe we missed this in the docs, can you try that (or @master) and see where you get to.

If this syntax works how I think it does you should be able to do e.g wntrblm/nox@2022.7.1 etc

@lewoudar
Copy link
Contributor Author

Thanks for the suggestion @FollowTheProcess it seems better but I have another issue, I don't know how nox configures python, in my configuration file above, I explicitly setup nox python to the one configured in the matrix but I have this:
nox

Two versions of python are configured and therefore it creates issues when installing dependencies

Run nox -t security
nox > Running session bandit
nox > Creating virtual environment (virtualenv) using python in .nox/bandit
nox > poetry install
nox > Warning: poetry is not installed into the virtualenv, it is located at /opt/hostedtoolcache/Python/3.10.6/x64/bin/poetry. This might cause issues! Pass external=True into run() to silence this message.
Installing dependencies from lock file

Package operations: 49 installs, 0 updates, 0 removals

  • Installing idna (3.3)
  • Installing sniffio (1.2.0)

  AttributeError

  'Link' object has no attribute 'is_absolute'

  at /opt/hostedtoolcache/Python/3.10.6/x64/lib/python3.10/site-packages/poetry/core/packages/file_dependency.py:33 in __init__
       29│         self._path = path
       30│         self._base = base or Path.cwd()
       31│         self._full_path = path
       32│ 
    →  33│         if not self._path.is_absolute():
       34│             try:
       35│                 self._full_path = self._base.joinpath(self._path).resolve()
       36│             except FileNotFoundError:
       37│                 raise ValueError("Directory {} does not exist".format(self._path))


  AttributeError

  'Link' object has no attribute 'is_absolute'

  at /opt/hostedtoolcache/Python/3.10.6/x64/lib/python3.10/site-packages/poetry/core/packages/file_dependency.py:33 in __init__
       [29](https://github.com/lewoudar/noxtest/runs/7753186725?check_suite_focus=true#step:7:30)│         self._path = path
       30│         self._base = base or Path.cwd()
       31│         self._full_path = path
       32│ 
    →  33│         if not self._path.is_absolute():
       34│             try:
       35│                 self._full_path = self._base.joinpath(self._path).resolve()
       36│             except FileNotFoundError:
       [37](https://github.com/lewoudar/noxtest/runs/7753186725?check_suite_focus=true#step:7:38)│                 raise ValueError("Directory {} does not exist".format(self._path))

Anyway, the documentation should have a basic template to help us understand how it works ^^

@FollowTheProcess
Copy link
Collaborator

Hmm, I know that the Nox action sets up it's own pythons internally which may be why this is happening. What happens if you remove the setup-python step and just use the Nox action to setup the python matrix as described here https://nox.thea.codes/en/stable/tutorial.html?highlight=action#installation

@lewoudar
Copy link
Contributor Author

I end up with something like this (thanks for the suggestion):

...
jobs:
  build:
    timeout-minutes: 20
    runs-on: ${{ matrix.os }}
    strategy:
      max-parallel: 6
      matrix:
        os: [ 'ubuntu-latest', 'macos-latest' ]
        # python: [ pypy-3.7, pypy-3.8, 3.7, 3.8, 3.9, '3.10' ]
    steps:
      - uses: actions/checkout@v2
#      - name: Set up Python ${{ matrix.python }}
#        uses: actions/setup-python@v2
#        with:
#          python-version: ${{ matrix.python }}
      - name: Set up nox
        uses: wntrblm/nox@2022.8.7
#        with:
#          python-versions: ${{ matrix.python }}

It works now but man, I don't understand what is going on. I see that multiple python versions are configured, but how do I use them?

nox_2

Also I just realize that this action does not fit my general workflow since I install nox and run tests locally before doing it on GitHub.

@airtower-luna
Copy link
Contributor

I see that multiple python versions are configured, but how do I use them?

I just set that up for one of my workflows: The action only makes the Python versions and Nox available, you still have to tell Nox to use the ones you want. E.g. in noxfile.py to run tests with Python 3.9 and 3.10:

@nox.session(python=['3.9', '3.10'])
def test(session):
    # your test commands here

@lewoudar
Copy link
Contributor Author

@airtower-luna thanks for the clarification. This confirms that the documentation needs to be updated.

@henryiii
Copy link
Collaborator

henryiii commented Sep 7, 2022

This is a general problem when mixing pipx and nox, not just related to the action. If you run

- uses: actions/setup-python@v4
  with:
    python-version: 3.11-dev
- run: pipx run --python python nox

you'll get the active version of Python when running nox, but nox for some reason doesn't try to use the Python that ran it (via sys.executuable I'd expect) but instead gets the default Python for the OS instead (Something like 3.8-3.10, depending on the runner image you are using) (this is the one pipx itself is using).

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

Successfully merging a pull request may close this issue.

4 participants