Skip to content

Commit

Permalink
adding ansible-lint tests to CI (#484)
Browse files Browse the repository at this point in the history
  • Loading branch information
dangel101 committed Sep 29, 2022
1 parent 91b4120 commit c50a679
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
25 changes: 5 additions & 20 deletions build/ansible-check.sh
Original file line number Diff line number Diff line change
@@ -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/*

0 comments on commit c50a679

Please sign in to comment.