File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change 1919 steps :
2020 - name : Checkout current PR code
2121 uses : actions/checkout@v2
22+ with :
23+ fetch-depth : 0
2224
2325 - name : Install ruby version ${{ env.ruby_version }}
2426 uses : ruby/setup-ruby@v1
2830 - name : Prepare testing environment with bundler
2931 run : bundle update --jobs 4 --retry 3
3032
33+ - name : Run commits check
34+ run : bundle exec rake commits
35+
3136 - name : Run rubocop check
3237 run : bundle exec rake ${{ env.extra_checks }} rubocop
3338
Original file line number Diff line number Diff line change 8585 end
8686end
8787
88+ desc "verify that commit messages match CONTRIBUTING.md requirements"
89+ task ( :commits ) do
90+ # This rake task looks at the summary from every commit from this branch not
91+ # in the branch targeted for a PR.
92+ commit_range = 'HEAD^..HEAD'
93+ puts "Checking commits #{ commit_range } "
94+ %x{git log --no-merges --pretty=%s #{ commit_range } } . each_line do |commit_summary |
95+ # This regex tests for the currently supported commit summary tokens.
96+ # The exception tries to explain it in more full.
97+ if /^\( (maint|packaging|doc|docs|modules-\d +)\) |revert/i . match ( commit_summary ) . nil?
98+ raise "\n \n \n \t This commit summary didn't match CONTRIBUTING.md guidelines:\n " \
99+ "\n \t \t #{ commit_summary } \n " \
100+ "\t The commit summary (i.e. the first line of the commit message) should start with one of:\n " \
101+ "\t \t (MODULES-<digits>) # this is most common and should be a ticket at tickets.puppet.com\n " \
102+ "\t \t (docs)\n " \
103+ "\t \t (docs)(DOCUMENT-<digits>)\n " \
104+ "\t \t (packaging)\n "
105+ "\t \t (maint)\n " \
106+ "\n \t This test for the commit summary is case-insensitive.\n \n \n "
107+ else
108+ puts "#{ commit_summary } "
109+ end
110+ puts "...passed"
111+ end
112+ end
You can’t perform that action at this time.
0 commit comments