-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
cirrus.yml: implement skips based on source changes #23030
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Luap99 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@cevich @edsantiago PTAL The duplication is annoying for sure but I cannot think of something better, open for ideas. My current idea to test this would be cherry-pick this commit into a new PR, remove |
Ok some basic checks, not the full matrix but I think this is good enough:
Looks like it works as I expect and it clearly marks tests as skipped to the PR author/reviewer so it should be obvious what is actually being run. |
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.
LGTM modulo some concerns
.cirrus.yml
Outdated
skip: >- | ||
$CIRRUS_PR != '' && | ||
!changesInclude('.cirrus.yml', 'Makefile', 'contrib/cirrus/**', 'vendor/**', 'hack/**') && | ||
!changesInclude('**/*build*.go') |
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.
This is making me more and more uncomfortable as the day progresses. I think this is >95% safe, but I can also envision situations where changes to storage code (podman, not vendor) or CONF envariable handling could impact podman build. Also, bud.bats runs podman commands other than build. I don't want to block, but I'd really like a lot of thought going into 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.
I cannot think of much, first of all consider that all podman build tests part of e2e/system tests are still run. This is only the buildah bud specific test that I skip here because it is both flaky and slow.
I honestly don't see much risk here and well that is why we run everything nightly. So at least the next day we should know that something broke an PR the last day (easy enough to check manually, or git bisect if needed).
IMO the benefit of less flakes faster CI outweighs the risk here.
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.
Note to myself: It is missing test/buildah-bud
in case someone updates the diff. I will update this on the next push
$CIRRUS_PR != '' && | ||
!changesInclude('.cirrus.yml', 'Makefile', 'contrib/cirrus/**', 'vendor/**', 'hack/**') && | ||
!changesInclude('test/system/**') && | ||
!(changesInclude('**/*.go', '**/*.c') && !changesIncludeOnly('test/**', 'pkg/machine/e2e/**')) |
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.
Similar to my bud comments. Is it possible for changes to something-else.go to break podman-machine tests?
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.
Well I cannot say 100% no. Sure there is risk that some day something weird happens or we update the file structure. Nightly runs should catch things and I also count on reviewers to see that machine tests are marked skipped but they changed some machine related code.
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 think relying more on the nightly cron-runs is probably okay for complex cases like this.
Non-blocking / nice-to-have: Remove Otherwise, this is nice work so far @Luap99 |
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 think there might be instances where we don't want to skip anything, ie release PR's, even if certain files are not changed. In this case, it could be done by checking for edits in the rawversion.go, but there might be other instances where running everything would make sense. Maybe consider a override label? I'd be okay with this in a followup PR or something.
Absolutely, I like to remove all of the special magic CI modes. However first I needed to be sure this here even works. Second I like to go incremental on this. Currently we cannot replace CI:DOCS as other tests such as compose or APIv2 are not yet covered by file based rules. So I like to keep them until I migrated all task over. |
Yes thanks, I totally forget about the version file. I need to look into what options we have for a manual overwrite. Ideally nobody should need that but I agree that having such option might be useful just in case. |
Yes, testing it (and There's also |
Well I already tested it here, see #23030 (comment) |
Pushed a new version:
Still missing is manual overwrite option, the best I can think right now is to use a special title like |
👍 |
Reading the conditions makes my brain hurt, but that should (fingers crossed) only be a problem now at review time, not in the future. Logicwise, I can't find any cases this won't handle, so I'm close to LGTM. I'd still like to think about it some more. As for |
Possible suggestion for the sanity check: diff --git a/contrib/cirrus/cirrus_yaml_test.py b/contrib/cirrus/cirrus_yaml_test.py
index 49d35d1ff..5ab43ce5d 100755
--- a/contrib/cirrus/cirrus_yaml_test.py
+++ b/contrib/cirrus/cirrus_yaml_test.py
@@ -63,14 +63,17 @@ class TestDependsOn(TestCaseBase):
def test_skips(self):
"""2024-06 PR#23030: ugly but necessary duplication in skip conditions. Prevent typos or unwanted changes."""
beginning = "$CIRRUS_PR != '' && !changesInclude('.cirrus.yml', 'Makefile', 'contrib/cirrus/**', 'vendor/**', 'hack/**', 'version/rawversion/*') && "
+ real_source_changes = " && !(changesInclude('**/*.go', '**/*.c') && !changesIncludeOnly('test/**', 'pkg/machine/e2e/**'))"
for task_name in self.ALL_TASK_NAMES:
task = self.CIRRUS_YAML[task_name + '_task']
if 'skip' in task:
skip = task['skip']
if 'changesInclude' in skip:
- msg = ('{0}: invalid skip "{1}"'.format(task_name, skip))
- self.assertEqual(skip[:len(beginning)], beginning, msg=msg)
+ msg = ('{0}: invalid skip'.format(task_name))
+ self.assertEqual(skip[:len(beginning)], beginning, msg=msg+": beginning part is wrong")
+ if 'changesIncludeOnly' in skip:
+ self.assertEqual(skip[len(skip)-len(real_source_changes):], real_source_changes, msg=msg+": changesIncludeOnly() part is wrong")
def not_task(self):
"""Ensure no task is named 'task'"""
Reasons: (1) check the tail part, it's too hard to check by hand; and (2) remove clutter from message, it makes the failure message unreadable. |
LGTM, I like CI:ALL |
I'm not against |
Well I mean technically one can already just add a newline in Makefile/cirrus.yml or some other file from the danger zone so I rather not add another file for it. I think I go CI:ALL for now and then we can reconsider once I am at the point where we can remove the other special titles such as CI:DOCS. |
Cool with me. I'm okay too with followup improvements to In case it's not been said: Really nice work here Paul 👏 It's really important (to me at least) that the team is well engaged with our own automation systems. You've really "stepped up to the plate" recently and it's both noted and appreciated. |
We do not have to test everything for each PR, we can know based on the source if we changed (i.e. machine code) and only run the tests then. This implements it as skip conditions, due to the nature of yaml files we unfortunately cannot deduplicate everything, i.e. the is PR check and danger files apply to everything but as skip is only a single yaml string we cannot deduplicate parts of that string. If anyone knows a way to achieve this I like to hear it. For now I implemented this for int, system, bud and machine tests. Once we are more comfortable with this I plan on adding it to other tests as well. This will replace the current _bail_if_test_can_be_skipped logic as it covers more, marks tasks actually skipped in the github UI and works even for the windows/macos machine tests. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Now that we have source based skips there might be a case where we have to run all tests. One option is to simply change a line in one of the danger files but having something that can be set as title might be easier for users. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Pushed the test change from @edsantiago and now another commit to add CI:ALL support. This should be ready. |
@@ -126,6 +126,10 @@ is removed. | |||
commit-change before Cirrus-CI will notice the draft-status update (i.e. | |||
pressing the re-run button **is not** good enough). | |||
|
|||
### Intended `[CI:ALL]` behavior: | |||
|
|||
Run even the tasks that are skipped based on changed sources conditions otherwise. |
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.
Hard to parse, but IMO not worth a repush. Should you wish to repush (now or in a followup), perhaps something like:
As of June 2024, the default Cirrus CI setup skips tasks that it deems unnecessary, such as running e2e or system tests on a doc-only PR (see #23030). This string forces all CI jobs to run.
/lgtm |
LGTM |
48e1efb
into
containers:main
We do not have to test everything for each PR, we can know based on the source if we changed (i.e. machine code) and only run the tests then.
This implements it as skip conditions, due to the nature of yaml files we unfortunately cannot deduplicate everything, i.e. the is PR check and danger files apply to everything but as skip is only a single yaml string we cannot deduplicate parts of that string. If anyone knows a way to achieve this I like to hear it.
For now I implemented this for int, system, bud and machine tests. Once we are more comfortable with this I plan on adding it to other tests as well.
This will replace the current _bail_if_test_can_be_skipped logic as it covers more, marks tasks actually skipped in the github UI and works even for the windows/macos machine tests.
Does this PR introduce a user-facing change?