Skip to content

Commit

Permalink
Merge pull request #142 from i386x/lsr-template-refactored--part-1
Browse files Browse the repository at this point in the history
Onboard refactored tox & Travis CI setup and configuration vol. 1
  • Loading branch information
tyll authored Jan 9, 2020
2 parents c94fea7 + b563a09 commit 7b5a06c
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 10 deletions.
11 changes: 9 additions & 2 deletions .travis/config.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# SPDX-License-Identifier: MIT
export LSR_MOLECULE_DEPS='-rmolecule_requirements.txt'
#
# Use this file to specify custom configuration for a project. Generally, this
# involves the modification of the content of LSR_* environment variables, see
#
# * .travis/preinstall:
#
# - LSR_EXTRA_PACKAGES
#

LSR_EXTRA_PACKAGES='python3-selinux'
export LSR_MOLECULE_DEPS='-rmolecule_requirements.txt'
28 changes: 20 additions & 8 deletions .travis/preinstall
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
#!/bin/bash
# SPDX-License-Identifier: MIT

set -ex
# Install package specified by user in LSR_EXTRA_PACKAGES. Executed by Travis
# during before_install phase.
#
# LSR_EXTRA_PACKAGES, set by user in .travis/config.sh, is a space separated
# list of packages to be installed on the Travis build environment (Ubuntu).

SCRIPTDIR=$(dirname $0)
CONFIG=${SCRIPTDIR}/config.sh
set -e

if [[ -f ${CONFIG} ]]; then
. ${CONFIG}
SCRIPTDIR=$(readlink -f $(dirname $0))

. ${SCRIPTDIR}/utils.sh

# Add python3-selinux package (needed by Molecule on selinux enabled systems,
# because Molecule is using `copy` and `file` Ansible modules to setup the
# container).
if lsr_venv_python_matches_system_python; then
LSR_EXTRA_PACKAGES='python3-selinux'
fi

. ${SCRIPTDIR}/config.sh

# Install extra dependencies.
if [[ "${LSR_EXTRA_PACKAGES}" ]]; then
set -x
sudo apt-get update
for P in ${LSR_EXTRA_PACKAGES}; do
sudo apt-get install -y ${P} || :
done
sudo apt-get install -y ${LSR_EXTRA_PACKAGES}
fi
9 changes: 9 additions & 0 deletions .travis/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,12 @@ function lsr_compare_pythons() {
lsr_compare_versions \
$(lsr_get_python_version $1) $2 $(lsr_get_python_version $3)
}

##
# lsr_venv_python_matches_system_python
#
# Exit with 0 if virtual environment Python version matches the system Python
# version.
function lsr_venv_python_matches_system_python() {
lsr_compare_pythons python -eq /usr/bin/python3
}

0 comments on commit 7b5a06c

Please sign in to comment.