-
Notifications
You must be signed in to change notification settings - Fork 11
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
Allow to use ansible-test's change detection for Pull Requests #46
Allow to use ansible-test's change detection for Pull Requests #46
Conversation
3ace133
to
05aa9e9
Compare
FYI, this branch is currently used in community.crypto's |
@webknjaz can you take a look at this one? |
Oh, I somehow missed this one. Will take a look, thanks for the ping. |
@@ -45,6 +45,13 @@ inputs: | |||
default: auto | |||
pre-test-cmd: | |||
description: Extra command to invoke before ansible-test | |||
pull-request-change-detection: | |||
description: >- | |||
Whether to use change detection for pull requests. If set to `true`, will |
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.
Any reason not to have this on by default?
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's a breaking change, and different what most collections do right now. Basically only the collections using AZP use change detection, all others simply run all tests.
Also switching this on effectively disables code coverage reporting for pull requests.
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.
Also switching this on effectively disables code coverage reporting for pull requests.
Could you explore if codecov's carryforward feature could fix 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.
@felixfontein the new input probably needs a README entry and some test job?
Testing isn't so easy, since the test cases run with |
It sounds like Codecov's Carryforward flags could handle this: |
You could add another matrix job with it unset, or set to |
I cannot claim I fully understood carryforward flags, but the way I understand them they won't help here at all, since Also besides that, I really don't want any code coverage to be uploaded for PRs in the collections where I plan to use this. |
|
The tests now pass, and the life test of this branch in felixfontein/ansible-playground#4 is still working. |
@felixfontein I've accidentally merged the wrong branch so I had to force-push to reset that quickly. You'll need to reopen this as a new PR. |
So I've read the docs again myself, and it appears that it'd help, if one were to list those flags in a config and set
I wonder why. Is that because you think that their bot comments/statuses would be annoying? I think that could be disabled, and it'd be made silent. Also, I can imagine that some people would still want this, so maybe it's reasonable to have a flag/input for this? Or autodetect the use of carryforward in the codecov config? If there's any |
I've re-opened this in #49. |
Test PR: felixfontein/ansible-playground#4
This is necessary to make ansible-collections/community.crypto#520 bearable (running all integration tests needs 20-30 minutes), and to make a similar thing work for community.general and other larger collections where you usually don't want to run everything in CI.
(Not sending code coverage in this case is important since not all tests are run.)
The tricky part here is using ansible-test's change detection since it expects the current commit to be HEAD of a branch, and it expects the branch it is branched from to be around. GitHub's checkout action provides neither, but in the case of pull requests we have the merge commit checked out. By passing
fetch-depth: 0
to the checkout action, we can get all history, and we also get the branches from the repository where this PR runs in. This allows us to checkoutorigin/<target_branch_name>
(usuallymain
) as<target_branch_name>
, and we can create a new branch__action_branch_name
for the current commit (the merge commit). We then can callansible-test
with--changed --base-branch <target_branch_name>
and let ansible-test handle the change detection.https://github.com/felixfontein/ansible-playground/actions/runs/3352362049/jobs/5554455066 shows how this works. In the PR's branch one file has been modified (
plugins/connection/dummy.py
), while in the currentmain
branch of the collection also another file has been modified (the GHA workflow). So ansible-test should only detect the change in the plugin and not in the workflow (if you naively do agit diff --name-only origin/<target_branch_name>
you get both files). The relevant lines are:(Note that the linked run was with a slightly older version of this branch, which included a
git log
statement. That's gone now.)