MT#16391 Support --ignore-branch-check option in build/check actions

This option is essential if we're testing from within the git
repository and aren't standing on active 'master' branch.

Change-Id: I75b62d071116313317c69ad496e4425d6e98ad5a
changes/19/7419/5
Michael Prokop 10 years ago
parent 8a6053a104
commit e06c458e22

@ -248,20 +248,24 @@ need to be committed, then the commit message needs to be provided. This is
meant so the configuration change history (accessible e.g. via 'ngcpcfg log')
provides useful information.
**check** [<config_files_or_directories>|<pattern>]::
**check** [--ignore-branch-check] [<config_files_or_directories>|<pattern>]::
Check syntax of YAML files and validate schema before performing any further actions.
The *--ignore-branch-check* option doesn't fail the check if the
current active branch doesn't match 'master'.
In the High Availability setup possibly outstanding pull actions are
checked as well.
**build** [--modified-only] [<files_or_directories>|<pattern>]::
**build** [--ignore-branch-check] [--modified-only] [<files_or_directories>|<pattern>]::
Generate configuration files, based on values defined the central yml files and
based on the templates in the configuration tree (/etc/ngcp-config/templates by
default). Central yml files will be validated for integrity before building using
_check_ action. The *--modified-only* option checks for _modified_ and _uncommitted_
configuration files (central yml files and templates) and builds the relevant
files only. If a central yml file is modified it builds all configuration files.
files only. The *--ignore-branch-check* option doesn't fail the build if the
current active branch doesn't match 'master'.
If a central yml file is modified it builds all configuration files.
If changes are in template files only just the according template files are
considered for rebuild. If a file (e.g. _/etc/rsyslog.conf_) or directory (e.g.
_/etc/mysql/_) is provided as argument to the _build_ option only the specified

@ -18,16 +18,24 @@ fi
. "${FUNCTIONS}"/main
# Sanity check the YAML and schema files.
"${SCRIPTS}"/check
MODIFIED_ONLY=false
CHECK_BRANCH=true
if [ -n "${1:-}" ] ; then
case "$1" in
*--modified-only*) MODIFIED_ONLY=true ; shift ;;
*--ignore-branch-check*) CHECK_BRANCH=false ; shift ;;
esac
fi
# Sanity check the YAML and schema files.
# NOTE: we can't blindly pass "$@" to the check script,
# so explicitely check and add option as needed
if "$CHECK_BRANCH" ; then
"${SCRIPTS}"/check
else
"${SCRIPTS}"/check --ignore-branch-check
fi
# Kill all previous started tt2-daemon Perl processes if they were not stopped properly
killall tt2-daemon 2>/dev/null || true
rm -f /var/run/ngcpcfg.port

@ -16,7 +16,27 @@ fi
. "${FUNCTIONS}"/main
usage() {
printf "ngcpcfg build -- supported command line options:
--ignore-branch-check - do not fail build if branch doesn't match 'master'\n\n"
}
CHECK_BRANCH=true
while [ -n "${1:-}" ] ; do
case "$1" in
*--ignore-branch-check*) CHECK_BRANCH=false ; shift ;;
*--help*) usage ; exit 0 ;;
*) break ;;
esac
done
check_branch() {
if ! $CHECK_BRANCH ; then
log_info "Option --ignore-branch-check is enabled, not checking for branch 'master'."
return 0
fi
local current_branch=$(compare_active_branch 'master')
if [ "$current_branch" = 'master' ] ; then
log_debug "Current branch is 'master', continuing."

Loading…
Cancel
Save