-
-
Notifications
You must be signed in to change notification settings - Fork 155
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
Provide a handy CLI function and/or method on Func objects, to list all session names for a given Func
, for easier Github Actions integration
#407
Comments
I may me missing something but could you not just do something similar to nox's own # noxfile.py
@nox.session(python=ALL_SUPPORTED_VERSIONS_HERE)
def test(session: nox.Session) -> None:
"""
Runs all the tests for all python versions.
"""
<some_good_stuff>
... # CI.yml
name: CI
on: [push, pull_request]
jobs:
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.8", "3.9", "3.10.0-rc.2"]
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
python3 -m pip install --upgrade pip setuptools wheel
python3 -m pip install nox
- name: Run Tests and Coverage
run: nox --non-interactive --session "test-${{ matrix.python-version }}"
Here we've not had to specify explicit nox session, albeit we have had to specify supported python versions in both places, but there's an open issue suggesting parsing of |
@FollowTheProcess : sure we can do as you suggest, but it only works for a single session, non-parametrized, and you have to put all versions in the yaml. My point is more general-purpose: consider a random project with a random number of sessions, possibly with various python versions and/or parameters. Plus, consider that only some sessions are relevant for gh actions. See for example this project: https://github.com/smarie/python-pytest-cases/actions |
Ahh yeah I get it now! I was imagining a simpler case. I'm on board with this idea 👍🏻 |
I might have implemented something that could be easily added to nox and solve this issue before running into it. Usage : $ python commands/list_nox_manifest.py --sessions tests
> ["tests(python='3.7', streamlit_version='~=0.66', tqdm_version='~=4.50')", "tests(python='3.8', streamlit_version='~=0.66', tqdm_version='~=4.50')"]
$ python commands/list_nox_manifest.py --return-base-sessions
> ["isort", "lint", "coverage", "tests", "black"]
$ python commands/list_nox_manifest.py --list-python-versions
> ["3.10", "3.7", "3.8", "3.9"] EDIT : seems related to #658 |
Should be addressed by json output, I think! |
Let's consider the following prototypical noxfile.py :
When integrating such a nox-based project into github actions, the basic way to do it is to list the sessions:
It would be handy to not have to redefine the list of test sessions in the github actions build matrix.
I found a way to solve this issue, and have the GHA build workflow dynamically create a build matrix from nox sessions : see this post.
However it would be even better to not have to create a dedicated session for this. In other words if
> nox --list <base_session_name>
was a valid CLI command, the example demonstrated in the above stackoverflow post would be simplified greatly.
As a companion, I think that providing a method on the
Func
object to list all generated session names could also be handy.Note that all of this may need to evolve slightly when #404 is merged
The text was updated successfully, but these errors were encountered: