From 0ab944574b395e0beb2ff2fb5ea585ce5641123b Mon Sep 17 00:00:00 2001 From: Jean-Paul van Ravensberg <14926452+DevSecNinja@users.noreply.github.com> Date: Wed, 18 Nov 2026 17:03:08 +0100 Subject: [PATCH 1/3] test(lint): install the Galaxy roles in lint-test setup_file lint-test.bats ran ansible-lint without installing the Galaxy roles that our roles depend on (geerlingguy.docker). It only passed when docker-test.bats or syntax-test.bats had run first and installed them. run-tests.sh passes the .bats files in find order, which differs between runners, so the suite failed whenever lint-test.bats came first: syntax-check[specific]: The role 'geerlingguy.docker' was not found A setup_file now installs the roles from ansible/requirements.yml once before the file's tests, so the lint test no longer depends on test order. --- tests/bash/lint-test.bats | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/bash/lint-test.bats b/tests/bash/lint-test.bats index a277aab..20dc890 100644 --- a/tests/bash/lint-test.bats +++ b/tests/bash/lint-test.bats @@ -1,6 +1,20 @@ #!/usr/bin/env bats # Tests for Ansible linting +# Runs once before the tests in this file. ansible-lint runs offline and must +# resolve the Galaxy roles that our roles depend on (geerlingguy.docker), so +# install them here rather than rely on another test file having run first: +# run-tests.sh passes the files in `find` order, which differs between runners. +setup_file() { + local requirements + requirements="$(cd "${BATS_TEST_DIRNAME}/../.." && pwd)/ansible/requirements.yml" + if command -v ansible-galaxy >/dev/null 2>&1; then + if ! ansible-galaxy role install -r "$requirements" >/dev/null 2>&1; then + echo "# warning: could not install the roles in ${requirements}" >&3 + fi + fi +} + # Setup function runs before each test setup() { # Get repository root From 08e81a09aa77d4f8f46ab31e7180e23873ba1d37 Mon Sep 17 00:00:00 2001 From: Jean-Paul van Ravensberg <14926452+DevSecNinja@users.noreply.github.com> Date: Wed, 18 Nov 2026 17:11:45 +0100 Subject: [PATCH 2/3] test(lint): install the Galaxy roles in the ansible-lint test itself Copilot review on #208: on a machine without Ansible, setup_file skipped the role install, and the later "ansible-lint is available or can be installed" test installs Ansible without rerunning it. The lint test then still couldn't resolve geerlingguy.docker when this file ran first. Install the roles inside the ansible-lint test instead, after its tool check and before ansible-lint runs, and fail with the galaxy output if that fails. --- tests/bash/lint-test.bats | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/bash/lint-test.bats b/tests/bash/lint-test.bats index 20dc890..872664a 100644 --- a/tests/bash/lint-test.bats +++ b/tests/bash/lint-test.bats @@ -64,6 +64,17 @@ setup() { fi cd "$ANSIBLE_DIR" + # ansible-lint runs offline (.ansible-lint), so the Galaxy roles our roles + # depend on (geerlingguy.docker) must be installed first. Install them here + # rather than rely on another test file having run first: run-tests.sh passes + # the files in `find` order, which differs between runners. + run ansible-galaxy role install -r requirements.yml + if [ "$status" -ne 0 ]; then + echo "ansible-galaxy role install failed (exit $status):" >&2 + echo "$output" >&2 + fi + [ "$status" -eq 0 ] + run ansible-lint -c .ansible-lint roles/ # Print output on failure to aid CI debugging From 45a58ecceffe8c2ed97e81d262c2cf71c9247a2a Mon Sep 17 00:00:00 2001 From: Jean-Paul van Ravensberg <14926452+DevSecNinja@users.noreply.github.com> Date: Wed, 18 Nov 2026 17:12:21 +0100 Subject: [PATCH 3/3] test(lint): drop the setup_file role install --- tests/bash/lint-test.bats | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/tests/bash/lint-test.bats b/tests/bash/lint-test.bats index 872664a..3ac50ec 100644 --- a/tests/bash/lint-test.bats +++ b/tests/bash/lint-test.bats @@ -1,20 +1,6 @@ #!/usr/bin/env bats # Tests for Ansible linting -# Runs once before the tests in this file. ansible-lint runs offline and must -# resolve the Galaxy roles that our roles depend on (geerlingguy.docker), so -# install them here rather than rely on another test file having run first: -# run-tests.sh passes the files in `find` order, which differs between runners. -setup_file() { - local requirements - requirements="$(cd "${BATS_TEST_DIRNAME}/../.." && pwd)/ansible/requirements.yml" - if command -v ansible-galaxy >/dev/null 2>&1; then - if ! ansible-galaxy role install -r "$requirements" >/dev/null 2>&1; then - echo "# warning: could not install the roles in ${requirements}" >&3 - fi - fi -} - # Setup function runs before each test setup() { # Get repository root