This repository has been archived by the owner on Jan 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor ansible-changelog-fragment check
* 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.
- Loading branch information
Showing
1 changed file
with
31 additions
and
10 deletions.
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 |
---|---|---|
@@ -1,15 +1,36 @@ | ||
--- | ||
# There is a new changelog fragment, OR: there is a new plugin and no changes | ||
# of existing files. Fail otherwise. | ||
|
||
- hosts: localhost | ||
gather_facts: false | ||
tasks: | ||
- name: Check for changelog fragments | ||
args: | ||
- name: Look for modified and deleted files | ||
command: | ||
chdir: "{{ zuul.executor.src_root }}/{{ zuul.project.canonical_name }}" | ||
cmd: "git diff {{ zuul.project.default-branch }} --name-only --exit-code --diff-filter=MD" | ||
register: pr_modified_files | ||
failed_when: pr_modified_files.rc > 1 | ||
|
||
- name: Look for new plugin | ||
command: | ||
chdir: "{{ zuul.executor.src_root }}/{{ zuul.project.canonical_name }}" | ||
shell: git show --name-status --exit-code --oneline --diff-filter=A | grep changelogs/fragments/ | ||
register: r | ||
failed_when: r.rc > 1 | ||
|
||
- 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." | ||
when: r.rc | ||
cmd: "git diff {{ zuul.project.default-branch }} --name-only --exit-code --diff-filter=A -- plugins/" | ||
register: pr_new_plugin | ||
failed_when: pr_new_plugin.rc > 1 | ||
|
||
- name: Look for changelog fragment | ||
command: | ||
chdir: "{{ zuul.executor.src_root }}/{{ zuul.project.canonical_name }}" | ||
cmd: "git diff {{ zuul.project.default-branch }} --name-only --exit-code --diff-filter=A -- changelogs/fragments/" | ||
register: pr_changelog_fragment | ||
failed_when: pr_changelog_fragment.rc > 1 | ||
|
||
|
||
- name: Assert that a new changelog fragment is present if required | ||
assert: | ||
that: | ||
- pr_changelog_fragment.rc == 1 or | ||
pr_modified_files.rc < pr_new_plugin.rc | ||
success_msg: "Your pull-request contains a new {{ pr_changelog_fragment.rc | bool | ternary('changelog fragment', 'plugin') }}." | ||
fail_msg: "Your pull-request is missing a changelog fragment, please add one. It should explain to end users the reason for your change." |