Skip to content

Commit

Permalink
ci: Use supported ansible-lint action; run ansible-lint against the c…
Browse files Browse the repository at this point in the history
…ollection

The old ansible-community ansible-lint is deprecated.  There is a
new ansible-lint github action.

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

Add `---` doc start to .markdownlint.yaml

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
  • Loading branch information
richm committed Jan 6, 2024
1 parent cf8a305 commit 0b41667
Show file tree
Hide file tree
Showing 18 changed files with 73 additions and 59 deletions.
49 changes: 40 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,46 @@ jobs:
- name: Checkout repo
uses: actions/checkout@v4

- 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"
pip3 install "git+https://github.com/richm/tox-lsr@collection-debugging"
- name: Convert role to collection format
run: |
set -euxo pipefail
LSR_ROLE2COLL_DEBUG=true 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
if ! grep -q '^ *role_name:' "$mm"; then
sed "/galaxy_info:/a\ role_name: kernel_settings" -i "$mm"
done
# ansible-lint action requires a .git directory???
# https://github.com/ansible/ansible-lint/blob/main/action.yml#L45
mkdir -p "$coll_dir/.git"
# need .ansible-lint at the collection root directory
for file in "$coll_dir"/roles/*/.ansible-lint; do
if [ -f "$file" ]; then
cp "$file" "$coll_dir"
break
fi
fi
done
# doesn't like mock_roles
sed -e '/^mock_roles:/d' -e '/- linux-system-roles[.]/d' \
-i "$coll_dir/.ansible-lint"
echo DEBUG
cat "$coll_dir/tests/kernel_settings/tests_default.yml"
- name: Run ansible-lint
uses: ansible-community/ansible-lint-action@v6
uses: ansible/ansible-lint@v6
with:
working_directory: .tox/ansible_collections/${{ env.LSR_ROLE2COLL_NAMESPACE }}/${{ env.LSR_ROLE2COLL_NAME }}
2 changes: 1 addition & 1 deletion .github/workflows/ansible-managed-var-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Install tox, tox-lsr
run: |
set -euxo pipefail
pip3 install "git+https://github.com/linux-system-roles/tox-lsr@3.1.1"
pip3 install "git+https://github.com/richm/tox-lsr@collection-debugging"
- name: Run ansible-plugin-scan
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ansible-plugin-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Install tox, tox-lsr
run: |
set -euxo pipefail
pip3 install "git+https://github.com/linux-system-roles/tox-lsr@3.1.1"
pip3 install "git+https://github.com/richm/tox-lsr@collection-debugging"
- name: Run ansible-plugin-scan
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ansible-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Install tox, tox-lsr
run: |
set -euxo pipefail
pip3 install "git+https://github.com/linux-system-roles/tox-lsr@3.1.1"
pip3 install "git+https://github.com/richm/tox-lsr@collection-debugging"
- name: Convert role to collection format
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
run: |
set -euxo pipefail
python -m pip install --upgrade pip
pip install "git+https://github.com/linux-system-roles/tox-lsr@3.1.1"
pip install "git+https://github.com/richm/tox-lsr@collection-debugging"
# If you have additional OS dependency packages e.g. libcairo2-dev
# then put them in .github/config/ubuntu-requirements.txt, one
# package per line.
Expand Down
1 change: 1 addition & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# Default state for all rules
default: true

Expand Down
6 changes: 0 additions & 6 deletions .sanity-ansible-ignore-2.10.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
tests/kernel_settings/install_ansible_for_testing.sh shebang!skip
tests/kernel_settings/install_tuned_for_testing.sh shebang!skip
tests/kernel_settings/run_ansible_for_testing.sh shebang!skip
plugins/modules/kernel_settings.py validate-modules:missing-gplv3-license
plugins/modules/kernel_settings.py validate-modules:parameter-type-not-in-doc
plugins/modules/kernel_settings.py validate-modules:undocumented-parameter
plugins/modules/kernel_settings.py validate-modules:module-invalid-version-added
6 changes: 0 additions & 6 deletions .sanity-ansible-ignore-2.11.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
tests/kernel_settings/install_ansible_for_testing.sh shebang!skip
tests/kernel_settings/install_tuned_for_testing.sh shebang!skip
tests/kernel_settings/run_ansible_for_testing.sh shebang!skip
plugins/modules/kernel_settings.py validate-modules:missing-gplv3-license
plugins/modules/kernel_settings.py validate-modules:parameter-type-not-in-doc
plugins/modules/kernel_settings.py validate-modules:undocumented-parameter
plugins/modules/kernel_settings.py validate-modules:module-invalid-version-added
6 changes: 0 additions & 6 deletions .sanity-ansible-ignore-2.12.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
tests/kernel_settings/install_ansible_for_testing.sh shebang!skip
tests/kernel_settings/install_tuned_for_testing.sh shebang!skip
tests/kernel_settings/run_ansible_for_testing.sh shebang!skip
plugins/modules/kernel_settings.py validate-modules:missing-gplv3-license
plugins/modules/kernel_settings.py validate-modules:parameter-type-not-in-doc
plugins/modules/kernel_settings.py validate-modules:undocumented-parameter
plugins/modules/kernel_settings.py validate-modules:module-invalid-version-added
6 changes: 0 additions & 6 deletions .sanity-ansible-ignore-2.13.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
tests/kernel_settings/install_ansible_for_testing.sh shebang!skip
tests/kernel_settings/install_tuned_for_testing.sh shebang!skip
tests/kernel_settings/run_ansible_for_testing.sh shebang!skip
plugins/modules/kernel_settings.py validate-modules:missing-gplv3-license
plugins/modules/kernel_settings.py validate-modules:parameter-type-not-in-doc
plugins/modules/kernel_settings.py validate-modules:undocumented-parameter
plugins/modules/kernel_settings.py validate-modules:module-invalid-version-added
6 changes: 0 additions & 6 deletions .sanity-ansible-ignore-2.14.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
tests/kernel_settings/install_ansible_for_testing.sh shebang!skip
tests/kernel_settings/install_tuned_for_testing.sh shebang!skip
tests/kernel_settings/run_ansible_for_testing.sh shebang!skip
plugins/modules/kernel_settings.py validate-modules:missing-gplv3-license
plugins/modules/kernel_settings.py validate-modules:parameter-type-not-in-doc
plugins/modules/kernel_settings.py validate-modules:undocumented-parameter
plugins/modules/kernel_settings.py validate-modules:module-invalid-version-added
6 changes: 0 additions & 6 deletions .sanity-ansible-ignore-2.15.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
tests/kernel_settings/install_ansible_for_testing.sh shebang!skip
tests/kernel_settings/install_tuned_for_testing.sh shebang!skip
tests/kernel_settings/run_ansible_for_testing.sh shebang!skip
plugins/modules/kernel_settings.py validate-modules:missing-gplv3-license
plugins/modules/kernel_settings.py validate-modules:parameter-type-not-in-doc
plugins/modules/kernel_settings.py validate-modules:undocumented-parameter
plugins/modules/kernel_settings.py validate-modules:module-invalid-version-added
1 change: 1 addition & 0 deletions .sanity-ansible-ignore-2.16.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
plugins/modules/kernel_settings.py validate-modules:missing-gplv3-license
5 changes: 0 additions & 5 deletions .sanity-ansible-ignore-2.9.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
tests/kernel_settings/install_ansible_for_testing.sh shebang!skip
tests/kernel_settings/install_tuned_for_testing.sh shebang!skip
tests/kernel_settings/run_ansible_for_testing.sh shebang!skip
plugins/modules/kernel_settings.py validate-modules:missing-gplv3-license
plugins/modules/kernel_settings.py validate-modules:parameter-type-not-in-doc
plugins/modules/kernel_settings.py validate-modules:undocumented-parameter
26 changes: 24 additions & 2 deletions library/kernel_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
short_description: Manage kernel settings using tuned via a wrapper
version_added: "2.8"
version_added: "2.13.0"
description:
- "WARNING: Do not use this module directly! It is only for role internal use."
Expand Down Expand Up @@ -61,10 +61,32 @@
like the C(sysctl) module except that C(/etc/sysctl.conf) and files
under C(/etc/sysctl.d) are not used.
required: false
type: raw
sysfs:
description:
- key/value pairs of sysfs settings to apply
required: false
type: raw
modules:
description:
- key/value pairs of module settings to apply
required: false
type: raw
selinux:
description:
- key/value pairs of selinux settings to apply
required: false
type: raw
systemd:
description:
- key/value pairs of systemd settings to apply
required: false
type: raw
vm:
description:
- key/value pairs of vm settings to apply
required: false
type: raw
bootloader:
description:
- the C(cmdline) option can be used to set, add, or delete
Expand Down Expand Up @@ -154,7 +176,7 @@
- name: cmdline
value:
- name: spectre_v2
value: off
value: "off"
- name: nopti
- name: panic
state: absent
Expand Down
2 changes: 1 addition & 1 deletion tests/install_ansible_for_testing.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# this is used to install ansible into a venv or tox env
# for testing purposes

Expand Down
2 changes: 1 addition & 1 deletion tests/install_tuned_for_testing.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# this is used to install tuned into a venv or tox env
# for testing purposes

Expand Down
2 changes: 1 addition & 1 deletion tests/run_ansible_for_testing.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -euxo pipefail

Expand Down

0 comments on commit 0b41667

Please sign in to comment.