Merge "Add puppet-lint support"

This commit is contained in:
Zuul 2018-12-27 15:23:18 +00:00 committed by Gerrit Code Review
commit e93026cc5c
5 changed files with 233 additions and 0 deletions

View File

@ -19,6 +19,8 @@
- cgtsclient-tox-py27
- cgtsclient-tox-pep8
- cgtsclient-tox-pylint
- puppet-manifests-lint
- puppet-modules-wrs-lint
gate:
jobs:
- build-openstack-api-ref
@ -34,6 +36,8 @@
- cgtsclient-tox-py27
- cgtsclient-tox-pep8
- cgtsclient-tox-pylint
- puppet-manifests-lint
- puppet-modules-wrs-lint
post:
jobs:
- publish-stx-api-ref
@ -198,3 +202,27 @@
vars:
tox_envlist: pylint
tox_extra_args: -c sysinv/cgts-client/cgts-client/tox.ini
- job:
name: puppet-manifests-lint
parent: tox
description: |
Run puppetlint test for puppet-manifests
files:
- puppet-manifests/*
pre-run: playbooks/tox-puppet-lint/pre.yaml
vars:
tox_envlist: puppetlint
tox_extra_args: -c puppet-manifests/tox.ini
- job:
name: puppet-modules-wrs-lint
parent: tox
description: |
Run puppetlint test for puppet-modules-wrs
files:
- puppet-modules-wrs/*
pre-run: playbooks/tox-puppet-lint/pre.yaml
vars:
tox_envlist: puppetlint
tox_extra_args: -c puppet-modules-wrs/tox.ini

View File

@ -0,0 +1,110 @@
# Job cloned from:
# https://github.com/openstack-infra/openstack-zuul-jobs/blob/master/playbooks/legacy/puppet-lint/run.yaml
# to install gem and puppet-lint in Zuul operating enviroment,
# before running puppet-lint within the tox.ini file. The only
# modification to this job is to not run puppet-lint here.
# Rather, it's left to the tox.ini to control what files are
# checked and what options are used (ie. to skip certain checks)
#
- hosts: all
name: Setup gem and puppet-lint for availability within tox
roles:
- bindep
tasks:
- name: Ensure legacy workspace directory
file:
path: '{{ ansible_user_dir }}/workspace'
state: directory
- shell:
cmd: |
set -e
set -x
CLONEMAP=`mktemp`
function cleanup {
# In cases where zuul-cloner is aborted during a git
# clone operation, git will remove the git work tree in
# its cleanup. The work tree in these jobs is the
# workspace directory, which means that subsequent
# jenkins post-build actions can not run because the
# workspace has been removed.
# To reduce the likelihood of this having an impact,
# recreate the workspace directory if needed
mkdir -p $WORKSPACE
rm -f $CLONEMAP
}
trap cleanup EXIT
cat > $CLONEMAP << EOF
clonemap:
- name: $ZUUL_PROJECT
dest: .
EOF
/usr/zuul-env/bin/zuul-cloner -m $CLONEMAP --cache-dir /opt/git \
git://git.openstack.org $ZUUL_PROJECT
executable: /bin/bash
chdir: '{{ ansible_user_dir }}/workspace'
environment: '{{ zuul | zuul_legacy_vars }}'
- shell:
cmd: |
set -e
set -x
if [ -f /usr/bin/yum ]; then
sudo yum -y remove rdo-release "centos-release-openstack-*" "centos-release-ceph-*"
sudo yum -y install libxml2-devel libxslt-devel ruby-devel zlib-devel
sudo yum -y groupinstall "Development Tools"
# Uninstall python-requests from pip, since we install it in
# system-config/install_puppet.sh
sudo pip uninstall requests -y || true
elif [ -f /usr/bin/apt-get ]; then
sudo apt-get update
sudo apt-get install -y libxml2-dev libxslt-dev ruby-dev zlib1g-dev
fi
executable: /bin/bash
chdir: '{{ ansible_user_dir }}/workspace'
environment: '{{ zuul | zuul_legacy_vars }}'
- shell:
cmd: |
set -x
sudo rm -f /etc/sudoers.d/zuul
# Prove that general sudo access is actually revoked
! sudo -n true
executable: /bin/bash
chdir: '{{ ansible_user_dir }}/workspace'
environment: '{{ zuul | zuul_legacy_vars }}'
- shell:
cmd: |
if [ -f Modulefile -o -f metadata.json ]; then
if [ -f Modulefile ]; then
MODULE=$(awk '/^name/ {print $NF}' Modulefile |tr -d \"\')
elif [ -f metadata.json ]; then
MODULE=$(python -c 'import json;print json.load(open("metadata.json"))["name"]')
fi
if [ -z "$MODULE" ]; then
echo "Module name not defined in Modulefile or metadata.json"
else
mkdir -p "$MODULE"
rsync -a --exclude="$MODULE" --exclude ".*" . "$MODULE"
cd "$MODULE"
fi
fi
mkdir .bundled_gems
export GEM_HOME=`pwd`/.bundled_gems
if [ -f Gemfile ]; then
gem install bundler --no-rdoc --no-ri --verbose
$GEM_HOME/bin/bundle install --without system_tests
# We'll run puppet-lint from tox
#$GEM_HOME/bin/bundle exec rake lint 2>&1
else
gem install rake -n ./.bundled_gems/
gem install puppet-lint
gem install puppetlabs_spec_helper
# We'll run puppet-lint from tox
#./.bundled_gems/rake lint 2>&1
fi
chdir: '{{ ansible_user_dir }}/workspace'
environment: '{{ zuul | zuul_legacy_vars }}'

49
puppet-manifests/tox.ini Normal file
View File

@ -0,0 +1,49 @@
#
# Copyright (c) 2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
# Tox (http://tox.testrun.org/) is a tool for running tests
# in multiple virtualenvs. This configuration file will run the
# test suite on all supported python versions. To use it, "pip install tox"
# and then run "tox" from this directory.
[tox]
toxworkdir = /tmp/{env:USER}_puppet-manifests
envlist = puppetlint
skipsdist = True
[testenv]
recreate = True
[testenv:puppetlint]
deps =
whitelist_externals =
gem
bash
setenv =
GEM_HOME = {envdir}
GEM_PATH = {envdir}
skip_tests = \
--no-140chars \
--no-2sp_soft_tabs \
--no-arrow_alignment \
--no-arrow_on_right_operand_line-check \
--no-autoloader_layout-check \
--no-case_without_default \
--no-documentation-check \
--no-double_quoted_strings-check \
--no-ensure_first_param \
--no-hard_tabs \
--no-inherits_across_namespaces \
--no-only_variable_string \
--no-parameter_order \
--no-quoted_booleans \
--no-single_quote_string_with_variables \
--no-trailing_whitespace \
--no-variable_is_lowercase-check \
--no-variables_not_enclosed
commands =
gem install --no-document puppet-lint
bash -c "find {toxinidir} -name \*.pp -print0 | xargs -0 puppet-lint {[testenv:puppetlint]skip_tests}"

View File

@ -0,0 +1,42 @@
#
# Copyright (c) 2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
# Tox (http://tox.testrun.org/) is a tool for running tests
# in multiple virtualenvs. This configuration file will run the
# test suite on all supported python versions. To use it, "pip install tox"
# and then run "tox" from this directory.
[tox]
toxworkdir = /tmp/{env:USER}_puppet-modules-wrs
envlist = puppetlint
skipsdist = True
[testenv]
recreate = True
[testenv:puppetlint]
deps =
whitelist_externals =
gem
bash
setenv =
GEM_HOME = {envdir}
GEM_PATH = {envdir}
skip_tests = \
--no-2sp_soft_tabs \
--no-arrow_alignment \
--no-arrow_on_right_operand_line-check \
--no-documentation-check \
--no-double_quoted_strings-check \
--no-hard_tabs \
--no-parameter_order \
--no-star_comments \
--no-trailing_whitespace \
--no-variable_scope \
--no-variables_not_enclosed
commands =
gem install --no-document puppet-lint
bash -c "find {toxinidir} -name \*.pp -print0 | xargs -0 puppet-lint {[testenv:puppetlint]skip_tests}"

View File

@ -57,6 +57,10 @@ description = Dummy environment to allow flake8 to be run in subdir tox
basepython = python3
description = Dummy environment to allow pylint to be run in subdir tox
[testenv:puppetlint]
basepython = python3
description = Dummy environment to allow puppetlint to be run in subdir tox
[testenv:api-ref]
basepython = python3
install_command = pip install -U {opts} {packages}