Setup puppet-lint for new repo

This commit reintroduces the zuul jobs for running
puppet-lint in the new stx-puppet repo after the
restructuring work was completed.

Change-Id: I729135c04135ad66fcd1f24a52b9491fda35e1d2
Story: 2004515
Task: 36777
Signed-off-by: Don Penney <don.penney@windriver.com>
This commit is contained in:
Don Penney 2019-09-24 09:49:40 -04:00
parent 53051e82c9
commit b5f4eb4caa
5 changed files with 142 additions and 3 deletions

View File

@ -2,7 +2,15 @@
- project:
check:
jobs:
- openstack-tox-linters
- stx-puppet-linters
gate:
jobs:
- openstack-tox-linters
- stx-puppet-linters
- job:
name: stx-puppet-linters
parent: openstack-tox-linters
description: |
Run linters for stx-puppet
pre-run: playbooks/tox-puppet-lint/pre.yaml

34
modules/tox.ini Normal file
View File

@ -0,0 +1,34 @@
#
# Copyright (c) 2018-2019 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
envlist = puppetlint
skipsdist = True
[testenv]
recreate = True
[testenv:puppetlint]
# Note: centos developer env requires ruby-devel
# Ubuntu developer env requires ruby-dev
deps =
whitelist_externals =
gem
bash
setenv =
GEM_HOME = {envdir}
GEM_PATH = {envdir}
skip_tests = \
--no-documentation-check
commands =
gem install --no-document json puppet-lint
bash -c "find {toxinidir} -name \*.pp -print0 | xargs -0 puppet-lint --fail-on-warnings {[testenv:puppetlint]skip_tests}"

View File

@ -0,0 +1,81 @@
# Job cloned from:
# https://opendev.org/openstack/openstack-zuul-jobs/src/branch/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
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 --version '<2.0.0'
$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 }}'

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2018 Wind River Systems, Inc.
# Copyright (c) 2018-2019 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#

16
tox.ini
View File

@ -34,5 +34,21 @@ commands =
-e 'E*'"
[testenv:linters]
# Note: centos developer env requires ruby-devel
# Ubuntu developer env requires ruby-dev
whitelist_externals =
gem
bash
setenv =
GEM_HOME = {envdir}
GEM_PATH = {envdir}
skip_tests = \
--no-autoloader_layout-check \
--no-documentation-check
commands =
gem install --no-document json puppet-lint
bash -c "find {toxinidir}/puppet-manifests {toxinidir}/modules \
-name \*.pp -print0 \
| xargs -0 puppet-lint --fail-on-warnings {[testenv:linters]skip_tests}"
{[testenv:bashate]commands}