Skip to content

Commit

Permalink
Merge pull request #5 from chuckatkins/add-travis-matrix
Browse files Browse the repository at this point in the history
Prepare the travis run to use a matrix of options
  • Loading branch information
Chuck Atkins authored Dec 8, 2016
2 parents 03af3d6 + fd940b2 commit 2ff8853
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 27 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ install:
- tar -xf cmake-3.7.1-Linux-x86_64.tar.gz
- export PATH="${PWD}/cmake-3.7.1-Linux-x86_64/bin:${PATH}"
- pip install --user flake8
env:
- BUILD_MATRIX_ENTRY=format
script:
- cd ${TRAVIS_BUILD_DIR}
- scripts/travis/run-clang-format.sh
- ~/.local/bin/flake8 --config=flake8.cfg .
- ${TRAVIS_BUILD_DIR}/scripts/travis/run.sh

24 changes: 0 additions & 24 deletions scripts/travis/run-clang-format.sh

This file was deleted.

35 changes: 35 additions & 0 deletions scripts/travis/run-format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash

if [ -z "${SOURCE_DIR}" ]
then
echo "Error: SOURCE_DIR is empty or undefined"
exit 1
fi
if [ -z "${COMMIT_RANGE}" ]
then
echo "Error: COMMIT_RANGE is empty or undefined"
exit 1
fi

cd ${SOURCE_DIR}

# Check C and C++ code with clang-format
DIFF="$(./scripts/developer/git/git-clang-format --diff ${COMMIT_RANGE})"
if [ "${DIFF}" != "no modified files to format" ]
then
echo "clang-format:"
echo " Code format checks failed."
echo " Please run clang-format (or git clang-format) on your changes"
echo " before committing."
echo " The following changes are suggested:"
echo "${DIFF}"
exit 1
fi

# Check python code with flake8
if ! ~/.local/bin/flake8 --config=flake8.cfg .
then
exit 3
fi

exit 0
19 changes: 19 additions & 0 deletions scripts/travis/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash


export SOURCE_DIR=${TRAVIS_BUILD_DIR}
export BUILD_DIR=$(readlink -f ${SOURCE_DIR}/..)
export COMMIT_RANGE="${TRAVIS_COMMIT_RANGE/.../ }"

case ${BUILD_MATRIX_ENTRY} in
format)
echo "Running formatting tests"
if ! ${SOURCE_DIR}/scripts/travis/run-format.sh; then
exit 1;
fi
;;
*)
echo "Error: BUILD_MATRIX_ENTRY is undefined or set to an unknown value"
exit 1;
;;
esac

0 comments on commit 2ff8853

Please sign in to comment.