-
Notifications
You must be signed in to change notification settings - Fork 746
Convert reusable-nox workflowk to using nox GHA #3194
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
base: devel
Are you sure you want to change the base?
Conversation
oraNod
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @x1101 Some nits for your day. Can we also update the PR title so it is a bit more descriptive about what we're converting?
.github/workflows/reusable-nox.yml
Outdated
| workflow_call: | ||
| inputs: | ||
| python-versions: | ||
| description: Space-seperated list of python version(s) to run nox sessions with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| description: Space-seperated list of python version(s) to run nox sessions with | |
| description: Space-separated list of Python version(s) to install |
.github/workflows/reusable-nox.yml
Outdated
| required: false | ||
| default: "3.12" | ||
| sessions: | ||
| description: Space-seperated list of sessions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| description: Space-seperated list of sessions | |
| description: Space-separated list of nox sessions to run |
.github/workflows/reusable-nox.yml
Outdated
| description: Space-seperated list of sessions | ||
| type: string | ||
| required: false | ||
| default: "static formatters_check typing spelling checkers(rstcheck) checkers(rst-yamllint) checkers(docs-build) actionlint" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we just have "checkers" and run all three of those checks? I'm not sure it's necessary to specify which ones we want because it's all of them.
.github/workflows/reusable-nox.yml
Outdated
| with: | ||
| sessions: "${{ inputs.sessions }}" | ||
|
|
||
| - name: "Run Sessions with Args" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| - name: "Run Sessions with Args" | |
| - name: "Run the pip-compile session in check mode" |
.github/workflows/reusable-nox.yml
Outdated
| uses: x1101/github-action-run-nox@ca8b16f76c53a04b14952620e7a4ac5c7dc29812 | ||
| with: | ||
| sessions: "pip-compile" | ||
| extra-args: "--check" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty line at end of file needed. 😄
| matrix: | ||
| include: | ||
| # Inputs: | ||
| # session: name of session | ||
| # python-versions: comma-separated list of Python versions to install | ||
| # extra-args (optional): extra arguments to pass to nox session. | ||
| - session: static | ||
| python-versions: "3.12" | ||
| - session: formatters_check | ||
| python-versions: "3.12" | ||
| - session: typing | ||
| python-versions: "3.12" | ||
| - session: spelling | ||
| python-versions: "3.12" | ||
| - session: "checkers(rstcheck)" | ||
| python-versions: "3.12" | ||
| - session: "checkers(rst-yamllint)" | ||
| python-versions: "3.12" | ||
| - session: "checkers(docs-build)" | ||
| python-versions: "3.12" | ||
| - session: "actionlint" | ||
| python-versions: "3.12" | ||
| - session: "pip-compile" | ||
| extra-args: "--check" | ||
| python-versions: "3.12" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The matrix is needed so that there's multiple jobs. But it should be moved outside the reusable workflow into the calling one.
Having one step with everything in the CI log produces a wall of text that is difficult to parse and individual checks aren't represented in the checks widget in PRs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, that's exactly what I was concerned about, and the feedback I was looking for.
I'll rework it to address this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I actually have been researching mass maintenance of tox-managed projects and this is conceptually the same. I came up with a bunch of such principles when working on reusable-tox (calling side example: https://github.com/cherrypy/cheroot/blob/06a6d67e549ccaefe332cd0539c21e1483031071/.github/workflows/ci-cd.yml#L586-L690) and contributing to CPython's CI infra.
You can lurk in https://github.com/tox-dev/workflow/blob/208490c75f7f6b81e2698cc959f24d264c462d57/.github/workflows/reusable-tox.yml to see if you'd want to borrow some ideas.
- Per discussions, added the sessions matrix back in, instead of a single string list of sessions to support cleaner output of statuses
- Replaced (temp) x1101/github-action-run-nox with ansible-community/github-action-run-nox - Repalced "matrix.sessions" with "matrix.session" - All sessions now in quotes
|
I did a few fixups, and now it looks like its down to failing the |
- Replaced `inputs.` with `matrix.` This resovles the `actionlint` errors
|
I think I found it. I was still using At this point, I think this is ready to remove the "Draft" tag and be considered for full PR, unless there's additional feedback from @webknjaz or @oraNod on its current state. |
| # python-versions: comma-separated list of Python versions to install | ||
| # extra-args (optional): extra arguments to pass to nox session. | ||
| - session: static | ||
| - session: "static" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did somebody request wrapping string literals with quotes? My preference is usually removing them as much as possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I was having issues isolating the individual sessions, and this was one of the steps I took to do that.
Given the other fixes, there's a good chance its not needed. I'll re-test without them.
| matrix: | ||
| include: | ||
| # Inputs: | ||
| # matrix: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seeing the word from two lines above repeated looks confusing. It seems to be commented out code at glance.
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I meant originally is that this matrix should be in the calling workflow, not the reusable one. That would be ci.yaml.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what you mean. But I think that's a larger change to the workflow. As I understand it, the goal here is to take the existing workflow, which calls nox directly from a matrix and replace it with one that uses the GHA.
My preference would be to get the in-place change made and functional first before looking at reorganizing things.
That being said, if there's a strong desire to wrap that effort into this one, we can better outline that in the initial issue and I can look into tacking that too.
| - name: "Run nox session" | ||
| uses: ansible-community/github-action-run-nox@v1 | ||
| with: | ||
| sessions: "${{ matrix.session }}" | ||
| extra-args: "${{ matrix.extra-args || '' }}" | ||
| force-pythons: "${{ matrix.python-versions }}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's examples of splitting provisioning the venv and running the logic:
- https://github.com/pyca/cryptography/blob/09fb854e009d560e5edbe6677ce53f2b8c0b6011/.github/workflows/linkcheck.yml#L39-L45
- https://github.com/ansible/receptor/blob/59e0da47a39518b9a2742c7efae7bb7985a4d9a7/.github/workflows/coverage_reporting.yml#L52-L58
TL;DR for two steps to show up separately in CI, they should be actual separate entries in the step list (for the same session). The first one would run with nox --install-only, and it'd be followed by nox --no-install.
Marked as a DRAFT because it depends on a local fork of mine making changes to the upstream GHA. I have a PR in for that change. Once that's accepted, or the feature added in other ways, we can more accurately review this.
Addressed the request in #2511.
I am a little unsure of the approach I took on this, as the GHA looks for a single list of sessions to run. I converted the matrix over to that, but I'm unclear on what (if any) visibility into the details we'll lose that way. The other potential loss is if we intend to run different sessions against different python version in the same run (as opposed to running the whole action against a matrix of python versions).
If we determine that we're losing too many details or that we do need the ability to target multiple distinct pythons for different parts of the run, I can easily swap it back to the matrix setup, but still using this GHA.
Thoughts/questions/comments greatly appreciated.