forked from operator-framework/community-operators
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck-pr
executable file
·38 lines (34 loc) · 1.06 KB
/
check-pr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env bash
set -e
DIRS=()
GIT_INFO=""
if [[ "$1" == "openshift" ]]; then
DIRS=( "community-operators" )
GIT_INFO=master
else
DIRS=( "upstream-community-operators" )
GIT_INFO="$TRAVIS_COMMIT_RANGE"
# Make sure the TRAVIS_COMMIT_RANGE is valid, by catching any errors and exiting.
if [[ -z "$GIT_INFO" ]] || ! git rev-list --quiet $GIT_INFO; then
echo "Invalid commit range."
exit 1
fi
fi
# Only run CI on changes to certain directories.
if git diff --name-only $GIT_INFO | grep -q '\.yaml'; then
IS_TESTABLE=1
for d in "${DIRS[@]}"; do
if git diff --name-only $GIT_INFO | grep -q "$d"; then
IS_TESTABLE=0
break
fi
done
if [[ $IS_TESTABLE -gt 0 ]]; then
echo "No testable operators or scripts were updated, not running the CI."
exit 0
fi
elif [[ "$1" == "openshift" ]] || ! git diff --name-only $GIT_INFO | grep -E -q '(\.travis\.yml)|(scripts/ci)|(scripts/lib)'; then
# Only run CI if an operator package or CI script was modified.
echo "No manifest or script files were updated, not running the CI."
exit 0
fi