Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Kill Gitler and make way for The Butler
Browse files Browse the repository at this point in the history
The Butler is a more polite and helpful replacement to the
grumpy old Gitler.
The Butler will do his utmost to assist new (and old)
contributors to the MySensors cause.
fallberg committed May 2, 2018
1 parent 1c5853c commit e64c432
Showing 5 changed files with 98 additions and 78 deletions.
20 changes: 10 additions & 10 deletions .ci/arduino.groovy
Original file line number Diff line number Diff line change
@@ -65,7 +65,7 @@ def buildMySensorsMicro(config, sketches, String key) {
if (currentBuild.currentResult == 'UNSTABLE') {
config.pr.setBuildStatus(config, 'ERROR', 'Toll gate (MySensorsMicro - '+key+')', 'Warnings found', '${BUILD_URL}warnings2Result/new')
if (config.is_pull_request) {
error 'Termiated due to warnings found'
error 'Terminated due to warnings found'
}
} else if (currentBuild.currentResult == 'FAILURE') {
config.pr.setBuildStatus(config, 'FAILURE', 'Toll gate (MySensorsMicro - '+key+')', 'Build error', '${BUILD_URL}')
@@ -101,7 +101,7 @@ def buildMySensorsGw(config, sketches, String key) {
if (currentBuild.currentResult == 'UNSTABLE') {
config.pr.setBuildStatus(config, 'ERROR', 'Toll gate (MySensorsGW - '+key+')', 'Warnings found', '${BUILD_URL}warnings2Result/new')
if (config.is_pull_request) {
error 'Termiated due to warnings found'
error 'Terminated due to warnings found'
}
} else if (currentBuild.currentResult == 'FAILURE') {
config.pr.setBuildStatus(config, 'FAILURE', 'Toll gate (MySensorsGW - '+key+')', 'Build error', '${BUILD_URL}')
@@ -134,7 +134,7 @@ def buildArduinoUno(config, sketches, String key) {
if (currentBuild.currentResult == 'UNSTABLE') {
config.pr.setBuildStatus(config, 'ERROR', 'Toll gate (Arduino Uno - '+key+')', 'Warnings found', '${BUILD_URL}warnings2Result/new')
if (config.is_pull_request) {
error 'Termiated due to warnings found'
error 'Terminated due to warnings found'
}
} else if (currentBuild.currentResult == 'FAILURE') {
config.pr.setBuildStatus(config, 'FAILURE', 'Toll gate (Arduino Uno - '+key+')', 'Build error', '${BUILD_URL}')
@@ -167,7 +167,7 @@ def buildArduinoMega(config, sketches, String key) {
if (currentBuild.currentResult == 'UNSTABLE') {
config.pr.setBuildStatus(config, config, 'ERROR', 'Toll gate (Arduino Mega - '+key+')', 'Warnings found', '${BUILD_URL}warnings2Result/new')
if (config.is_pull_request) {
error 'Termiated due to warnings found'
error 'Terminated due to warnings found'
}
} else if (currentBuild.currentResult == 'FAILURE') {
config.pr.setBuildStatus(config, 'FAILURE', 'Toll gate (Arduino Mega - '+key+')', 'Build error', '${BUILD_URL}')
@@ -200,7 +200,7 @@ def buildSTM32F1(config, sketches, String key) {
if (currentBuild.currentResult == 'UNSTABLE') {
config.pr.setBuildStatus(config, 'ERROR', 'Toll gate (STM32F1 - '+key+')', 'Warnings found', '${BUILD_URL}warnings2Result/new')
if (config.is_pull_request) {
error 'Termiated due to warnings found'
error 'Terminated due to warnings found'
}
} else if (currentBuild.currentResult == 'FAILURE') {
config.pr.setBuildStatus(config, 'FAILURE', 'Toll gate (STM32F1 - '+key+')', 'Build error', '${BUILD_URL}')
@@ -239,7 +239,7 @@ def buildEsp8266(config, sketches, String key) {
if (currentBuild.currentResult == 'UNSTABLE') {
config.pr.setBuildStatus(config, 'ERROR', 'Toll gate (ESP8266 - '+key+')', 'Warnings found', '${BUILD_URL}warnings2Result/new')
if (config.is_pull_request) {
error 'Termiated due to warnings found'
error 'Terminated due to warnings found'
}
} else if (currentBuild.currentResult == 'FAILURE') {
config.pr.setBuildStatus(config, 'FAILURE', 'Toll gate (ESP8266 - '+key+')', 'Build error', '${BUILD_URL}')
@@ -287,7 +287,7 @@ def buildEsp32(config, sketches, String key) {
if (currentBuild.currentResult == 'UNSTABLE') {
config.pr.setBuildStatus(config, 'ERROR', 'Toll gate (ESP32 - '+key+')', 'Warnings found', '${BUILD_URL}warnings2Result/new')
if (config.is_pull_request) {
error 'Termiated due to warnings found'
error 'Terminated due to warnings found'
}
} else if (currentBuild.currentResult == 'FAILURE') {
config.pr.setBuildStatus(config, 'FAILURE', 'Toll gate (ESP32 - '+key+')', 'Build error', '${BUILD_URL}')
@@ -328,7 +328,7 @@ def buildnRF5(config, sketches, String key) {
if (currentBuild.currentResult == 'UNSTABLE') {
config.pr.setBuildStatus(config, 'ERROR', 'Toll gate (nRF5 - '+key+')', 'Warnings found', '${BUILD_URL}warnings2Result/new')
if (config.is_pull_request) {
error 'Termiated due to warnings found'
error 'Terminated due to warnings found'
}
} else if (currentBuild.currentResult == 'FAILURE') {
config.pr.setBuildStatus(config, 'FAILURE', 'Toll gate (nRF5 - '+key+')', 'Build error', '${BUILD_URL}')
@@ -352,7 +352,7 @@ def buildnRF52832(config, sketches, String key) {
if (currentBuild.currentResult == 'UNSTABLE') {
config.pr.setBuildStatus(config, 'ERROR', 'Toll gate (nRF52832 - '+key+')', 'Warnings found', '${BUILD_URL}warnings2Result/new')
if (config.is_pull_request) {
error 'Termiated due to warnings found'
error 'Terminated due to warnings found'
}
} else if (currentBuild.currentResult == 'FAILURE') {
config.pr.setBuildStatus(config, 'FAILURE', 'Toll gate (nRF52832 - '+key+')', 'Build error', '${BUILD_URL}')
@@ -376,7 +376,7 @@ def buildnRF51822(config, sketches, String key) {
if (currentBuild.currentResult == 'UNSTABLE') {
config.pr.setBuildStatus(config, 'ERROR', 'Toll gate (nRF51822 - '+key+')', 'Warnings found', '${BUILD_URL}warnings2Result/new')
if (config.is_pull_request) {
error 'Termiated due to warnings found'
error 'Terminated due to warnings found'
}
} else if (currentBuild.currentResult == 'FAILURE') {
config.pr.setBuildStatus(config, 'FAILURE', 'Toll gate (nRF51822 - '+key+')', 'Build error', '${BUILD_URL}')
36 changes: 20 additions & 16 deletions .ci/gitler.groovy → .ci/butler.groovy
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!groovy
def call(config) {
config.pr.setBuildStatus(config, 'PENDING', 'Toll gate (Gitler)', 'Checking...', '${BUILD_URL}flowGraphTable/')
config.pr.setBuildStatus(config, 'PENDING', 'Toll gate (Butler)', 'Checking...', '${BUILD_URL}flowGraphTable/')
if (env.CHANGE_TARGET == 'master' &&
(env.CHANGE_AUTHOR != 'bblacey' && env.CHANGE_AUTHOR != 'd00616' &&
env.CHANGE_AUTHOR != 'fallberg' && env.CHANGE_AUTHOR != 'henrikekblad' &&
@@ -9,7 +9,7 @@ def call(config) {
env.CHANGE_AUTHOR != 'tekka007' && env.CHANGE_AUTHOR != 'user2684' &&
env.CHANGE_AUTHOR != 'Yveaux'))
{
config.pr.setBuildStatus(config, 'FAILURE', 'Toll gate (Gitler)', 'This pull request targets master. That is not permitted for '+env.CHANGE_AUTHOR, '')
config.pr.setBuildStatus(config, 'FAILURE', 'Toll gate (Butler)', 'Sir, This pull request targets master. I am afraid that is not permitted for '+env.CHANGE_AUTHOR, '')
error "This pull request targets master. That is not permitted!"
}
else if (env.CHANGE_TARGET == 'master')
@@ -48,7 +48,7 @@ def call(config) {
])
}

config.pr.setBuildStatus(config, 'SUCCESS', 'Toll gate (Gitler)', 'Pass', '')
config.pr.setBuildStatus(config, 'SUCCESS', 'Toll gate (Butler)', 'Pass - Well done Master!', '')
config.pr.setBuildStatus(config, 'SUCCESS', 'Toll gate (Release changelog)', '', '${BUILD_URL}execution/node/3/ws/MySensors/ReleaseNotes.md/*view*/')
return
}
@@ -115,31 +115,35 @@ def call(config) {
ret = sh(returnStatus: true,
script:"""#!/bin/bash
cd ${config.repository_root}/.ci
./gitler.sh""")
./butler.sh""")

if (fileExists(config.repository_root+'restyling.patch')) {
emailext (
subject: "Job '${env.JOB_NAME} #${env.BUILD_NUMBER} [PR#${env.CHANGE_ID}]' failed due to bad code styling",
body: """<p>Job '${env.JOB_NAME} [<a href="${env.CHANGE_URL}">PR#${env.CHANGE_ID}</a> - ${env.CHANGE_TITLE}]' failed because code style does not follow the standards.</p>
A patch to rectify the errors is attached. You apply the patch using:<br>
subject: "PR#${env.CHANGE_ID} - ${env.CHANGE_TITLE} has unfortunate code styling",
body: """<p>Greetings Sir!<p>
I am afraid your pull request does not follow the MySensors standards with respect to coding style.</p>
That is ok, you are perhaps a first time committer to this repository. Please read the <a href="https://www.mysensors.org/download/contributing">code contribution guidelines</a> for help on how to format your code.<p>
To assist you, I have prepared a patch for you that will reformat the code according to the coding style required.<br>
The patch is attached. You may apply the patch using:<br>
git apply restyling.patch<p>
If you disagree to this, please discuss it <a href="${env.CHANGE_URL}">here</a>.<p>
Yours sincerely, Gitler, on behalf of Jenkins""",
mimeType: 'text/html', to: '${env.CHANGE_AUTHOR_EMAIL}',
If you disagree with me, please discuss it <a href="${env.CHANGE_URL}">here</a>.<p>
--<br>
Yours sincerely, The Butler, serving the MySensors community""",
mimeType: 'text/html', to: env.CHANGE_AUTHOR_EMAIL,
attachLog: false, compressLog: false, attachmentsPattern: config.repository_root+'restyling.patch'
)
}
publishHTML([allowMissing: true, alwaysLinkToLastBuild: false, keepAll: true,
reportDir: config.repository_root,
reportFiles: 'gitler.html', reportName: 'Gitler report', reportTitles: ''])
reportFiles: 'butler.html', reportName: 'The Butler report', reportTitles: ''])
if (ret == 1) {
config.pr.setBuildStatus(config, 'FAILURE', 'Toll gate (Gitler)', 'Commit(s) does not meet coding standards', '${BUILD_URL}Gitler_report/gitler.html')
config.pr.setBuildStatus(config, 'FAILURE', 'Toll gate (Butler)', 'I am afraid the commit(s) needs some touchup, please check the details...', '${BUILD_URL}The_20Butler_20report/butler.html')
currentBuild.currentResult == 'FAILURE'
echo "Termiated due to Gitler assert" // For BFA
echo "You can read the detailed error report here: "+env.BUILD_URL+"Gitler_report/"
error 'Termiated due to Gitler assert'
echo "Terminated due to Butler assert" // For BFA
echo "You can read the detailed error report here: "+env.BUILD_URL+"The_20Butler_20report/"
error 'Terminated due to Butler assert'
} else {
config.pr.setBuildStatus(config, 'SUCCESS', 'Toll gate (Gitler)', 'Pass', '')
config.pr.setBuildStatus(config, 'SUCCESS', 'Toll gate (Butler)', 'Pass - Well done Sir!', '')
}
}

73 changes: 36 additions & 37 deletions .ci/gitler.sh → .ci/butler.sh
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ echo "No subjects with leading lower case characters<br>" > leading_lowercases.t
echo "No subjects with trailing periods<br>" > trailing_periods.txt
echo "No body lines are too wide<br>" > too_long_body_lines.txt
echo "No keywords are missing in keywords.txt<br>" > missing_keywords.txt
echo "No occurences of the deprecated boolean data type<br>" >> booleans.txt

too_long_subjects=`awk 'length > 72' subjects.txt`
if [ -n "$too_long_subjects" ]; then
@@ -48,56 +49,54 @@ if [ -n "$missing_keywords" ]; then
result=1
fi

# Evaluate if there exists booleans in the code tree (not counting this file)
if git grep -q boolean -- `git ls-files | grep -v butler.sh`; then
echo "<b>You have added at least one occurence of the deprecated boolean data type. Please use bool instead.</b><br>" > booleans.txt
result=1
fi

printf "%s" "<html>" > gitler.html
awk 'FNR==1{print "<br>"}1' too_long_subjects.txt leading_lowercases.txt trailing_periods.txt too_long_body_lines.txt missing_keywords.txt >> gitler.html
echo "<br>" >> gitler.html
printf "%s" "<html>" > butler.html
echo "Greetings Sir! Here is my evaluation of your pull request:<br>" >> butler.html
awk 'FNR==1{print "<br>"}1' too_long_subjects.txt leading_lowercases.txt trailing_periods.txt too_long_body_lines.txt missing_keywords.txt booleans.txt >> butler.html
echo "<br>" >> butler.html
if [ $result -ne 0 ]; then
echo "You should follow <a href="http://chris.beams.io/posts/git-commit">this guide</a> when writing your commit messages.<br>" >> gitler.html
echo "<br>" >> gitler.html
echo "To change the commit message for a single-commit pull request:<br>" >> gitler.html
echo "git checkout &lt;your_branch&gt;<br>" >> gitler.html
echo "git commit --amend<br>" >> gitler.html
echo "git push origin HEAD:&lt;your_branch_on_github&gt; -f<br>" >> gitler.html
echo "<br>" >> gitler.html
echo "To change the commit messages for a multiple-commit pull request:<br>" >> gitler.html
echo "git checkout &lt;your_branch&gt;<br>" >> gitler.html
echo "git rebase -i &lt;sha_of_parent_to_the_earliest_commit_you_want_to_change&gt;<br>" >> gitler.html
echo "Replace \"pick\" with \"r\" or \"reword\" on the commits you need to change message for<br>" >> gitler.html
echo "git push origin HEAD:&lt;your_branch_on_github&gt; -f<br>" >> gitler.html
echo "<br>" >> gitler.html
echo "<b>I am afraid there are some issues with your commit messages and/or use of keywords.</b><br>" >> butler.html
echo "I highly recommend reading <a href="http://chris.beams.io/posts/git-commit">this guide</a> for tips on how to write a good commit message.<br>" >> butler.html
echo "More specifically, MySensors have some <a href="https://www.mysensors.org/download/contributing">code contribution guidelines</a> that I am afraid all contributers need to follow.<br>" >> butler.html
echo "<br>" >> butler.html
echo "I can help guide you in how to change the commit message for a single-commit pull request:<br>" >> butler.html
echo "git checkout &lt;your_branch&gt;<br>" >> butler.html
echo "git commit --amend<br>" >> butler.html
echo "git push origin HEAD:&lt;your_branch_on_github&gt; -f<br>" >> butler.html
echo "<br>" >> butler.html
echo "To change the commit messages for a multiple-commit pull request:<br>" >> butler.html
echo "git checkout &lt;your_branch&gt;<br>" >> butler.html
echo "git rebase -i &lt;sha_of_parent_to_the_earliest_commit_you_want_to_change&gt;<br>" >> butler.html
echo "Replace \"pick\" with \"r\" or \"reword\" on the commits you need to change message for<br>" >> butler.html
echo "git push origin HEAD:&lt;your_branch_on_github&gt; -f<br>" >> butler.html
echo "<br>" >> butler.html
fi

# Evaluate coding style
astyle --options=.mystools/astyle/config/style.cfg -nq --recursive "*.h" "*.c" "*.cpp"
git diff > restyling.patch
if [ -s restyling.patch ]; then
echo "<b>This commit is not meeting the coding standards, a mail with a patch has been sent to you that if applied to your PR, will make it meet the coding standards.</b><br>" >> gitler.html
echo "You apply the patch using:<br>" >> gitler.html
echo "git apply restyling.patch<br>" >> gitler.html
echo "<br>" >> gitler.html
echo "I am afraid your coding style is not entirely in line with the MySensors preffered style.<b><br>A mail with a patch has been sent to you that, if applied to your PR, will make it follow the MySensors coding standards.</b><br>" >> butler.html
echo "You can apply the patch using:<br>" >> butler.html
echo "git apply restyling.patch<br>" >> butler.html
echo "<br>" >> butler.html
result=1
else
echo "This commit is meeting the coding standards, congratulations!<br>" >> gitler.html
echo "<br>" >> gitler.html
echo "This commit is meeting the coding standards, well done Sir!<br>" >> butler.html
echo "<br>" >> butler.html
rm restyling.patch
fi

# Evaluate if there exists booleans in the code tree (not counting this file)
if git grep -q boolean -- `git ls-files | grep -v gitler.sh`
then
echo "<b>This repository currently contain the boolean keyword. This should be avoided.</b><br>" >> gitler.html
echo "<br>" >> gitler.html
result=1
else
echo "This repository does not contain any boolean keywords. This is good.<br>" >> gitler.html
echo "<br>" >> gitler.html
fi

if [ $result -ne 0 ]; then
echo "<b>If you disagree to this, please discuss it in the GitHub pull request thread.</b><br>" >> gitler.html
echo "<br>" >> gitler.html
echo "If you have any questions, please first read the <a href="https://www.mysensors.org/download/contributing">code contribution guidelines</a>.</b><br>" >> butler.html
echo "<b>If you disagree to this, please discuss it in the GitHub pull request thread.</b><br>" >> butler.html
echo "<br>" >> butler.html
fi
echo "Yours sincerely, Gitler, on behalf of Jenkins<br>" >> gitler.html
printf "%s" "</html>" >> gitler.html
echo "Yours sincerely, The Butler, serving the MySensors community<br>" >> butler.html
printf "%s" "</html>" >> butler.html
exit $result
6 changes: 3 additions & 3 deletions .ci/linux.groovy
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ def buildSerial(config) {
buildLinux(config, '--my-debug=disable --my-transport=none --my-gateway=serial', 'Serial')
if (currentBuild.currentResult == 'UNSTABLE') {
config.pr.setBuildStatus(config, 'ERROR', 'Toll gate (Linux builds - Serial GW)', 'Warnings found', '${BUILD_URL}warnings28Result/new')
error 'Termiated due to warnings found'
error 'Terminated due to warnings found'
} else if (currentBuild.currentResult == 'FAILURE') {
config.pr.setBuildStatus(config, 'FAILURE', 'Toll gate (Linux builds - Serial GW)', 'Build error', '${BUILD_URL}')
} else {
@@ -47,7 +47,7 @@ def buildEthernet(config) {
buildLinux(config, '--my-debug=enable --my-transport=rs485 --my-gateway=ethernet', 'Ethernet')
if (currentBuild.currentResult == 'UNSTABLE') {
config.pr.setBuildStatus(config, 'ERROR', 'Toll gate (Linux builds - Ethernet GW)', 'Warnings found', '${BUILD_URL}warnings28Result/new')
error 'Termiated due to warnings found'
error 'Terminated due to warnings found'
} else if (currentBuild.currentResult == 'FAILURE') {
config.pr.setBuildStatus(config, 'FAILURE', 'Toll gate (Linux builds - Ethernet GW)', 'Build error', '${BUILD_URL}')
} else {
@@ -60,7 +60,7 @@ def buildMQTT(config) {
buildLinux(config, '--my-debug=disable --my-transport=none --my-gateway=mqtt', 'MQTT')
if (currentBuild.currentResult == 'UNSTABLE') {
config.pr.setBuildStatus(config, 'ERROR', 'Toll gate (Linux builds - MQTT GW)', 'Warnings found', '${BUILD_URL}warnings28Result/new')
error 'Termiated due to warnings found'
error 'Terminated due to warnings found'
} else if (currentBuild.currentResult == 'FAILURE') {
config.pr.setBuildStatus(config, 'FAILURE', 'Toll gate (Linux builds - MQTT GW)', 'Build error', '${BUILD_URL}')
} else {
Loading

0 comments on commit e64c432

Please sign in to comment.