commit
3a7635eb82
53
test.sh
53
test.sh
|
|
@ -25,7 +25,7 @@ TESTDIRS="analysis \
|
||||||
# Assume first it's the travis commit (for builds of master), unless we're
|
# Assume first it's the travis commit (for builds of master), unless we're
|
||||||
# a PR, when it's actually the first parent.
|
# a PR, when it's actually the first parent.
|
||||||
TRIGGER_COMMIT=${TRAVIS_COMMIT}
|
TRIGGER_COMMIT=${TRAVIS_COMMIT}
|
||||||
if [ "${TRAVIS_PULL_REQUEST}" != "false" ] ; then
|
if [ "x${TRAVIS_PULL_REQUEST}" != "x" ] ; then
|
||||||
revs=$(git rev-list --parents -n 1 HEAD)
|
revs=$(git rev-list --parents -n 1 HEAD)
|
||||||
# The trigger commit is the last ID in the space-delimited rev-list
|
# The trigger commit is the last ID in the space-delimited rev-list
|
||||||
TRIGGER_COMMIT=${revs##* }
|
TRIGGER_COMMIT=${revs##* }
|
||||||
|
|
@ -53,33 +53,33 @@ update_status() {
|
||||||
}
|
}
|
||||||
|
|
||||||
run() {
|
run() {
|
||||||
echo "$*"
|
echo "$@"
|
||||||
$* 2>&1
|
"$@" 2>&1
|
||||||
local status=$?
|
local status=$?
|
||||||
|
|
||||||
if [ ${status} -eq 0 ]; then
|
if [ ${status} -eq 0 ]; then
|
||||||
update_status --state success
|
update_status --state success
|
||||||
echo "Success: $*"
|
echo "Success: $@"
|
||||||
else
|
else
|
||||||
FAILURE=1
|
FAILURE=1
|
||||||
update_status --state failure
|
update_status --state failure
|
||||||
echo "[!] FAILURE: $*"
|
echo "[!] FAILURE: $@"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return ${status}
|
return ${status}
|
||||||
}
|
}
|
||||||
|
|
||||||
run_and_comment() {
|
run_and_comment() {
|
||||||
if [ "x${TRAVIS}" = "x" ] || [ "${TRAVIS_PULL_REQUEST}" == "false" ] || [ ! -f "${GITHUB_SECRET_FILE}"] ; then
|
if [ "x${TRAVIS}" = "x" ] || [ "${TRAVIS_PULL_REQUEST}" == "false" ] || [ ! -f "${GITHUB_SECRET_FILE}" ] ; then
|
||||||
run $*
|
run "$@"
|
||||||
else
|
else
|
||||||
result=$(run $*)
|
result=$(run "$@")
|
||||||
local status=$?
|
local status=$?
|
||||||
# Only send a comment if exit code > 0
|
# Only send a comment if exit code > 0
|
||||||
if [ ${status} -ne 0 ] ; then
|
if [ ${status} -ne 0 ] ; then
|
||||||
echo $'```\n'${result}$'\n```' | github-pr-status --authfile $GITHUB_SECRET_FILE \
|
echo $'```\n'${result}$'\n```' | github-pr-status --authfile $GITHUB_SECRET_FILE \
|
||||||
--owner "letsencrypt" --repo "boulder" \
|
--owner "letsencrypt" --repo "boulder" \
|
||||||
comment --pr ${TRAVIS_PULL_REQUEST}
|
comment --pr "${TRAVIS_PULL_REQUEST}" -b -
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
@ -168,29 +168,26 @@ end_context #test/golint
|
||||||
# Ensure all files are formatted per the `go fmt` tool
|
# Ensure all files are formatted per the `go fmt` tool
|
||||||
#
|
#
|
||||||
start_context "test/gofmt"
|
start_context "test/gofmt"
|
||||||
unformatted=$(find . -name "*.go" -not -path "./Godeps/*" -print | xargs -n1 gofmt -l)
|
check_gofmt() {
|
||||||
if [ "x${unformatted}" == "x" ] ; then
|
unformatted=$(find . -name "*.go" -not -path "./Godeps/*" -print | xargs -n1 gofmt -l)
|
||||||
update_status --state success
|
if [ "x${unformatted}" == "x" ] ; then
|
||||||
else
|
return 0
|
||||||
|
else
|
||||||
|
V="Unformatted files found.
|
||||||
|
Please run 'go fmt' on each of these files and amend your commit to continue."
|
||||||
|
|
||||||
V="Unformatted files found.
|
for f in ${unformatted}; do
|
||||||
Please run 'go fmt' on each of these files and amend your commit to continue."
|
V=$(printf "%s\n - %s" "${V}" "${f}")
|
||||||
|
done
|
||||||
|
|
||||||
for f in ${unformatted}; do
|
# Print to stdout
|
||||||
V=$(printf "%s\n - %s" "${V}" "${f}")
|
printf "%s\n\n" "${V}"
|
||||||
done
|
[ "${TRAVIS}" == "true" ] || exit 1 # Stop here if running locally
|
||||||
|
return 1
|
||||||
# Print to stdout
|
|
||||||
printf "%s\n\n" "${V}"
|
|
||||||
update_status --state failure --description "${V}"
|
|
||||||
|
|
||||||
# Post a comment with the unformatted list
|
|
||||||
if [ "${TRAVIS_PULL_REQUEST}" != "false" ] ; then
|
|
||||||
run_and_comment printf "%s\n\n" "${V}"
|
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
[ "${TRAVIS}" == "true" ] || exit 1 # Stop here if running locally
|
run_and_comment check_gofmt
|
||||||
fi
|
|
||||||
end_context #test/gofmt
|
end_context #test/gofmt
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue