Skip to content

Commit 407df6a

Browse files
committed
ci: Comply with Ansible partner certification checking [citest_skip]
https://github.com/ansible-collections/partner-certification-checker/blob/main/README.md Unfortunately we cannot use the checkers provided by their team because they assume the git repo is in collection format - you cannot convert to collection format first then point the checkers at that collection. Instead, implement our own checkers that do the same (and more) - check with multiple versions of ansible-lint and ansible-test to ensure we cover: * all supported versions of EL * Automation Hub gating * the latest versions of Ansible, including the latest milestone version This requires the latest version of tox-lsr Signed-off-by: Rich Megginson <rmeggins@redhat.com>
1 parent 07964ea commit 407df6a

File tree

5 files changed

+44
-60
lines changed

5 files changed

+44
-60
lines changed

.ansible-lint

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ exclude_paths:
2121
- .github/
2222
- .markdownlint.yaml
2323
- examples/roles/
24+
- .collection/
2425
mock_roles:
2526
- linux-system-roles.metrics
2627
- performancecopilot.metrics.bpftrace

.github/workflows/ansible-lint.yml

Lines changed: 20 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ jobs:
2222
!((github.event_name == 'pull_request' && contains(github.event.pull_request.title, '[citest_skip]')) ||
2323
(github.event_name == 'push' && contains(github.event.head_commit.message, '[citest_skip]')))
2424
runs-on: ubuntu-latest
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
# There should be one version which is the one used by the Automation Hub gating, and
29+
# one for the latest version.
30+
# https://github.com/ansible-collections/partner-certification-checker/blob/main/.github/workflows/certification-reusable.yml#L108
31+
versions:
32+
- { ansible_lint: "24.*", ansible: "2.16.*", python: "3.12" }
33+
- { ansible_lint: "26.*", ansible: "2.20.*", python: "3.13" }
2534
steps:
2635
- name: Update pip, git
2736
run: |
@@ -35,53 +44,17 @@ jobs:
3544
- name: Install tox, tox-lsr
3645
run: |
3746
set -euxo pipefail
38-
pip3 install "git+https://github.com/linux-system-roles/tox-lsr@3.17.1"
47+
pip3 install "git+https://github.com/linux-system-roles/tox-lsr@3.18.0"
3948
40-
- name: Convert role to collection format
41-
id: collection
49+
- name: Set up Python
50+
uses: actions/setup-python@v6
51+
with:
52+
python-version: ${{ matrix.versions.python }}
53+
54+
- name: Convert role to collection format and run ansible-lint
4255
run: |
4356
set -euxo pipefail
44-
TOXENV=collection lsr_ci_runtox
45-
coll_dir=".tox/ansible_collections/$LSR_ROLE2COLL_NAMESPACE/$LSR_ROLE2COLL_NAME"
46-
# cleanup after collection conversion
47-
rm -rf "$coll_dir/.ansible" .tox/ansible-plugin-scan "$coll_dir/.collection"
48-
# ansible-lint action requires a .git directory???
49-
# https://github.com/ansible/ansible-lint/blob/main/action.yml#L45
50-
mkdir -p "$coll_dir/.git"
51-
meta_req_file="${{ github.workspace }}/meta/collection-requirements.yml"
52-
test_req_file="${{ github.workspace }}/tests/collection-requirements.yml"
53-
if [ -f "$meta_req_file" ] && [ -f "$test_req_file" ]; then
54-
coll_req_file="${{ github.workspace }}/req.yml"
55-
python -c 'import sys; import yaml
56-
hsh1 = yaml.safe_load(open(sys.argv[1]))
57-
hsh2 = yaml.safe_load(open(sys.argv[2]))
58-
coll = {}
59-
for item in hsh1["collections"] + hsh2["collections"]:
60-
if isinstance(item, dict):
61-
name = item["name"]
62-
rec = item
63-
else:
64-
name = item # assume string
65-
rec = {"name": name}
66-
if name not in coll:
67-
coll[name] = rec
68-
hsh1["collections"] = list(coll.values())
69-
yaml.safe_dump(hsh1, open(sys.argv[3], "w"))' "$meta_req_file" "$test_req_file" "$coll_req_file"
70-
echo merged "$coll_req_file"
71-
cat "$coll_req_file"
72-
elif [ -f "$meta_req_file" ]; then
73-
coll_req_file="$meta_req_file"
74-
elif [ -f "$test_req_file" ]; then
75-
coll_req_file="$test_req_file"
76-
else
77-
coll_req_file=""
78-
fi
79-
echo "coll_req_file=$coll_req_file" >> $GITHUB_OUTPUT
80-
81-
- name: Run ansible-lint
82-
uses: ansible/ansible-lint@v26
83-
with:
84-
working_directory: ${{ github.workspace }}/.tox/ansible_collections/${{ env.LSR_ROLE2COLL_NAMESPACE }}/${{ env.LSR_ROLE2COLL_NAME }}
85-
requirements_file: ${{ steps.collection.outputs.coll_req_file }}
86-
env:
87-
ANSIBLE_COLLECTIONS_PATH: ${{ github.workspace }}/.tox
57+
LSR_ANSIBLE_LINT_DEP="ansible-lint==${{ matrix.versions.ansible_lint }}" \
58+
LSR_ANSIBLE_LINT_ANSIBLE_DEP="ansible-core==${{ matrix.versions.ansible }}" \
59+
tox -x testenv:ansible-lint-collection.basepython="python${{ matrix.versions.python }}" \
60+
-e collection,ansible-lint-collection

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ 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.17.1"
36+
pip3 install "git+https://github.com/linux-system-roles/tox-lsr@3.18.0"
3737
3838
- name: Run ansible-plugin-scan
3939
run: |

.github/workflows/ansible-test.yml

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ jobs:
2222
!((github.event_name == 'pull_request' && contains(github.event.pull_request.title, '[citest_skip]')) ||
2323
(github.event_name == 'push' && contains(github.event.head_commit.message, '[citest_skip]')))
2424
runs-on: ubuntu-latest
25+
strategy:
26+
fail-fast: false # get all results, not just the first failure
27+
matrix:
28+
versions:
29+
- { ansible: "2-14", python: "3.9" }
30+
- { ansible: "2-16", python: "3.11" }
31+
- { ansible: "2-17", python: "3.12" }
32+
- { ansible: "2-18", python: "3.12" }
33+
- { ansible: "2-19", python: "3.13" }
34+
- { ansible: "2-20", python: "3.13" }
35+
- { ansible: "milestone", python: "3.13" }
2536
steps:
2637
- name: Update pip, git
2738
run: |
@@ -36,16 +47,15 @@ jobs:
3647
- name: Install tox, tox-lsr
3748
run: |
3849
set -euxo pipefail
39-
pip3 install "git+https://github.com/linux-system-roles/tox-lsr@3.17.1"
50+
pip3 install "git+https://github.com/linux-system-roles/tox-lsr@3.18.0"
4051
41-
- name: Convert role to collection format
42-
run: |
43-
set -euxo pipefail
44-
TOXENV=collection lsr_ci_runtox
45-
46-
- name: Run ansible-test
47-
uses: ansible-community/ansible-test-gh-action@release/v1
52+
- name: Set up Python
53+
uses: actions/setup-python@v6
4854
with:
49-
testing-type: sanity # wokeignore:rule=sanity
50-
ansible-core-version: stable-2.17
51-
collection-src-directory: ${{ github.workspace }}/.tox/ansible_collections/${{ env.LSR_ROLE2COLL_NAMESPACE }}/${{ env.LSR_ROLE2COLL_NAME }}
55+
python-version: ${{ matrix.versions.python }}
56+
57+
- name: Convert role to collection format and run ansible-test
58+
run: |
59+
tox \
60+
-x testenv:ansible-test-${{ matrix.versions.ansible }}.basepython="python${{ matrix.versions.python }}" \
61+
-e collection,ansible-test-${{ matrix.versions.ansible }}

.github/workflows/qemu-kvm-integration-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ jobs:
110110
python3 -m pip install --upgrade pip
111111
sudo apt update
112112
sudo apt install -y --no-install-recommends git ansible-core genisoimage qemu-system-x86
113-
pip3 install "git+https://github.com/linux-system-roles/tox-lsr@3.17.1"
113+
pip3 install "git+https://github.com/linux-system-roles/tox-lsr@3.18.0"
114114
115115
# HACK: Drop this when moving this workflow to 26.04 LTS
116116
- name: Update podman to 5.x for compatibility with bootc-image-builder's podman 5

0 commit comments

Comments
 (0)