diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 12:06:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 12:06:49 +0000 |
commit | 2fe34b6444502079dc0b84365ce82dbc92de308e (patch) | |
tree | 8fedcab52bbbc3db6c5aa909a88a7a7b81685018 /tools | |
parent | Initial commit. (diff) | |
download | ansible-lint-2fe34b6444502079dc0b84365ce82dbc92de308e.tar.xz ansible-lint-2fe34b6444502079dc0b84365ce82dbc92de308e.zip |
Adding upstream version 6.17.2.upstream/6.17.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/get-version.sh | 7 | ||||
-rwxr-xr-x | tools/install-reqs.sh | 4 | ||||
-rwxr-xr-x | tools/test-eco.sh | 27 | ||||
-rwxr-xr-x | tools/test-hook.sh | 19 | ||||
-rwxr-xr-x | tools/test-setup.sh | 29 | ||||
-rwxr-xr-x | tools/update-version.sh | 7 |
6 files changed, 93 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..f7a08f9 --- /dev/null +++ b/tools/install-reqs.sh @@ -0,0 +1,4 @@ +#!/bin/bash +set -euo pipefail +echo "Install requirements.yml ..." +ansible-galaxy collection install -r requirements.yml -p examples/playbooks/collections diff --git a/tools/test-eco.sh b/tools/test-eco.sh new file mode 100755 index 0000000..55792af --- /dev/null +++ b/tools/test-eco.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +set -eu +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +if [[ -d "${SCRIPT_DIR}/../.cache/eco/.git" ]]; then + git -C "${SCRIPT_DIR}/../.cache/eco" pull +else + mkdir -p "${SCRIPT_DIR}/../.cache" + git clone --recursive https://github.com/ansible-community/ansible-lint-eco "${SCRIPT_DIR}/../.cache/eco" +fi +pushd "${SCRIPT_DIR}/../.cache/eco/projects" > /dev/null + + +for i in $(ls -d */); do + DIR=${i%%/} + RC=0 + pushd $DIR > /dev/null + # Calling ansible lint without any positional arguments inside repository root + SECONDS=0 + ANSIBLE_LINT_IGNORE_FILE=../$DIR.ignore.txt ansible-lint -qq --generate-ignore -f codeclimate | python3 -m json.tool > ../$DIR.json || + RC=$? + echo "Got $RC RC on $DIR in $SECONDS seconds" + popd > /dev/null +done +popd > /dev/null +# Fail if git reports dirty at the end +git diff --exit-code diff --git a/tools/test-hook.sh b/tools/test-hook.sh new file mode 100755 index 0000000..85d2d27 --- /dev/null +++ b/tools/test-hook.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# This scripts checks if ansible-lint works as a hook as expected. +SOURCE=${BASH_SOURCE[0]} +while [ -L "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd ) + SOURCE=$(readlink "$SOURCE") + [[ $SOURCE != /* ]] && SOURCE=$DIR/$SOURCE # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located +done +DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd ) + +set -euo pipefail +rm -rf .tox/x +mkdir -p .tox/x +cd .tox/x +git init +# we add a file to the repo to avoid error due to no file to to lint +touch foo.yml +git add foo.yml +python3 -m pre_commit try-repo -v "${DIR}/.." ansible-lint 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" |