forked from privacyidea/privacyidea
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis_check.sh
executable file
·68 lines (57 loc) · 1.52 KB
/
.travis_check.sh
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
set -ev
# setup patterns for files/directories to ignore
declare -a ignore_patterns
ignore_patterns=(
"^doc/"
"^privacyidea/static/"
"^privacyidea/translations/"
"^migrations/"
"^deploy/"
"^contrib/"
"READ_BEFORE_UPDATE.md"
"README.rst"
"SECURITY.md"
"^\.circleci/"
"^\.codespell_skip"
"^\.github/"
"^\.gitignore"
"^\.pep8speaks.yml"
"^\.readthedocs.yaml"
)
# get the base branch for checking changes
if [[ $TRAVIS_PULL_REQUEST == false ]]; then
base_branch="master"
else
base_branch=${TRAVIS_BRANCH}
fi
echo "base_branch: $base_branch"
echo "travis pull request: $TRAVIS_PULL_REQUEST"
git remote set-branches --add origin "${base_branch}"
git fetch
git update-ref "${base_branch}" "origin/${base_branch}"
CHANGED_FILES=$( git diff --name-only --diff-filter=AM "${base_branch}"...HEAD )
echo "Changed Files: ${CHANGED_FILES}"
IGNORE_BUILD=True
for CHANGED_FILE in ${CHANGED_FILES}; do
match_found=False
for pattern in "${ignore_patterns[@]}"; do
if [[ ${CHANGED_FILE} =~ ${pattern} ]]; then
match_found=True
echo "Match found! Changed file: $CHANGED_FILE, pattern: $pattern"
break
fi
done
if [[ ${match_found} == False ]]; then
IGNORE_BUILD=False
echo "Found a test-relevant file: $CHANGED_FILE. Executing tests."
break
fi
done
echo "IGNORE_BUILD: $IGNORE_BUILD"
if [[ ${IGNORE_BUILD} == True ]]; then
echo "No changes to build-essential files found, exiting."
exit 123
else
echo "Changes to build-essential files found, continuing with tests."
fi