Skip to content

Commit 0de9b76

Browse files
committed
ci: Use supported ansible-lint action; run ansible-lint against the collection
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. 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 <[email protected]>
1 parent 773f692 commit 0de9b76

File tree

4 files changed

+20
-30
lines changed

4 files changed

+20
-30
lines changed

.github/workflows/ansible-lint.yml

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ on: # yamllint disable-line rule:truthy
1111
branches:
1212
- main
1313
workflow_dispatch:
14+
env:
15+
LSR_ROLE2COLL_NAMESPACE: fedora
16+
LSR_ROLE2COLL_NAME: linux_system_roles
1417
permissions:
1518
contents: read
1619
jobs:
@@ -26,18 +29,21 @@ jobs:
2629
- name: Checkout repo
2730
uses: actions/checkout@v4
2831

29-
- name: Fix up role meta/main.yml namespace and name
32+
- name: Install tox, tox-lsr
3033
run: |
3134
set -euxo pipefail
32-
mm=meta/main.yml
33-
if [ -f "$mm" ]; then
34-
if ! grep -q '^ *namespace:' "$mm"; then
35-
sed "/galaxy_info:/a\ namespace: linux_system_roles" -i "$mm"
36-
fi
37-
if ! grep -q '^ *role_name:' "$mm"; then
38-
sed "/galaxy_info:/a\ role_name: postgresql" -i "$mm"
39-
fi
40-
fi
35+
pip3 install "git+https://github.com/linux-system-roles/[email protected]"
36+
37+
- name: Convert role to collection format
38+
run: |
39+
set -euxo pipefail
40+
TOXENV=collection lsr_ci_runtox
41+
coll_dir=".tox/ansible_collections/$LSR_ROLE2COLL_NAMESPACE/$LSR_ROLE2COLL_NAME"
42+
# ansible-lint action requires a .git directory???
43+
# https://github.com/ansible/ansible-lint/blob/main/action.yml#L45
44+
mkdir -p "$coll_dir/.git"
4145
4246
- name: Run ansible-lint
43-
uses: ansible-community/ansible-lint-action@v6
47+
uses: ansible/ansible-lint@v6
48+
with:
49+
working_directory: .tox/ansible_collections/${{ env.LSR_ROLE2COLL_NAMESPACE }}/${{ env.LSR_ROLE2COLL_NAME }}

.github/workflows/ansible-managed-var-comment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- name: Install tox, tox-lsr
3131
run: |
3232
set -euxo pipefail
33-
pip3 install "git+https://github.com/linux-system-roles/tox-lsr@3.1.1"
33+
pip3 install "git+https://github.com/linux-system-roles/tox-lsr@3.2.1"
3434
3535
- name: Run ansible-plugin-scan
3636
run: |

.github/workflows/ansible-plugin-scan.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- name: Install tox, tox-lsr
3131
run: |
3232
set -euxo pipefail
33-
pip3 install "git+https://github.com/linux-system-roles/tox-lsr@3.1.1"
33+
pip3 install "git+https://github.com/linux-system-roles/tox-lsr@3.2.1"
3434
3535
- name: Run ansible-plugin-scan
3636
run: |

.github/workflows/ansible-test.yml

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,12 @@ jobs:
3333
- name: Install tox, tox-lsr
3434
run: |
3535
set -euxo pipefail
36-
pip3 install "git+https://github.com/linux-system-roles/tox-lsr@3.1.1"
36+
pip3 install "git+https://github.com/linux-system-roles/tox-lsr@3.2.1"
3737
3838
- name: Convert role to collection format
3939
run: |
4040
set -euxo pipefail
41-
# Remove to avoid running ansible-test on unrelated file
42-
rm -f .pandoc_template.html5
4341
TOXENV=collection lsr_ci_runtox
44-
# copy the ignore files
45-
coll_dir=".tox/ansible_collections/$LSR_ROLE2COLL_NAMESPACE/$LSR_ROLE2COLL_NAME"
46-
# wokeignore:rule=sanity
47-
ignore_dir="$coll_dir/tests/sanity"
48-
if [ ! -d "$ignore_dir" ]; then
49-
mkdir -p "$ignore_dir"
50-
fi
51-
# wokeignore:rule=sanity
52-
for file in .sanity-ansible-ignore-*.txt; do
53-
if [ -f "$file" ]; then
54-
# wokeignore:rule=sanity
55-
cp "$file" "$ignore_dir/${file//*.sanity-ansible-}"
56-
fi
57-
done
5842
5943
- name: Run ansible-test
6044
uses: ansible-community/ansible-test-gh-action@release/v1

0 commit comments

Comments
 (0)