From c50a679f5f774f746a32e454ceb7d102ec91a51d Mon Sep 17 00:00:00 2001 From: dangel101 Date: Wed, 28 Sep 2022 14:20:07 +0300 Subject: [PATCH] adding ansible-lint tests to CI (oVirt#484) --- .github/workflows/build.yml | 3 +++ build/ansible-check.sh | 25 +++++-------------------- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 63c96ef70fa..1f7c56bf986 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,6 +27,9 @@ jobs: image: quay.io/ovirt/buildcontainer:${{ matrix.container-name }} steps: + - name: Install required PyPI packages + run: pip3.8 install "ansible-lint>=6.0.0,<7.0.0" + - name: Checkout sources uses: ovirt/checkout-action@main diff --git a/build/ansible-check.sh b/build/ansible-check.sh index b1b97899e06..f90203433d5 100755 --- a/build/ansible-check.sh +++ b/build/ansible-check.sh @@ -1,27 +1,12 @@ #!/bin/sh -x -# Search for playbooks within specified directories (one level only) -PLABOOKS_DIR="packaging/ansible-runner-service-project/project" - -# Directory with roles -ROLES_DIR="packaging/ansible-runner-service-project/project/roles" - -SRCDIR="$(dirname "$0")/.." - -ANSIBLE_LINT=/usr/bin/ansible-lint ANSIBLE_LINT_CONF="$(dirname "$0")/ansible-lint.conf" -if ! which "${ANSIBLE_LINT}" > /dev/null 2>&1; then - echo "WARNING: tool '${ANSIBLE_LINT}' is missing" >&2 +# Check if the ansible-lint binary exists +if ! command -v ansible-lint > /dev/null 2>&1; then + echo "WARNING: tool 'ansible-lint' is missing" >&2 exit 0 fi -cd "${SRCDIR}" - -# Find playbooks -PARAMS=$(find ${PLABOOKS_DIR} -type f -name '*.yml' -maxdepth 1) - -# Find roles -PARAMS="$PARAMS $(find ${ROLES_DIR} -type d -maxdepth 1)" - -${ANSIBLE_LINT} -c ${ANSIBLE_LINT_CONF} ${PARAMS} +# Run ansible-lint +ansible-lint -c ${ANSIBLE_LINT_CONF} packaging/ansible-runner-service-project/project/roles/*