Skip to content
Permalink
Browse files

Merge pull request #1953 from privacyidea/travis_skip_build_script

Check if travis needs to run
  • Loading branch information
cornelinux committed Dec 3, 2019
2 parents 6c839c4 + ea67081 commit 9ade949455f1e6a424904529582f417b16cb624b
Showing with 64 additions and 1 deletion.
  1. 0 .gitmodules
  2. +6 −1 .travis.yml
  3. +58 −0 .travis_check.sh
No changes.
@@ -6,10 +6,15 @@ python:
- "3.5"
- "3.6"
- "3.7"

# check if we need to run travis
before_install: ./.travis_check.sh; ret=$?; if [ $ret -eq 123 ]; then travis_terminate 0; elif [
$ret -ne 0 ]; then travis_terminate $ret; fi

# command to install dependencies
install:
- "pip install ."
- "pip install -r tests/requirements.txt"
- "pip install ."
- "pip install codecov"

# split the test run according to
@@ -0,0 +1,58 @@
#!/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/"
)

# 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

0 comments on commit 9ade949

Please sign in to comment.
You can’t perform that action at this time.