Add CI scripts

Add CI scripts for:
- lint
- syntax 3 and 4
- unit
- beaker

And remove run_tests.sh which is not useful anymore.

Change-Id: I235d8561d6cc2c593cf788ced04d1394127ab3ce
This commit is contained in:
Emilien Macchi 2016-07-20 12:08:13 -04:00
parent 15b9572dd8
commit 2366d14fd9
7 changed files with 122 additions and 44 deletions

View File

@ -105,8 +105,13 @@ popd
# Step 4: Retrieve the puppet-modulesync-configs directory and configure it for your need
#
git clone https://review.openstack.org/openstack/puppet-modulesync-configs
pushd puppet-modulesync-configs/
if [ -e /usr/zuul-env/bin/zuul-cloner ] ; then
/usr/zuul-env/bin/zuul-cloner --cache-dir /opt/git \
git://git.openstack.org openstack/puppet-modulesync-configs
else
git clone git://git.openstack.org/openstack/puppet-modulesync-configs openstack/puppet-modulesync-configs
fi
pushd openstack/puppet-modulesync-configs/
[ -z "${testing}" ] || ${GEM_HOME}/bin/bundle install
cat > managed_modules.yml <<EOF
---

16
functions Normal file
View File

@ -0,0 +1,16 @@
#!/bin/bash
#
# functions - puppet-openstack_spec_helper specific functions
#
prepare_environment() {
mkdir .bundled_gems
export GEM_HOME=`pwd`/.bundled_gems
gem install bundler --no-rdoc --no-ri --verbose
# Build fake module
OS_NEW_MODULE_TEST=yes bash -x ./contrib/bootstrap.sh whazz dummy
cd puppet-whazz/openstack/puppet-modulesync-configs/modules/puppet-whazz
$GEM_HOME/bin/bundle install
}

25
run_beaker_tests.sh Executable file
View File

@ -0,0 +1,25 @@
#!/bin/bash -ex
# Copyright 2015 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
export SCRIPT_DIR=$(cd `dirname $0` && pwd -P)
source $SCRIPT_DIR/functions
prepare_environment
# run beaker tests
export BEAKER_set=nodepool-centos7
export BEAKER_debug=yes
export BEAKER_color=no
$GEM_HOME/bin/bundle exec rspec spec/acceptance

22
run_lint_tests.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/bash -ex
# Copyright 2016 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
export SCRIPT_DIR=$(cd `dirname $0` && pwd -P)
source $SCRIPT_DIR/functions
prepare_environment
# run unit tests
$GEM_HOME/bin/bundle exec rake lint

30
run_syntax_tests.sh Executable file
View File

@ -0,0 +1,30 @@
#!/bin/bash -ex
# Copyright 2015 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
export SCRIPT_DIR=$(cd `dirname $0` && pwd -P)
source $SCRIPT_DIR/functions
export PUPPET_VERSION=${PUPPET_VERSION:-4}
export PUPPET_GEM_VERSION="~> $PUPPET_VERSION"
if [ "$PUPPET_VERSION" -lt "4" ]; then
export FUTURE_PARSER=${FUTURE_PARSER:-yes}
else
export FUTURE_PARSER=${FUTURE_PARSER:-no}
fi
prepare_environment
# run unit tests
$GEM_HOME/bin/bundle exec rake syntax

View File

@ -1,42 +0,0 @@
#!/bin/bash -ex
# Copyright 2016 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
export LANG=en_US.utf8
# Temporary, until we split jobs into different pieces:
WORKSPACE=`pwd`
if [[ $WORKSPACE =~ 'puppet-3' ]]; then
export PUPPET_GEM_VERSION='~> 3'
else
export PUPPET_GEM_VERSION='~> 4'
fi
mkdir .bundled_gems
export GEM_HOME=`pwd`/.bundled_gems
gem install bundler --no-rdoc --no-ri --verbose
# Build fake module
OS_NEW_MODULE_TEST=yes bash -x ./contrib/bootstrap.sh whazz dummy
cd puppet-whazz/puppet-modulesync-configs/modules/puppet-whazz
$GEM_HOME/bin/bundle install --retry 3
# lint tests
$GEM_HOME/bin/bundle exec rake lint
# Ruby files syntax tests
$GEM_HOME/bin/bundle exec rake validate
# Rspec tests
$GEM_HOME/bin/bundle exec rake spec

22
run_unit_tests.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/bash -ex
# Copyright 2015 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
export SCRIPT_DIR=$(cd `dirname $0` && pwd -P)
source $SCRIPT_DIR/functions
prepare_environment
# run unit tests
$GEM_HOME/bin/bundle exec rake spec SPEC_OPTS='--format documentation'