Skip to content

Commit

Permalink
Do not check PRs with only file deletes
Browse files Browse the repository at this point in the history
- If FILES is empty, skip checking files
- Copyright check and line endings check

[skip ci]

Fixes Issue eclipse-openj9#323

Signed-off-by: Adam Brousseau <[email protected]>
  • Loading branch information
AdamBrousseau committed Oct 16, 2017
1 parent 282519e commit 75b93ba
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 74 deletions.
57 changes: 30 additions & 27 deletions buildenv/jenkins/copyrightCheck
Original file line number Diff line number Diff line change
Expand Up @@ -37,35 +37,38 @@ stage('Copyright Check') {
returnStdout: true
).trim()
echo FILES
def FILES_LIST = FILES.split("\\r?\\n")
DATE_YEAR = sh (
script: "date +%Y",
returnStdout: true
).trim()
FILES_LIST.each() {
println "Checking file: '${it}'"
RESULT = sh (
script: "grep -qE 'Copyright \\(c\\) ([0-9]{4}), ${DATE_YEAR} IBM Corp. and others' '${it}'",
returnStatus: true)
if(RESULT != 0) {
echo "FAILURE - Copyright date in file: '${it}' appears to be incorrect"
FAIL = true
BAD_FILES << "${it}"
} else {
echo "Copyright date in file: appears to be correct"
if (FILES == "") {
echo "There are no files to check for copyrights"
} else {
def FILES_LIST = FILES.split("\\r?\\n")
DATE_YEAR = sh (
script: "date +%Y",
returnStdout: true
).trim()
FILES_LIST.each() {
println "Checking file: '${it}'"
RESULT = sh (
script: "grep -qE 'Copyright \\(c\\) ([0-9]{4}), ${DATE_YEAR} IBM Corp. and others' '${it}'",
returnStatus: true)
if(RESULT != 0) {
echo "FAILURE - Copyright date in file: '${it}' appears to be incorrect"
FAIL = true
BAD_FILES << "${it}"
} else {
echo "Copyright date in file: appears to be correct"
}
}

}
if (FAIL) {
echo "${HASHES}"
echo "The following files were modified and have incorrect copyrights"
BAD_FILES.each() {
echo "${it}"
if (FAIL) {
echo "${HASHES}"
echo "The following files were modified and have incorrect copyrights"
BAD_FILES.each() {
echo "${it}"
}
echo "${HASHES}"
sh 'exit 1'
} else {
echo "All modified files appear to have correct copyrights"
}
echo "${HASHES}"
sh 'exit 1'
} else {
echo "All modified files appear to have correct copyrights"
}
}
}
Expand Down
98 changes: 51 additions & 47 deletions buildenv/jenkins/lineEndingsCheck
Original file line number Diff line number Diff line change
Expand Up @@ -37,56 +37,60 @@ stage('Line Endings Check') {
returnStdout: true
).trim()
echo FILES
def FILES_LIST = FILES.split("\\r?\\n")
FILES_LIST.each() {
println "Checking file: '${it}'"
TYPE = sh (
script: "file -b '${it}'",
returnStdout: true
).trim()
if (FILES == "") {
echo "There are no files to check for line endings"
} else {
def FILES_LIST = FILES.split("\\r?\\n")
FILES_LIST.each() {
println "Checking file: '${it}'"
TYPE = sh (
script: "file -b '${it}'",
returnStdout: true
).trim()

switch (TYPE) {
case ~/empty/:
echo "Empty file: '${it}'"
break
case ~/.*text.*/:
switch (it.toLowerCase()) {
case ~/.*\.bat|.*\.cmd/:
switch(TYPE) {
case ~/.*CRLF line terminators.*/:
echo "Good windows script: '${it}' type: '${TYPE}'"
break
default:
echo "ERROR - should have CRLF line terminators: '${it}' type: '${TYPE}'"
FAIL = true
BAD_FILES << "${it}"
}
default:
switch (TYPE) {
case ~/.*CR.* line terminators.*/:
echo "ERROR - should have LF line terminators: '${it}' type: '${TYPE}'"
FAIL = true
BAD_FILES << "${it}"
break
default:
echo "Good text file: '${it}' type: '${TYPE}'"
break
}
}
default:
echo "Non-text file: '${it}' type: '${TYPE}'"
switch (TYPE) {
case ~/empty/:
echo "Empty file: '${it}'"
break
case ~/.*text.*/:
switch (it.toLowerCase()) {
case ~/.*\.bat|.*\.cmd/:
switch(TYPE) {
case ~/.*CRLF line terminators.*/:
echo "Good windows script: '${it}' type: '${TYPE}'"
break
default:
echo "ERROR - should have CRLF line terminators: '${it}' type: '${TYPE}'"
FAIL = true
BAD_FILES << "${it}"
}
default:
switch (TYPE) {
case ~/.*CR.* line terminators.*/:
echo "ERROR - should have LF line terminators: '${it}' type: '${TYPE}'"
FAIL = true
BAD_FILES << "${it}"
break
default:
echo "Good text file: '${it}' type: '${TYPE}'"
break
}
}
default:
echo "Non-text file: '${it}' type: '${TYPE}'"
}
}
}
if (FAIL) {
echo "${HASHES}"
echo "The following files were modified and have incorrect line endings"
BAD_FILES.each() {
echo "${it}"
if (FAIL) {
echo "${HASHES}"
echo "The following files were modified and have incorrect line endings"
BAD_FILES.each() {
echo "${it}"
}
echo "${HASHES}"
sh 'exit 1'
} else {
echo "All modified files appear to have correct line endings"
}
echo "${HASHES}"
sh 'exit 1'
} else {
echo "All modified files appear to have correct line endings"
}
}
}
Expand Down

0 comments on commit 75b93ba

Please sign in to comment.