-
Notifications
You must be signed in to change notification settings - Fork 2
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 CI testing support #8
Draft
mitchnegus
wants to merge
4
commits into
sandialabs:main
Choose a base branch
from
mitchnegus:tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# A composite action to prepare tox-based workflows | ||
|
||
name: "Prepare tox" | ||
|
||
description: "Prepare tox-based workflows" | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: "Ensure upgraded pip" | ||
run: pip install --upgrade pip | ||
shell: bash | ||
- name: "Install tox" | ||
run: pip install tox | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# This workflow will install Python dependencies and run tests with a variety of Python versions | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | ||
|
||
name: Testing | ||
|
||
on: | ||
push: | ||
branches: [ "*" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: | | ||
3.8 | ||
3.9 | ||
3.10 | ||
3.11 | ||
3.12 | ||
3.13 | ||
- name: Install dependencies | ||
uses: ./.github/actions/prepare-tox | ||
- name: Run unit tests | ||
run: | | ||
tox -e py38,py39,py310,py311,py312,py313 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It seems reasonable to also require installing Python here. Are there compelling reasons why choosing a standard version (3.11) and using that for all tox jobs wouldn't work?
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 reason I had not included that one was because I hadn't put thought into how the matrixing versions (in lint) and full inclusion of all versions (in the tests) should be reconciled.
When we run
tox -e py39,py310,...
it runs an individual tox job for tests for each. That means that the runner has to have all those versions of Python installed to start with, because tox will look for each Python as it runs each job. But for linting, ourtox -e lint
job will just use whichever Python is the default in our virtual environment (I think).The
setup-python
action seems to allow you to specify the default Python version as the last version identified among multiple selected. I'd think if nothing else we might want to control which version is used for linting (e.g., 3.11 like you suggested).Also, another concern that popped into my head might be that there could be a performance penalty for installing all versions of Python for the linting job. From what I can see on the pipelines right now, it's less than 1 second for just one version at a time and closer to 9 seconds to install all 6 (Python 3.8 through 3.13). That's not huge for a CI pipeline—especially if it's running concurrent with tests which will almost always take far longer—so I'm inclined to think it's not a big deal.
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.
Ok, I've thought more about this, and I think adding Python here would make things difficult. Based on the comment above, in these tests we need to do three distinct things:
tox run
/tox -e py39,py310...
: Run unit tests with tox, with tox running tests for each version of Python. This requires that all tested versions of Python be installed on the runner for this one job.tox -e lint
: Run linting with tox, where tox will run the linting job with whatever Python version is the default. Hence, we use the version matrixing so that only the Python version we want to use for linting is installed for a given workflow, and tox uses that (e.g., job 1 installs 3.9 and lints with 3.9, before job 2 installs 3.10 and lints with 3.10, etc.).That all means that (1) needs all versions installed, (2) only needs one version installed, but if there are multiple versions it should be fixed as some mid-lifecycle default (e.g., 3.11), and (3) only needs one version installed at a time, but must be run multiple times with the majority of those runs being something other than the default.
Reconciling these conditions, especially if we install all the versions but then need to explicitly call tox with one version of Python or the other, is a more difficult means of accomplishing the same effect as installing only the versions we need for each job but then performing the rest of the tox setup in a common manner.
(I'm also still quite green in my understanding of GitHub workflows/actions, so if you think this misses the mark I'm open to other suggestions.)