Skip to content

Commit

Permalink
ci: run ansible-lint against the collection
Browse files Browse the repository at this point in the history
The latest Ansible repo gating tests run ansible-lint against
the collection format instead of against individual roles.
We have to convert the role to collection format before running
ansible-test.

Role developers can run this locally using
`tox -e collection,ansible-lint-collection`
See linux-system-roles/tox-lsr#125

ha_cluster - add to python_roles

metrics - fix ansible-lint

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
  • Loading branch information
richm committed May 17, 2023
1 parent b3bbc7f commit 5e50dc0
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions .github/workflows/ansible-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ on: # yamllint disable-line rule:truthy
branches:
- main
workflow_dispatch:
env:
LSR_ROLE2COLL_NAMESPACE: fedora
LSR_ROLE2COLL_NAME: linux_system_roles
permissions:
contents: read
jobs:
Expand All @@ -26,18 +29,31 @@ jobs:
- name: Checkout repo
uses: actions/checkout@v3

- name: Fix up role meta/main.yml namespace and name
- name: Install tox, tox-lsr
run: |
set -euxo pipefail
mm=meta/main.yml
if [ -f "$mm" ]; then
if ! grep -q '^ *namespace:' "$mm"; then
sed "/galaxy_info:/a\ namespace: linux_system_roles" -i "$mm"
fi
if ! grep -q '^ *role_name:' "$mm"; then
sed "/galaxy_info:/a\ role_name: kernel_settings" -i "$mm"
fi
pip3 install "git+https://github.com/linux-system-roles/tox-lsr@3.0.0"
- name: Convert role to collection format
run: |
set -euxo pipefail
TOXENV=collection lsr_ci_runtox
# copy the ignore files
coll_dir=".tox/ansible_collections/$LSR_ROLE2COLL_NAMESPACE/$LSR_ROLE2COLL_NAME"
# wokeignore:rule=sanity
ignore_dir="$coll_dir/tests/sanity"
if [ ! -d "$ignore_dir" ]; then
mkdir -p "$ignore_dir"
fi
# wokeignore:rule=sanity
for file in .sanity-ansible-ignore-*.txt; do
if [ -f "$file" ]; then
# wokeignore:rule=sanity
cp "$file" "$ignore_dir/${file//*.sanity-ansible-}"
fi
done
- name: Run ansible-lint
uses: ansible-community/ansible-lint-action@v6
with:
path: .tox/ansible_collections/${{ env.LSR_ROLE2COLL_NAMESPACE }}/${{ env.LSR_ROLE2COLL_NAME }}

0 comments on commit 5e50dc0

Please sign in to comment.