Skip to content

Commit 5829673

Browse files
committed
RHELPLAN-56588 - sync collections related changes from template to storage role
- Adding .travis/runcollection.sh. - Enabling collection as part of tox/travis tests.
1 parent 1c54c25 commit 5829673

File tree

3 files changed

+75
-3
lines changed

3 files changed

+75
-3
lines changed

.travis/runcollection.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: MIT
3+
4+
set -e
5+
6+
#uncomment if you use $ME - otherwise set in utils.sh
7+
#ME=$(basename "$0")
8+
SCRIPTDIR=$(readlink -f "$(dirname "$0")")
9+
10+
. "${SCRIPTDIR}/utils.sh"
11+
. "${SCRIPTDIR}/config.sh"
12+
13+
# Collection commands that are run when `tox -e collection`:
14+
role=$(basename "${TOPDIR}")
15+
toxworkdir=${1:-"${TOPDIR}"/.tox}
16+
STABLE_TAG=${2:-master}
17+
cd "${toxworkdir}"
18+
toxworkdir=$(pwd)
19+
envlist=${3:- "black,flake8,yamllint,py38,shellcheck"}
20+
automaintenancerepo=https://raw.githubusercontent.com/linux-system-roles/auto-maintenance/
21+
22+
curl -L -o lsr_role2collection.py "${automaintenancerepo}${STABLE_TAG}"/lsr_role2collection.py
23+
24+
python lsr_role2collection.py --src-path "${TOPDIR}/.." --dest-path "${toxworkdir}" --role "${role}" > "${toxworkdir}"/collection.out 2>&1
25+
26+
yamllint="${toxworkdir}"/ansible_collections/fedora/system_roles/.yamllint_defaults.yml
27+
sed -i -e 's/\( *\)\(document-start: disable\)/\1\2\n\1line-length:\n\1\1level: warning/' "${yamllint}"
28+
29+
cd ansible_collections/fedora/system_roles
30+
tox -e "${envlist}" 2>&1 | tee "${toxworkdir}"/collection.tox.out || :
31+
32+
rm -rf "${toxworkdir}"/auto-maintenance "${toxworkdir}"/ansible_collections
33+
cd "${TOPDIR}"
34+
res=$(grep "^ERROR: .*failed" "${toxworkdir}"/collection.tox.out || :)
35+
if [ "$res" != "" ]; then
36+
lsr_error "${ME}: tox in the converted collection format failed."
37+
exit 1
38+
fi

.travis/utils.sh

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,21 @@ function lsr_venv_python_matches_system_python() {
172172
lsr_compare_pythons "${1:-python}" -eq "$syspython"
173173
}
174174

175+
function run_setup_module_utils() {
176+
local srcdir
177+
srcdir="$1"
178+
local destdir
179+
destdir="$2"
180+
if [ -x "$TOPDIR/tests/setup_module_utils.sh" ]; then
181+
bash "$TOPDIR/tests/setup_module_utils.sh" "$srcdir" "$destdir"
182+
else
183+
setup_module_util=$( find "$TOPDIR"/tests -name "setup_module_utils.sh" | head -n 1 )
184+
if [ "$setup_module_util" != "" ]; then
185+
bash "$setup_module_util" "$srcdir" "$destdir"
186+
fi
187+
fi
188+
}
189+
175190
##
176191
# lsr_setup_module_utils [$1] [$2]
177192
#
@@ -189,7 +204,16 @@ function lsr_setup_module_utils() {
189204
local destdir
190205
destdir="${2:-$DEST_MODULE_UTILS_DIR}"
191206
if [ -n "$srcdir" ] && [ -d "$srcdir" ] && [ -n "$destdir" ] && [ -d "$destdir" ]; then
192-
bash "$TOPDIR/tests/setup_module_utils.sh" "$srcdir" "$destdir"
207+
run_setup_module_utils "$srcdir" "$destdir"
208+
else
209+
srcdir="${SRC_COLL_MODULE_UTILS_DIR}"
210+
destdir="${DEST_COLL_MODULE_UTILS_DIR}"
211+
if [ -n "$destdir" ] && [ -d "$destdir" ]; then
212+
if [ -n "$srcdir" ] && [ ! -d "$srcdir" ]; then
213+
mkdir -p "$srcdir"
214+
fi
215+
run_setup_module_utils "$srcdir" "$destdir"
216+
fi
193217
fi
194218
}
195219

tox.ini

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
envlist =
44
black, pylint, flake8, yamllint
55
py{26,27,36,37,38}, shellcheck
6-
custom
6+
collection, custom
77
skipsdist = true
88
skip_missing_interpreters = true
99

@@ -164,6 +164,16 @@ commands =
164164
{[testenv:molecule_syntax]commands}
165165
{[testenv:molecule_test]commands}
166166

167+
[testenv:collection]
168+
changedir = {toxinidir}
169+
ansible_python_interpreter = /usr/bin/python3
170+
deps =
171+
ruamel.yaml
172+
ansible
173+
jmespath
174+
commands =
175+
bash {toxinidir}/.travis/runcollection.sh {toxworkdir} master
176+
167177
[testenv:custom]
168178
changedir = {toxinidir}
169179
envdir = {toxworkdir}/env-{env:TRAVIS_PYTHON_VERSION:custom}
@@ -200,7 +210,7 @@ max-line-length = 88
200210
python =
201211
2.6: py26,coveralls,custom
202212
2.7: py27,coveralls,flake8,pylint,custom
203-
3.6: py36,coveralls,black,yamllint,shellcheck,custom
213+
3.6: py36,coveralls,black,yamllint,shellcheck,custom,collection
204214
3.7: py37,coveralls,custom
205215
3.8: py38,coveralls,custom
206216
3.8-dev: py38,coveralls,custom

0 commit comments

Comments
 (0)