diff options
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/get-version.sh | 7 | ||||
-rwxr-xr-x | tools/install-reqs.sh | 24 | ||||
-rwxr-xr-x | tools/test-setup.sh | 29 | ||||
-rwxr-xr-x | tools/update-version.sh | 7 |
4 files changed, 67 insertions, 0 deletions
diff --git a/tools/get-version.sh b/tools/get-version.sh new file mode 100755 index 0000000..67033f8 --- /dev/null +++ b/tools/get-version.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -e +{ + python3 -c "import setuptools_scm" || python3 -m pip install --user setuptools-scm +} 1>&2 # redirect stdout to stderr to avoid polluting the output +python3 -m setuptools_scm | \ + sed 's/Guessed Version\([^+]\+\).*/\1/' diff --git a/tools/install-reqs.sh b/tools/install-reqs.sh new file mode 100755 index 0000000..d4f3624 --- /dev/null +++ b/tools/install-reqs.sh @@ -0,0 +1,24 @@ +#!/bin/bash +set -euo pipefail +pushd examples/playbooks/collections >/dev/null +MISSING=() +export ANSIBLE_COLLECTIONS_PATH=. +for COLLECTION in ansible.posix community.general community.molecule; +do + COL_NAME=${COLLECTION//\./-} + FILENAME=$(find . -maxdepth 1 -name "$COL_NAME*" -print -quit) + if test -n "$FILENAME" + then + echo "Already cached $COL_NAME as $FILENAME" + else + MISSING+=("${COLLECTION}") + fi + if [ ${#MISSING[@]} -ne 0 ]; then + ansible-galaxy collection download -p . -v "${MISSING[@]}" + fi +done + +echo "Install requirements.yml ..." +ansible-galaxy collection install *.tar.gz -p . +ansible-galaxy collection list +popd >/dev/null diff --git a/tools/test-setup.sh b/tools/test-setup.sh new file mode 100755 index 0000000..79dbcc8 --- /dev/null +++ b/tools/test-setup.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# This tool is used to setup the environment for running the tests. Its name +# name and location is based on Zuul CI, which can automatically run it. +set -euo pipefail + +# User specific environment +# shellcheck disable=SC2076 +if ! [[ "$PATH" =~ "$HOME/.local/bin" ]] +then + PATH="$HOME/.local/bin:$PATH" +fi + +if [ -f "/usr/bin/apt-get" ]; then + if [ ! -f "/var/cache/apt/pkgcache.bin" ]; then + sudo apt-get update # mandatory or other apt-get commands fail + fi + # avoid outdated ansible and pipx + sudo apt-get remove -y ansible pipx || true + # cspell:disable-next-line + sudo apt-get install -y --no-install-recommends -o=Dpkg::Use-Pty=0 \ + curl gcc git python3-venv python3-pip python3-dev libyaml-dev + # Some of these might be needed for compiling packages that do not yet + # a binary for current platform, like pyyaml on py311 + # pip3 install -v --no-binary :all: --user pyyaml +fi + +# Log some useful info in case of unexpected failures: +uname +python3 --version diff --git a/tools/update-version.sh b/tools/update-version.sh new file mode 100755 index 0000000..e2cd24d --- /dev/null +++ b/tools/update-version.sh @@ -0,0 +1,7 @@ +#!/bin/bash +DIR=$(dirname "$0") +VERSION=$(./tools/get-version.sh) +mkdir -p "${DIR}/../dist" +sed -e "s/VERSION_PLACEHOLDER/${VERSION}/" \ + "${DIR}/../.config/ansible-lint.spec" \ + > "${DIR}/../dist/ansible-lint.spec" |