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

FEAT: json session listing #658

Closed
henryiii opened this issue Oct 7, 2022 · 1 comment · Fixed by #665
Closed

FEAT: json session listing #658

henryiii opened this issue Oct 7, 2022 · 1 comment · Fixed by #665

Comments

@henryiii
Copy link
Collaborator

henryiii commented Oct 7, 2022

How would this feature be useful?

GitHub actions (and maybe others) let you configure the jobs dynamically using JSON. This was used very effectively by cibuildwheel (see https://iscinumpy.dev/post/cibuildwheel-2-10-0/#only-210). I was thinking this might be really nice for nox, too. Then the session list would be the source of truth for the CI Python jobs.

Describe the solution you'd like

A new flag, like --json-sessions, could be added to augment the -l list sessions command. It doesn't have to be json, but that's likely the easiest to process if there were multiple items in the output (and you could include handy items like the help text, and add to it later without breaking usage). Something like this:

$ nox --json-sessions
{"name": "tests-3.7", "help": "Run test suite with pytest."}
{"name": "tests-3.8", "help": "Run test suite with pytest."}
...

It should be possible to combine --json-sessions with -s session selections, just like it is with -l today, which would make it easy to produce just the correct subset.

Describe alternatives you've considered

The current output could be parsed, but it's not very amenable to parsing, and more info (like the base session name & the python interpreter) would be nice to have. It doesn't have to be json, but it should be easily machine readable (which json is). And technically I used json lines above, though regular json is fine too - either is easy to run through jq. It also should be only the active values (or have a bool for selected on/off).

Anything else?

Here's with another option (python) added:

$ nox --json-sessions
{"name": "tests-3.7", "python": "3.7", "help": "Run test suite with pytest."}
{"name": "tests-3.8", "python": "3.7",  "help": "Run test suite with pytest."}
...
{"name": "lint", "python": "3.x",  "help": "Run pre-commit linting."}
...

Then you could easily have enough for python-version.

I've not carefully worked this through, but thought I'd put it down to see what people thought.

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

Successfully merging a pull request may close this issue.

2 participants