Skip to content

Commit

Permalink
ci: Use new ansible-lint action, which requires collection format and…
Browse files Browse the repository at this point in the history
… 2.16

The old ansible-community ansible-lint github action is deprecated.
There is a new ansible-lint github action called `ansible/ansible-lint`.
However, this version requires a collection, so we have to convert
the role to collection format before running the ansible-lint action.

tox-lsr has been updated to use ansible-core 2.16 for ansible-lint and
ansible-test.

This also requires tox-lsr 3.2.1 - bump other actions to use 3.2.1

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

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
  • Loading branch information
richm committed Jan 11, 2024
1 parent e4d4997 commit 4ceb5b0
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 32 deletions.
28 changes: 17 additions & 11 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,21 @@ 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"
fi
if ! grep -q '^ *role_name:' "$mm"; then
sed "/galaxy_info:/a\ role_name: network" -i "$mm"
fi
fi
pip3 install "git+https://github.com/linux-system-roles/tox-lsr@3.2.1"
- name: Convert role to collection format
run: |
set -euxo pipefail
TOXENV=collection lsr_ci_runtox
coll_dir=".tox/ansible_collections/$LSR_ROLE2COLL_NAMESPACE/$LSR_ROLE2COLL_NAME"
# ansible-lint action requires a .git directory???
# https://github.com/ansible/ansible-lint/blob/main/action.yml#L45
mkdir -p "$coll_dir/.git"
- 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/linux-system-roles/tox-lsr@3.2.1"
- 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/linux-system-roles/tox-lsr@3.2.1"
- name: Run ansible-plugin-scan
run: |
Expand Down
18 changes: 1 addition & 17 deletions .github/workflows/ansible-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,12 @@ 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/linux-system-roles/tox-lsr@3.2.1"
- name: Convert role to collection format
run: |
set -euxo pipefail
# Remove to avoid running ansible-test on unrelated file
rm -f .pandoc_template.html5
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-test
uses: ansible-community/ansible-test-gh-action@release/v1
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/linux-system-roles/tox-lsr@3.2.1"
# 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
2 changes: 1 addition & 1 deletion tests/tests_provider_nm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@
- ansible_distribution_major_version != '6'

- networkmanager_version is version('1.20.0', '>=')
- ansible_distribution not in ['RedHat', 'CentOS'] or
- ansible_distribution != 'RedHat' or
ansible_distribution_major_version | int < 9

0 comments on commit 4ceb5b0

Please sign in to comment.