-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix skipping test on mergify merge commit using bash
- Loading branch information
1 parent
8c8456b
commit 4e7edf5
Showing
2 changed files
with
51 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
# Everything that is normally printed to `stdout` in the script will be redirected to `stderr` | ||
# which will be visible in tty/Travis log. | ||
# Outputs that is printed to `fd 3` will be redirected to `stdout`, | ||
# which will be finally assigned to a variable `$SKIP` | ||
exec 3>&1 1>&2 # fd 3 = fd 1; fd 1 = fd 2 | ||
|
||
function return_to_travis { | ||
STRATEGY="${1}" | ||
echo ${STRATEGY} >&3 | ||
exit 0 | ||
} | ||
function skip_travis { return_to_travis "skip" ; } | ||
function noskip_travis { return_to_travis "noskip" ; } | ||
|
||
echo "Event type ${TRAVIS_EVENT_TYPE}" | ||
echo "Branch: ${TRAVIS_EVENT_TYPE}" | ||
echo "Commit: ${TRAVIS_COMMIT}" | ||
|
||
case ${TRAVIS_EVENT_TYPE} in | ||
push) | ||
if [[ "${TRAVIS_BRANCH}" = master ]] | ||
then | ||
echo "Push on master" | ||
else | ||
echo "Don't skip testing for other than master" | ||
noskip_travis | ||
fi | ||
;; | ||
*) | ||
echo "Don't skip for PR, api, cron event" | ||
noskip_travis | ||
;; | ||
esac | ||
|
||
MERGIFY_COMMITTER="mergify[bot] <mergify[bot]@users.noreply.github.com>" | ||
COMMITTER=`git show --format="%cN <%cE>" --no-patch "${TRAVIS_COMMIT}"` | ||
|
||
if [[ "${COMMITTER}" = "${MERGIFY_COMMITTER}" ]] | ||
then | ||
echo "Skip check since it was checked in other PR" | ||
skip_travis | ||
else | ||
noskip_travis | ||
fi |