Skip to content

Commit

Permalink
Add a workflow looking for changelog fragments
Browse files Browse the repository at this point in the history
Limitations:
- The comment asking for the fragment will be posted at each push on the
  PR until the fragment is present.

Closes:: #186
  • Loading branch information
rrey committed Jun 25, 2022
1 parent a820865 commit 653fac2
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/fragment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
on:
pull_request:

name: Check changelog fragment
jobs:
check_fragment:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Automatic Rebase
run: ./hacking/check_fragment.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.number }}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ See LICENCE to see the full text.

Any contribution is welcome and we only ask contributors to:
* Provide *at least* integration tests for any contribution.
* The Pull Request *MUST* contain a changelog fragment. See [Ansible documentation](https://docs.ansible.com/ansible/latest/community/development_process.html#creating-a-changelog-fragment) about fragments.
* Create an issue for any significant contribution that would change a large portion of the code base.

## Contributors ✨
Expand Down
2 changes: 2 additions & 0 deletions changelogs/fragments/186_check_fragments.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
trivial:
- GH Actions now checks that all PR contains a changelog fragment.
7 changes: 7 additions & 0 deletions hacking/NEED_FRAGMENT
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Dear contributor,

Thank you for you Pull Request !
To ease the work of maintainers you need to add a [changelog fragment](https://docs.ansible.com/ansible/latest/community/development_process.html#creating-a-changelog-fragment) in you PR.

It will help your change be released faster !
Thank you !
23 changes: 23 additions & 0 deletions hacking/check_fragment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

function comment() {
echo "No fragment detected"
if [ -n "$PR_NUMBER" ]; then
gh pr review "$PR_NUMBER" -r -F "$(git rev-parse --show-toplevel)/hacking/NEED_FRAGMENT"
fi
exit 1
}

function approve() {
if [ -n "$PR_NUMBER" ]; then
gh pr review "$PR_NUMBER" -a
fi
}

FRAGMENTS=$(git fetch && git diff --name-only --diff-filter=ACMRT origin/main..HEAD | grep "changelogs/fragments")

if [ -z "$FRAGMENTS" ]; then
comment
else
approve
fi
1 change: 1 addition & 0 deletions tests/sanity/ignore-2.10.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
plugins/modules/grafana_dashboard.py validate-modules:invalid-argument-name
tests/unit/modules/grafana/grafana_plugin/test_grafana_plugin.py pep8:W291
hacking/check_fragment.sh shebang
1 change: 1 addition & 0 deletions tests/sanity/ignore-2.11.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
plugins/modules/grafana_dashboard.py validate-modules:invalid-argument-name
tests/unit/modules/grafana/grafana_plugin/test_grafana_plugin.py pep8:W291
hacking/check_fragment.sh shebang
1 change: 1 addition & 0 deletions tests/sanity/ignore-2.12.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
plugins/modules/grafana_dashboard.py validate-modules:invalid-argument-name
tests/unit/modules/grafana/grafana_plugin/test_grafana_plugin.py pep8:W291
hacking/check_fragment.sh shebang
1 change: 1 addition & 0 deletions tests/sanity/ignore-2.13.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
plugins/modules/grafana_dashboard.py validate-modules:invalid-argument-name
tests/unit/modules/grafana/grafana_plugin/test_grafana_plugin.py pep8:W291
hacking/check_fragment.sh shebang
1 change: 1 addition & 0 deletions tests/sanity/ignore-2.14.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
plugins/modules/grafana_dashboard.py validate-modules:invalid-argument-name
tests/unit/modules/grafana/grafana_plugin/test_grafana_plugin.py pep8:W291
hacking/check_fragment.sh shebang
1 change: 1 addition & 0 deletions tests/sanity/ignore-2.9.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
tests/unit/modules/grafana/grafana_plugin/test_grafana_plugin.py pep8:W291
hacking/check_fragment.sh shebang

0 comments on commit 653fac2

Please sign in to comment.