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

Using Nox inside our GitHub CI actions #40

Merged
merged 1 commit into from
Jan 10, 2023
Merged

Conversation

jherland
Copy link
Member

@jherland jherland commented Jan 5, 2023

(This PR depends on #23 and adds the following commit on top)

Rephrase GitHub Actions in terms of Nox actions

This reduces duplication of GitHub vs local/Nox CI actions by changing
the GitHub actions to call out to Nox.

That said, this is not a full-fledged embrace of the Nox way: Nox will
usually install dependencies in its own virtualenvs. However, these
would come in addition to Poetry's virtualenv, and we have not currently
set up caching for anything but the Poetry virtualenvs.

Work around this by setting up the appropriate Python version and
installing all the necessary dependencies in the Poetry virtualenv
(i.e. outside of Nox). We can then run Nox with --no-venv --no-install
to explicitly disable the Nox virtualenvs (which also disables the
Python version parametrization inside Nox).

For this to work, we also need to adjust our install_groups() helper in
noxfile.py to detect when it's running without Nox virtualenvs and skip
installation in this case.

In summary, this avoids an extra layer of virtualenvs and should also
retain the same useful caching of the Poetry virtualenvs, but at the
cost of running the Nox sessions in a slightly different way compared
to running Nox in your local development environment: We do Python
version parametrization and dependency installation the Github Actions +
Poetry way, and then only use Nox to abstract away the actual commands
run inside each CI action.

Time will tell if this creates too many issues to be worthwhile.

@jherland jherland changed the title Using Nox inside out GitHub CI actions Using Nox inside our GitHub CI actions Jan 5, 2023
@mknorps mknorps linked an issue Jan 5, 2023 that may be closed by this pull request
@jherland jherland force-pushed the jherland/nox-for-github-ci branch 4 times, most recently from 486d485 to 1bca1bd Compare January 5, 2023 14:06
@jherland
Copy link
Member Author

jherland commented Jan 5, 2023

At this point in time, the CI actions all complete successfully, and they are not obviously slower than the previous CI actions (comparing CI actions runtimes between this PR and #23), so I think this is ready to go out of draft mode.

The remaining question posed by this PR is really: do we prefer duplicating the commands run in CI actions between Nox and GitHub Actions, or do we want a slightly more complicated GitHub Actions that reuses the Nox actions?

@jherland jherland marked this pull request as ready for review January 5, 2023 14:12
@dpulls
Copy link

dpulls bot commented Jan 9, 2023

🎉 All dependencies have been resolved !

This reduces duplication of GitHub vs local/Nox CI actions by changing
the GitHub actions to call out to Nox.

That said, this is not a full-fledged embrace of the Nox way: Nox will
usually install dependencies in its own virtualenvs. However, these
would come in addition to Poetry's virtualenv, and we have not currently
set up caching for anything but the Poetry virtualenvs.

Work around this by setting up the appropriate Python version and
installing all the necessary dependencies in the Poetry virtualenv
(i.e. outside of Nox). We can then run Nox with --no-venv --no-install
to explicitly disable the Nox virtualenvs (which also disables the
Python version parametrization inside Nox).

For this to work, we also need to adjust our install_groups() helper in
noxfile.py to detect when it's running without Nox virtualenvs and skip
installation in this case.

In summary, this adds Nox into the Github Actions mix, but avoids adding
an extra layer of virtualenvs and also keeps the same useful caching of
the Poetry virtualenvs. The downside is that we run the Nox sessions in
a slightly different way compared to running Nox in our local
development environment: We do Python version parametrization and
dependency installation the Github Actions + Poetry way, and then use
Nox merely to abstract away the actual commands run in each CI action.

Time will tell if this setup is stable enough to run without issues. We
can always revert to duplicating Nox actions inside GitHub Actions
later. We can even consider generating .github/workflows/ci.yaml semi-
automatically from the sessions defined in noxfile.py.
@jherland jherland changed the base branch from jherland/nox-for-local-ci to main January 9, 2023 17:18
Copy link
Collaborator

@mknorps mknorps left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks neat.
I understand we do not use the full power of Nox here and give control over venv to Poetry. It is still OK I think.

@jherland jherland merged commit 2a57243 into main Jan 10, 2023
@jherland jherland deleted the jherland/nox-for-github-ci branch February 8, 2023 11:30
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 this pull request may close these issues.

Integrate local CI with GitHub Actions
2 participants