From 54c4715f1c7aa414dcb4d03be31936c4466eb4dc Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Wed, 20 Jul 2016 12:23:17 -0400 Subject: [PATCH] Add CI scripts Add CI scripts for: - lint - syntax 3 and 4 - unit - beaker Change-Id: I38dd2000996d20ebe51bd64fb831c5b352439eec --- functions | 16 ++++++++++++++++ run_beaker_tests.sh | 25 +++++++++++++++++++++++++ run_lint_tests.sh | 22 ++++++++++++++++++++++ run_syntax_tests.sh | 31 +++++++++++++++++++++++++++++++ run_unit_tests.sh | 22 ++++++++++++++++++++++ 5 files changed, 116 insertions(+) create mode 100644 functions create mode 100755 run_beaker_tests.sh create mode 100755 run_lint_tests.sh create mode 100755 run_syntax_tests.sh create mode 100755 run_unit_tests.sh diff --git a/functions b/functions new file mode 100644 index 0000000..15d3aad --- /dev/null +++ b/functions @@ -0,0 +1,16 @@ +#!/bin/bash +# +# functions - puppet-openstack_spec_helper specific functions +# + +install_module() { + 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-openstack-cookiecutter + else + git clone git://git.openstack.org/openstack/puppet-openstack-cookiecutter openstack/puppet-openstack-cookiecutter + fi + cd openstack/puppet-openstack-cookiecutter + source functions + prepare_environment +} diff --git a/run_beaker_tests.sh b/run_beaker_tests.sh new file mode 100755 index 0000000..9cfb5a2 --- /dev/null +++ b/run_beaker_tests.sh @@ -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 + +install_module + +# run beaker tests +export BEAKER_set=nodepool-centos7 +export BEAKER_debug=yes +export BEAKER_color=no +$GEM_HOME/bin/bundle exec rspec spec/acceptance diff --git a/run_lint_tests.sh b/run_lint_tests.sh new file mode 100755 index 0000000..51c7f8c --- /dev/null +++ b/run_lint_tests.sh @@ -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 + +install_module + +# run unit tests +$GEM_HOME/bin/bundle exec rake lint diff --git a/run_syntax_tests.sh b/run_syntax_tests.sh new file mode 100755 index 0000000..9b6cec3 --- /dev/null +++ b/run_syntax_tests.sh @@ -0,0 +1,31 @@ +#!/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} +PUPPET_MAJOR_VERSION=`echo $PUPPET_VERSION | cut -c 1` +export PUPPET_GEM_VERSION="~> $PUPPET_MAJOR_VERSION" +if [ "$PUPPET_MAJOR_VERSION" -lt "4" ]; then + export FUTURE_PARSER=${FUTURE_PARSER:-yes} +else + export FUTURE_PARSER=${FUTURE_PARSER:-no} +fi + +install_module + +# run unit tests +$GEM_HOME/bin/bundle exec rake syntax diff --git a/run_unit_tests.sh b/run_unit_tests.sh new file mode 100755 index 0000000..84150d0 --- /dev/null +++ b/run_unit_tests.sh @@ -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 + +install_module + +# run unit tests +$GEM_HOME/bin/bundle exec rake spec SPEC_OPTS='--format documentation'