travis: skip unit and build tests for package-only PRs#5842
travis: skip unit and build tests for package-only PRs#5842alalazo wants to merge 4 commits intospack:developfrom
Conversation
222cbbc to
cec010d
Compare
cec010d to
c2f991c
Compare
|
@scheibelp @tgamblin Do you have time to review this one? It may help reducing the cycles spent on testing when the PR modifies only packages. We need to "educate" users to start PRs of this kind on branches named |
c2f991c to
c7a2ae2
Compare
f13da74 to
880e407
Compare
There was a problem hiding this comment.
This looks awesome. The only thing I would request be changed is that we not completely eliminate unit tests for package builds, but drastically reduce them.
There are two unit test that actually matter for package builds:
-
In
package_sanity.pythere are two relevant tests:test_get_all_packages: makes sure all packages are importable.test_all_versions_are_lowercase: tests that all package names are lowercase (should probably be renamed -- not sure how this got crufty)
-
In
python_versionthere is one relevant test:test_package_module_compatibility: tests that package code is compatible with different python versions.
I think if we ran one test on Linux to do just these, we'd be in pretty good shape. What should probably happen is that we should add a pytest marker to them, then run spack test and filter on the marker (e.g. @ptyest.mark.packagetest).
Note that the python_version test is not 100% comprehensive, so we may still miss some python version compatibility issues that we would catch if we actually ran it for all versions of python. But I think it's pretty good. Note also that the package tests get all packages, so if you want to be really efficient you could only have it try to get (import) the packages that are added/modified in the PR. That is probably unnecessary, given how fast the tests run compared to the launch overhead.
Obviously, we also want the packages to actually be built on each PR, but that is something we're working on that needs to be done outside travis. The plan is to add that later.
Thoughts?
|
👍 to what @tgamblin said, apparently you can't react to reviews like you can comments. |
880e407 to
a599376
Compare
|
@tgamblin @adamjstewart Done with the requested changes
I agree. In any case, if an issue slips through the reduced set of tests (quite rare occurrence imo), it will be caught immediately on merge to
On that regard some self-advertisement for a PR: #6977 can be useful for the reporting phase of a build. Adding CDash (or whatever we want to use) on top of that should be as easy as adding a new template. |
This comment has been minimized.
This comment has been minimized.
tgamblin
left a comment
There was a problem hiding this comment.
@alalazo ok reviewed again. Thanks for all this work!
I made some comments but the only concrete code change I have is to remove one test erroneously labeled packagetest. I have another question and maybe a change request, though.
I thought about it and it's a bit sad that travis isn't a bit more flexible about the conditions. It seems that they are pretty static -- we can't have Travis analyze the PR, determine what changed, and spawn different test cases based on that. This means we have to force users to name package branches certain things.
I am somewhat concerned that the rigid branch naming is going to confuse people and scare away contributors. If you look at our PR list right now, the base branch name of a lot of package PRs is not packages/*, but the scripts in this PR are pretty rigid about this and will fail builds.
What if, instead of failing PRs not properly labeled with packages/*, we let the regular tests run but comment on the PR that things could build much faster if you use the packages/ base name? The comment can be automatically added by the qa script, and it could link to the relevant contributor documentation. I think that would keep things rolling at first and would gradually get people to switch to the new naming scheme without scaring people off. Thoughts?
Another thing that might help would be to make it super easy to make a package PR, e.g. with a spack pull-request command or something like that. Then the checks and naming stuff could happen client-side and transparently to the user. Easybuild actually does some of this, though I am not sure they do it to control which tests run.
The most confusing way things can fail is if someone submits a package PR to one of the core build tests -- they probably don't know anything about those but we'll make them change the name of their PR branch still... is there a good way around this?
| assert not all_issues | ||
|
|
||
|
|
||
| @pytest.mark.packagetest |
There was a problem hiding this comment.
This one actually isn't needed is it? It doesn't look at package files, just core. Is there a reason to run this for package-only tests?
| check_python_versions(pyfiles([spack.lib_path], exclude=exclude_paths)) | ||
|
|
||
|
|
||
| @pytest.mark.packagetest |
There was a problem hiding this comment.
I think just marking this one covers things.
share/spack/qa/no_changes_in_core.py
Outdated
|
|
||
| # If something changed in the core libraries we need to test it | ||
| core_path = os.path.join('lib', 'spack') | ||
| changes_in_core = any(core_path in x for x in files) |
There was a problem hiding this comment.
For correctness I would make this any x.startswith(core_path) and make sure they're absolute paths. We don't have it now but I could imagine some mirror lib/spack structure arising somewhere outside the core (e.g. if we moved the tests or something) so I think it's best to be rigorous and do the real check.
|
|
||
| if changes_in_relevant_packages: | ||
| print('FAILURE: at least one of the packages in the "Build tests" stage has been modified.') # noqa: ignore=E501 | ||
| print('Rename your branch to something that does not start with "packages"') # noqa: ignore=E501 |
There was a problem hiding this comment.
Rather than being obnoxious about naming, could we not just run the correct tests given the set of changes that we encounter? I kind of don't like that you have to name your branch something special to get the shorter/longer tests. Is this something that we have to do b/c of how stages work in travis?
There was a problem hiding this comment.
Ok I read through this stuff. It looks like travis isn't particularly flexible about this so I guess we have to make sure the branches are named correctly like this. Can these conventions be made very clear in the contribution docs?
| # Exit early because polling the repo may be slow | ||
| if changes_in_core: | ||
| print('FAILURE: at least one core file has been modified.') | ||
| print('Rename your branch to something that does not start with "packages"') # noqa: ignore=E501 |
There was a problem hiding this comment.
See my comment below -- I think we shouldn't enforce package naming conventions so strictly. I think people are accustomed to naming their branches whatever they want in their own forks, as well.
There was a problem hiding this comment.
Just a quick comment on this. The only failure case should be if somebody submitted a change to the core framework and called the branch packages/*. For the most common case where somebody changed just a package and named the branch whatever they want, that just triggers all the tests. It will be slower, but won't result in a failure because of naming.
👍 to the suggestion of sending an automated message to tell people they had a faster way to run tests, if they missed it.
| # | ||
| # Description: | ||
| # Helper script that returns 0 if any file in core | ||
| # has been changed, 1 otherwise |
There was a problem hiding this comment.
Could this script be a developer command instead of a standalone script? Seems like the stuff it reports is useful outside of this script (e.g., so users can know whether they pakage-only or core changes).
a599376 to
34b4e6b
Compare
I left a comment above, but to reiterate:
Said otherwise: you're allowed to get a fast test lane if you call your branch
That should be already the case (unless I miss something). The fact is that, with this configuration: stages:
- 'flake8 + documentation'
- name: 'no changes in core'
if: head_branch =~ ^packages
- name: 'unit tests'
if: NOT head_branch =~ ^packages
- name: 'build tests'
if: NOT head_branch =~ ^packages
- name: 'unit tests - osx'
if: type IN (cron)we run the new python script only on branches that are called
which is exactly the current situation. In any case, I like the idea of leaving a status message to inform people of changes to the qa workflow. Another way to help contributors could be a $ spack audit --base=develop
Modified files:
var/spack/repos/builtin/packages/ldc-bootstrap/package.py
var/spack/repos/builtin/packages/ldc/package.py
Naming: branch 'ldc_update' could be named 'packages/ldc_update' to skip unit tests on the PR
Flake8: checks were clean
...If you agree I'd work on those ideas in later PRs.
You're right, but hopefully the error message: will be clear enough not to lose much time on the issue. I agree though that for the user it's an hassle. |
|
@tgamblin Is there any change needed here? Do you want me to move the script to a developer command within this PR? |
|
@tgamblin ping |
34b4e6b to
6ab7476
Compare
|
ping |
|
@scheibelp @tgamblin Travis seems to be flakey again, so maybe this can help with package only PRs? For your convenience, here's an example from our fork. |
|
Is there still interest in this PR? |
6ab7476 to
74b2393
Compare
74b2393 to
a5d8506
Compare
|
@tgamblin is this functionality in place? This PR is open, but I see this comment: #9403 (comment) that seems to indicate it might already work ? I thought I'd seen some PRs from branches with this prefix skip the built tests, but I can't find any now. |
With this PR all the branches that starts with 'packages' will skip unit tests and build tests, on the promise that there are no modifications to core files. This promise is checked by an additional test that is run prior to flake8 and documentation.
a5d8506 to
0ff5d40
Compare
|
Do we need to rebase this and bring it up to date? Mac OS builders on Travis are a real stopper when we receive a lot of package only PRs at the same time. This will reduce the request of MacOS builders in that case by ~50% (they'll be used on merge, but not on PR). |
I'm kind of tempted to move to GitHub actions and have a seed stage that determines what to do based on what is actually modified. Travis's stages are pretty inflexible. What do you think? |
If that's possible it would be better, since we won't impose a naming convention for branches to contributors. I need to have a closer look at Github actions but it seems they already support MacOS. Definitely worth a try. Which time-frame do you have in mind? |
TLDR
With this PR all the branches whose name starts with
packageswill skip unit tests and build tests, on the promise that there are no modifications to core files. This promise is checked by an additional test that is run after flake8 and documentation.Documentation on the new Travis features here.
Example
You can check that Travis in this PR run all the tests as it did before. In #5840 the modifications are basically the same but the branch is namedpackages/ldc_and_faster_ci. The resulting CI is here and it fails as expected.closes #5180
closes #5822
closes #5840
For #5822: I started with the idea of fixing that issue and skipping unit + build tests. I ended up modifying part of core, hence the current status. If the 2 lines change in
ldc+ldc-bootstrapbother people I can extract them.