wntrblm / nox

Flexible test automation for Python
https://nox.thea.codes
Apache License 2.0
1.3k stars 148 forks source link

Lookup github action values from nox #800

Open chadrik opened 6 months ago

chadrik commented 6 months ago

Hi, thanks for this awesome project!

This PR establishes a single source of truth for python versions and tests matrix, driven by nox.

I had this idea for my own projects as I've often been frustrated with duplicated data between pre-commit, nox, and gitlab. I wanted to implement this in this project for a few reasons:

Changes

These are the differences in behavior from before:

Other thoughts

The most difficult part of this project was discovering the right incantations for jq to mutate the data from nox -l --json (though it is fairly readable once it's done). If this idea catches on, I foresee a need for a CLI tool (either part of nox or separate) which can reduce the complexity and boilerplate by preparing nox session data in ways that can be more easily consumed by Gitlab, Github, pre-commit, etc.

cjolowicz commented 6 months ago

Thank you for working on this! It's interesting to see how this feature works out for our CI.

In this particular case, I'm not sure how the benefit of single sourcing the build matrix stacks up against the costs in complexity and runtime overhead. I'm a bit worried about having all jobs block on that initial job computing the matrix, when they could otherwise start running in parallel right away.

cjolowicz commented 6 months ago

Would it make sense to pre-compute the build matrix in pre-commit?

chadrik commented 5 months ago

I'm a bit worried about having all jobs block on that initial job computing the matrix, when they could otherwise start running in parallel right away.

I understand the concern, but to be fair the job completes in 7s, so it's not a major delay.

Would it make sense to pre-compute the build matrix in pre-commit?

The easiest thing to do would be to add a pre-commit task that writes nox -l --json to a file that gets committed in the repo. It could obviously be setup to only run if noxfile.py changes. Would you prefer that approach?