Skip to content

Commit

Permalink
M #-: Add Travis test for conf branch protection
Browse files Browse the repository at this point in the history
OpenNebula maintenance and hotfix revisions do not allow for any
change in their configuration files with respect to their
previous version.

In a minor branch (one-XX), the new 01-conf_branch_protect.sh script
will warn about configuration changes.
  • Loading branch information
tinova committed May 24, 2019
1 parent beb85ef commit c53b101
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .travis/tests/01-conf_branch_protect.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash -xv

# **previous** refers to the code base in the main repository
# **current** refers to the code base of the PR (or the new commit)

if [[ $TRAVIS_BRANCH =~ (^one-) ]]; then
export PREVIOUS_ONE=~/previous.one
export CURRENT_ONE=$TRAVIS_BUILD_DIR
export PREVIOUS_ONE_INSTALL=~/previous.install
export CURRENT_ONE_INSTALL=~/current.install

# Checkout previous code base
git clone https://github.com/tinova/one $PREVIOUS_ONE
(cd $PREVIOUS_ONE ; git checkout $TRAVIS_BRANCH)
# In a PR we compare with the head of $TRAVIS_BRANCH
# Otherwise, we want to check with the previous commit
if [[ $TRAVIS_PULL_REQUEST == false ]]; then
(cd $PREVIOUS_ONE ; git checkout HEAD~1)
fi

# Debug information
echo "Previous commit:"
(cd $PREVIOUS_ONE ; git --no-pager log -1)
echo "----------------"
echo "Current commit:"
(cd $CURRENT_ONE ; git --no-pager log -1)
echo "----------------"

# Install previous and current code base
(cd $PREVIOUS_ONE ; ./install.sh -d $PREVIOUS_ONE_INSTALL &> /dev/null)
(cd $CURRENT_ONE ; ./install.sh -d $CURRENT_ONE_INSTALL &> /dev/null)

echo "Testing conf changes:"
diff -r $PREVIOUS_ONE_INSTALL/etc $CURRENT_ONE_INSTALL/etc
rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi
diff -r $PREVIOUS_ONE_INSTALL/var/remotes/etc $CURRENT_ONE_INSTALL/var/remotes/etc
rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi
fi

exit 0
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit c53b101

Please sign in to comment.