Add Zuul Project Files and other supporting files.
Add Zuul project files for automated testing. Test Pass: PASS - In local environment, test tox. 1. python -m venv venv 2. . ./venv/bin/activate. 3. pip install tox 4. tox 5. verify tox for flake8, py39, pylint, and bandit pass. Change-Id: I2b046b57371eb3a149dbc7eb03984a6c803336b8 Signed-off-by: Joshua Reed <joshua.reed@windriver.com>
This commit is contained in:
parent
4b82175d18
commit
26c30e6cfd
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Virtual Environment
|
||||||
|
venv/
|
||||||
|
env/
|
4
.gitreview
Normal file
4
.gitreview
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
[gerrit]
|
||||||
|
host=review.opendev.org
|
||||||
|
port=29418
|
||||||
|
project=starlingx/app-gen-tool.git
|
8
.yamllint
Normal file
8
.yamllint
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
extends: default
|
||||||
|
|
||||||
|
rules:
|
||||||
|
# 80 chars should be enough, but don't fail if a line is longer
|
||||||
|
line-length:
|
||||||
|
max: 200
|
||||||
|
level: warning
|
65
.zuul.yaml
Normal file
65
.zuul.yaml
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
---
|
||||||
|
- project:
|
||||||
|
vars:
|
||||||
|
ensure_tox_version: '<4'
|
||||||
|
check:
|
||||||
|
jobs:
|
||||||
|
- app-gen-tool-tox-py39
|
||||||
|
- app-gen-tool-tox-flake8
|
||||||
|
- app-gen-tool-tox-pylint
|
||||||
|
- app-gen-tool-tox-bandit
|
||||||
|
gate:
|
||||||
|
jobs:
|
||||||
|
- app-gen-tool-tox-py39
|
||||||
|
- app-gen-tool-tox-flake8
|
||||||
|
- app-gen-tool-tox-pylint
|
||||||
|
- app-gen-tool-tox-bandit
|
||||||
|
|
||||||
|
- job:
|
||||||
|
name: app-gen-tool-tox-py39
|
||||||
|
parent: tox-py39
|
||||||
|
description: |
|
||||||
|
Run py39 test for app-gen-tool
|
||||||
|
nodeset: debian-bullseye
|
||||||
|
files:
|
||||||
|
- ./*
|
||||||
|
vars:
|
||||||
|
tox_envlist: py39
|
||||||
|
python_version: 3.9
|
||||||
|
tox_extra_args: -c tox.ini
|
||||||
|
|
||||||
|
- job:
|
||||||
|
name: app-gen-tool-tox-flake8
|
||||||
|
parent: tox
|
||||||
|
description: |
|
||||||
|
Run flake8 test for app-gen-tool
|
||||||
|
nodeset: debian-bullseye
|
||||||
|
files:
|
||||||
|
- ./*
|
||||||
|
vars:
|
||||||
|
tox_envlist: flake8
|
||||||
|
tox_extra_args: -c tox.ini
|
||||||
|
|
||||||
|
- job:
|
||||||
|
name: app-gen-tool-tox-pylint
|
||||||
|
parent: tox
|
||||||
|
description: |
|
||||||
|
Run pylint test for app-gen-tool
|
||||||
|
nodeset: debian-bullseye
|
||||||
|
files:
|
||||||
|
- ./*
|
||||||
|
vars:
|
||||||
|
tox_envlist: pylint
|
||||||
|
tox_extra_args: -c tox.ini
|
||||||
|
|
||||||
|
- job:
|
||||||
|
name: app-gen-tool-tox-bandit
|
||||||
|
parent: tox
|
||||||
|
description: |
|
||||||
|
Run bandit test for app-gen-tool
|
||||||
|
nodeset: debian-bullseye
|
||||||
|
files:
|
||||||
|
- ./*
|
||||||
|
vars:
|
||||||
|
tox_envlist: bandit
|
||||||
|
tox_extra_args: -c tox.ini
|
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
PyYAML
|
5
test-requirements.txt
Normal file
5
test-requirements.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
hacking>=1.1.0,<=2.0.0 # Apache-2.0
|
||||||
|
bashate >= 0.2
|
||||||
|
PyYAML >= 3.1.0
|
||||||
|
shellcheck-py;python_version>="3.0" # MIT
|
||||||
|
yamllint<1.26.1;python_version>="3.0" # GPLv2
|
170
tox.ini
Normal file
170
tox.ini
Normal file
@ -0,0 +1,170 @@
|
|||||||
|
[tox]
|
||||||
|
envlist = linters
|
||||||
|
minversion = 2.3
|
||||||
|
skipsdist = True
|
||||||
|
|
||||||
|
[testenv]
|
||||||
|
install_command = pip install \
|
||||||
|
-c{env:UPPER_CONSTRAINTS_FILE:./requirements.txt} \
|
||||||
|
{opts} {packages}
|
||||||
|
setenv = VIRTUAL_ENV={envdir}
|
||||||
|
OS_STDOUT_CAPTURE=1
|
||||||
|
OS_STDERR_CAPTURE=1
|
||||||
|
OS_TEST_TIMEOUT=60
|
||||||
|
deps = -r{toxinidir}/test-requirements.txt
|
||||||
|
allowlist_externals = reno
|
||||||
|
|
||||||
|
|
||||||
|
[testenv:bashate]
|
||||||
|
basepython = python3
|
||||||
|
allowlist_externals = bash
|
||||||
|
# The following are suppressed:
|
||||||
|
# E006 Line too long
|
||||||
|
# E010 The "do" should be on same line as for
|
||||||
|
#
|
||||||
|
# Run bashate twice to handle shell scripts that do not end in .sh
|
||||||
|
# grep for ' shell' and not 'shell' to exclude files with shell in their name
|
||||||
|
# Several of the shell scripts that do not end in .sh have more suppressions
|
||||||
|
# E001 Trailing Whitespace
|
||||||
|
# E002 Tab indents
|
||||||
|
# E003 Indent not multiple of 4
|
||||||
|
# E011 Then keyword is not on same line as if or elif keyword
|
||||||
|
# E020 Function declaration not in format ^function name {$
|
||||||
|
# E042 local declaration hides errors
|
||||||
|
commands =
|
||||||
|
bash -c "find {toxinidir} \
|
||||||
|
-not \( -type d -name .?\* -prune \) \
|
||||||
|
-type f \
|
||||||
|
-not -name \*~ \
|
||||||
|
-not -name \*.md \
|
||||||
|
-name \*.sh \
|
||||||
|
-print0 | xargs -r -n 1 -0 bashate -v -e E* \
|
||||||
|
-i E006,E010"
|
||||||
|
bash -c "find {toxinidir} \
|
||||||
|
-not \( -type d -name .?\* -prune \) \
|
||||||
|
-type f \
|
||||||
|
-not -name \*~ \
|
||||||
|
-not -name \*.md \
|
||||||
|
\( -exec bash -c 'file \{\} | grep -q :.*shell' \; \
|
||||||
|
-a ! -name '*.sh' \) \
|
||||||
|
-print0 | xargs -r -n 1 -0 bashate -v -e E* \
|
||||||
|
-i E001,E002,E003,E006,E010,E011,E020,E042"
|
||||||
|
|
||||||
|
[testenv:yamllint]
|
||||||
|
basepython = python3
|
||||||
|
allowlist_externals = bash
|
||||||
|
commands =
|
||||||
|
bash -c "find {toxinidir} \
|
||||||
|
-name .tox -prune \
|
||||||
|
-o -type f -name '*.yaml' \
|
||||||
|
-print0 | xargs -0 yamllint -f parsable \
|
||||||
|
-c {toxinidir}/.yamllint"
|
||||||
|
|
||||||
|
[testenv:shellcheck]
|
||||||
|
basepython = python3
|
||||||
|
allowlist_externals = bash
|
||||||
|
# The following shellcheck errors are suppressed:
|
||||||
|
# SC1091: Not following: ./bin/activate was not specified as input (see shellcheck -x).
|
||||||
|
# SC2001: See if you can use ${variable//search/replace} instead.
|
||||||
|
# SC2002: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.
|
||||||
|
# SC2004: $/${} is unnecessary on arithmetic variables.
|
||||||
|
# SC2006: Use $(...) notation instead of legacy backticked `...`.
|
||||||
|
# SC2034: variable appears unused. Verify use (or export if used externally).
|
||||||
|
# SC2046: Quote this to prevent word splitting.
|
||||||
|
# SC2064: Use single quotes, otherwise this expands now rather than when signalled.
|
||||||
|
# SC2086: Double quote to prevent globbing and word splitting.
|
||||||
|
# SC2119: Use remove_tmp "$@" if function's $1 should mean script's $1.
|
||||||
|
# SC2120: remove_tmp references arguments, but none are ever passed.
|
||||||
|
# SC2154: variable is referenced but not assigned.
|
||||||
|
# SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.
|
||||||
|
# SC2181: Check exit code directly with e.g. 'if mycmd;', not indirectly with $?.
|
||||||
|
# SC2207: Prefer mapfile or read -a to split command output (or quote to avoid splitting).
|
||||||
|
# SC2231: Quote expansions in this for loop glob to prevent wordsplitting, e.g. "$dir"/*.txt .
|
||||||
|
# SC2236: Use -n instead of ! -z
|
||||||
|
# SC2268: Avoid x-prefix in comparisons as it no longer serves a purpose.
|
||||||
|
# SC2320: This $? refers to echo/printf, not a previous command.
|
||||||
|
#
|
||||||
|
# Run bashate twice to handle shell scripts that do not end in .sh
|
||||||
|
# grep for ' shell' and not 'shell' to exclude files with shell in their name
|
||||||
|
# The non .sh files have these additional suppressions:
|
||||||
|
# SC1001: This \= will be a regular '=' in this context.
|
||||||
|
# SC1009: The mentioned syntax error was in this if expression.
|
||||||
|
# SC1035: You need a space after the [[ and before the ]].
|
||||||
|
# SC1072: Expected test to end here (don't wrap commands in []/[[]]).
|
||||||
|
# SC1073: Couldn't parse this test expression. Fix to allow more checks.
|
||||||
|
# SC1090: ShellCheck can't follow non-constant source. Use a directive to specify location.
|
||||||
|
# SC2003: expr is antiquated. Consider rewriting this using $((..)), ${} or [[ ]].
|
||||||
|
# SC2009: Consider using pgrep instead of grepping ps output.
|
||||||
|
# SC2015: Note that A && B || C is not if-then-else. C may run when A is true.
|
||||||
|
# SC2069: To redirect stdout+stderr, 2>&1 must be last
|
||||||
|
# SC2112: 'function' keyword is non-standard. Delete it.
|
||||||
|
# SC2155: Declare and assign separately to avoid masking return values
|
||||||
|
# SC2168: 'local' is only valid in functions.
|
||||||
|
# SC2219: Instead of 'let expr', prefer (( expr )) .
|
||||||
|
# SC2223: This default assignment may cause DoS due to globbing. Quote it.
|
||||||
|
# SC2317: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).
|
||||||
|
# SC3005: In POSIX sh, arithmetic for loops are undefined.
|
||||||
|
# SC3018: In POSIX sh, ++ is undefined.
|
||||||
|
# SC3020: In POSIX sh, &> is undefined.
|
||||||
|
# SC3037: In POSIX sh, echo flags are undefined.
|
||||||
|
# SC3039: In POSIX sh, 'let' is undefined.
|
||||||
|
# SC3043: In POSIX sh, 'local' is undefined.
|
||||||
|
commands =
|
||||||
|
bash -c "find {toxinidir} \
|
||||||
|
-not \( -type d -name .?\* -prune \) \
|
||||||
|
-type f \
|
||||||
|
-not -name \*~ \
|
||||||
|
-not -name \*.md \
|
||||||
|
-name \*.sh \
|
||||||
|
-print0 | xargs -r -n 1 -0 shellcheck \
|
||||||
|
-eSC1091 -eSC2001 -eSC2002 -eSC2004 -eSC2006 -eSC2034 \
|
||||||
|
-eSC2046 -eSC2064 -eSC2086 -eSC2119 -eSC2120 -eSC2154 \
|
||||||
|
-eSC2166 -eSC2181 -eSC2207 -eSC2231 -eSC2236 -eSC2268 \
|
||||||
|
-eSC2320"
|
||||||
|
bash -c "find {toxinidir} \
|
||||||
|
-not \( -type d -name .?\* -prune \) \
|
||||||
|
-type f \
|
||||||
|
-not -name \*~ \
|
||||||
|
-not -name \*.md \
|
||||||
|
\( -exec bash -c 'file \{\} | grep -q :.*shell' \; \
|
||||||
|
-a ! -name '*.sh' \) \
|
||||||
|
-print0 | xargs -r -n 1 -0 shellcheck \
|
||||||
|
-eSC1091 -eSC2001 -eSC2002 -eSC2004 -eSC2006 -eSC2034 \
|
||||||
|
-eSC2046 -eSC2064 -eSC2086 -eSC2119 -eSC2120 -eSC2154 \
|
||||||
|
-eSC2166 -eSC2181 -eSC2207 -eSC2231 -eSC2236 -eSC2268 \
|
||||||
|
-eSC1001 -eSC1009 -eSC1035 -eSC1072 -eSC1073 -eSC1090 \
|
||||||
|
-eSC2003 -eSC2009 -eSC2015 -eSC2069 -eSC2112 -eSC2155 \
|
||||||
|
-eSC2168 -eSC2219 -eSC2223 -eSC2317 -eSC3005 -eSC3018 \
|
||||||
|
-eSC3020 -eSC3037 -eSC3039 -eSC3043"
|
||||||
|
|
||||||
|
[testenv:linters]
|
||||||
|
basepython = python3
|
||||||
|
allowlist_externals = bash
|
||||||
|
commands =
|
||||||
|
{[testenv:bashate]commands}
|
||||||
|
{[testenv:yamllint]commands}
|
||||||
|
{[testenv:shellcheck]commands}
|
||||||
|
|
||||||
|
[testenv:pep8]
|
||||||
|
basepython = python3
|
||||||
|
usedevelop = False
|
||||||
|
skip_install = True
|
||||||
|
deps = -r{toxinidir}/test-requirements.txt
|
||||||
|
commands =
|
||||||
|
flake8
|
||||||
|
|
||||||
|
[testenv:venv]
|
||||||
|
basepython = python3
|
||||||
|
commands = {posargs}
|
||||||
|
|
||||||
|
[testenv:flake8]
|
||||||
|
basepython = python3
|
||||||
|
description = Dummy environment to allow flake8 to be run in subdir tox
|
||||||
|
|
||||||
|
[testenv:pylint]
|
||||||
|
basepython = python3
|
||||||
|
description = Dummy environment to allow pylint to be run in subdir tox
|
||||||
|
|
||||||
|
[testenv:bandit]
|
||||||
|
basepython = python3
|
||||||
|
description = Dummy environment to allow bandit to be run in subdir tox
|
Loading…
Reference in New Issue
Block a user