-
Notifications
You must be signed in to change notification settings - Fork 47
look for add of a changelog fragment in the whole PR rather than the last commit #772
look for add of a changelog fragment in the whole PR rather than the last commit #772
Conversation
323650e
to
7e5fb52
Compare
@pabelanger could you take a look, please ? |
@justjais @goneri @pabelanger Change looks good to me. Can you please review and merge? Thanks in advance. |
Thank you @quidame for the change. May I ask you to move the logic in a new role. e.g
This way it will be way easier to test any future change and maybe, integrate that in the CI. |
* Look for add of a changelog fragment in the whole PR rather than the last commit. * Also look for changes/removal of existing files and for add of a new plugin. Use results to mitigate the need of a changelog fragment.
7e5fb52
to
97cddcd
Compare
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.
If I use the main branch, I still get the "Your pull-request is missing a changelog fragment, please add one. It should explain to end users the reason for your change." error.
We should not have any error in this case IMO.
* add a 'git rebase' before 'git diff' queries
97cddcd
to
e1ec70a
Compare
Where ? |
I did this:
|
|
||
- name: Changelog fragment failed | ||
fail: | ||
msg: "Your pull-request is missing a changelog fragment, please add one. It should explain to end users the reason for your change." |
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 suggest to add this URL in the error message: https://docs.ansible.com/ansible/latest/community/development_process.html#changelogs
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.
if the url is not expected to change for a couple of years, yes, I agree
- name: Check for changelog fragments | ||
args: | ||
chdir: "{{ zuul.executor.src_root }}/{{ zuul.project.canonical_name }}" | ||
shell: git show --name-status --exit-code --oneline --diff-filter=A | grep changelogs/fragments/ |
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 a pretty large refactor, I think you could just change this too
git show HEAD...origin/{{ zuul.branch }} --name-status --exit-code --oneline --diff-filter=A | grep changelogs/fragments/
And it will work as expected
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 does not cover this:
You do not have to add a changelog fragment for PRs that add new modules and plugins, because our tooling does that for you automatically.
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.
That is fine for now, the original purpose of this check was to enforce each commit to specific folders had the fragment. There shouldn't be harm for a user adding it in the same commit as a new module.
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, a commit that only changes tests/ should not require a changelog fragment.
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, a commit that only changes tests/ should not require a changelog fragment.
That is managed via https://github.com/ansible/project-config/blob/master/zuul.d/jobs.yaml#L76 if a project doesn't want them on tests, I would say create a new job, and parent to ansible-changelog-fragment updating the file matcher. In the case of network collections, changelogs for tests are still fine.
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.
There shouldn't be harm for a user adding it in the same commit as a new module.
You're right, and in fact there is no harm for a user adding it in the same commit as a new module. But there shouldn't be harm for a user NOT adding it in the same PR/commit as a new module.
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.
my feelings here are, that could be an optimization we make in a follow up patch. Even have a discussion on how we want to enhance this job. Your original issue was 'don't only check the last commit', which I think we can land now and test.
@goneri I don't understand your testcase. Do you play |
In my opinion, since their is no different between the two branches, we should just ignore the test. Sometime we run our tests again the main branches, e.g with periodical jobs. And in this case a role like this one should not raise an error. |
check_changelog_fragment__new_plugin.rc > check_changelog_fragment__changed_files.rc | ||
success_msg: >- | ||
Your pull-request contains a new {{ 'changelog fragment' if | ||
check_changelog_fragment__new_fragment.rc | bool else 'plugin' }}. |
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 also get the message when there is no difference between the two branches, but I'm fine with that at this stage.
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.
Looks good to me, thank you @quidame.
@pabelanger @goneri thanks for reviewing ! |
You're welcome. Merci pour ta patience :-) |
Yes, this code looks to be broken: Can we please revert, and create a new temp job? |
Give me a sec, I push a revert PR. |
This PR reverts the change on the |
# * the PR renames existing file(s) | ||
|
||
|
||
# Rebasing ensures diffs are related to the PR, and only to the PR. If the task |
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 finally had some time to look at this, there isn't a need to rebase here. We have dedicated zuul-mergers that run merge operations, if the merge fails the job won't run. So, lets delete 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.
ah, ok, that's fine, I'll remove it
changed_when: check_changelog_fragment__rebase.stdout_lines | length > 1 | ||
|
||
|
||
- name: Look for any diff between current and target branches |
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.
there should always be a diff right? As the PR running will have a new commit?
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.
yes, there should be a diff, except in the use case explained above by @goneri (playing the role in scheduled jobs against the default branch itself, so with an empty diff)
Fixes #771
RATIONALE
The current
ansible-changelog-fragment
check leads to many false positives:This PR is a refactor of the whole check to look for add of a changelog fragment in the entire PR rather that just the last commit, and to not fail when a changelog fragment is not required.