Skip to content

Commit

Permalink
Merge pull request linux-system-roles#20 from nhosoi/lsr-template-sync
Browse files Browse the repository at this point in the history
RHELPLAN-56584 - sync collections related changes from template to nbde_client role
  • Loading branch information
nhosoi authored Oct 13, 2020
2 parents 6306def + f882b21 commit f8cc55b
Show file tree
Hide file tree
Showing 4 changed files with 185 additions and 109 deletions.
38 changes: 38 additions & 0 deletions .travis/runcollection.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash
# SPDX-License-Identifier: MIT

set -e

#uncomment if you use $ME - otherwise set in utils.sh
#ME=$(basename "$0")
SCRIPTDIR=$(readlink -f "$(dirname "$0")")

. "${SCRIPTDIR}/utils.sh"
. "${SCRIPTDIR}/config.sh"

# Collection commands that are run when `tox -e collection`:
role=$(basename "${TOPDIR}")
toxworkdir=${1:-"${TOPDIR}"/.tox}
STABLE_TAG=${2:-master}
cd "${toxworkdir}"
toxworkdir=$(pwd)
envlist=${3:- "black,flake8,yamllint,py38,shellcheck"}
automaintenancerepo=https://raw.githubusercontent.com/linux-system-roles/auto-maintenance/

curl -L -o lsr_role2collection.py "${automaintenancerepo}${STABLE_TAG}"/lsr_role2collection.py

python lsr_role2collection.py --src-path "${TOPDIR}/.." --dest-path "${toxworkdir}" --role "${role}" > "${toxworkdir}"/collection.out 2>&1

yamllint="${toxworkdir}"/ansible_collections/fedora/system_roles/.yamllint_defaults.yml
sed -i -e 's/\( *\)\(document-start: disable\)/\1\2\n\1line-length:\n\1\1level: warning/' "${yamllint}"

cd ansible_collections/fedora/system_roles
tox -e "${envlist}" 2>&1 | tee "${toxworkdir}"/collection.tox.out || :

rm -rf "${toxworkdir}"/auto-maintenance "${toxworkdir}"/ansible_collections
cd "${TOPDIR}"
res=$(grep "^ERROR: .*failed" "${toxworkdir}"/collection.tox.out || :)
if [ "$res" != "" ]; then
lsr_error "${ME}: tox in the converted collection format failed."
exit 1
fi
26 changes: 25 additions & 1 deletion .travis/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,21 @@ function lsr_venv_python_matches_system_python() {
lsr_compare_pythons "${1:-python}" -eq "$syspython"
}

function run_setup_module_utils() {
local srcdir
srcdir="$1"
local destdir
destdir="$2"
if [ -x "$TOPDIR/tests/setup_module_utils.sh" ]; then
bash "$TOPDIR/tests/setup_module_utils.sh" "$srcdir" "$destdir"
else
setup_module_util=$( find "$TOPDIR"/tests -name "setup_module_utils.sh" | head -n 1 )
if [ "$setup_module_util" != "" ]; then
bash "$setup_module_util" "$srcdir" "$destdir"
fi
fi
}

##
# lsr_setup_module_utils [$1] [$2]
#
Expand All @@ -189,7 +204,16 @@ function lsr_setup_module_utils() {
local destdir
destdir="${2:-$DEST_MODULE_UTILS_DIR}"
if [ -n "$srcdir" ] && [ -d "$srcdir" ] && [ -n "$destdir" ] && [ -d "$destdir" ]; then
bash "$TOPDIR/tests/setup_module_utils.sh" "$srcdir" "$destdir"
run_setup_module_utils "$srcdir" "$destdir"
else
srcdir="${SRC_COLL_MODULE_UTILS_DIR}"
destdir="${DEST_COLL_MODULE_UTILS_DIR}"
if [ -n "$destdir" ] && [ -d "$destdir" ]; then
if [ -n "$srcdir" ] && [ ! -d "$srcdir" ]; then
mkdir -p "$srcdir"
fi
run_setup_module_utils "$srcdir" "$destdir"
fi
fi
}

Expand Down
Loading

0 comments on commit f8cc55b

Please sign in to comment.