Skip to content

ci: support running multiple versions of ansible-lint and ansible-test#237

Merged
richm merged 1 commit intolinux-system-roles:mainfrom
richm:ci-ansible-lint-version
Apr 1, 2026
Merged

ci: support running multiple versions of ansible-lint and ansible-test#237
richm merged 1 commit intolinux-system-roles:mainfrom
richm:ci-ansible-lint-version

Conversation

@richm
Copy link
Copy Markdown
Contributor

@richm richm commented Apr 1, 2026

This is for Ansible partner certification checking
https://github.com/ansible-collections/partner-certification-checker/blob/main/README.md

We must be able to test with the versions used by Automation Hub gating as well as the
latest versions.

Create separate testenvs for different versions of ansible-test so that we can easily
test with that version and ensure all of the dependencies are correct. Note that
the milestone version number is the next one after the current stable version number,
for the sanity ignore files.

By default, tox -e ansible-lint will use the latest version of ansible-lint, and the
latest versions of ansible-core and python that ansible-lint requires.

If you want to use a different version of ansible-lint, you must also specify the ansible-core
and python versions required by that version of ansible-lint. For example:

LSR_ANSIBLE_LINT_DEP=ansible-lint==24.12.* LSR_ANSIBLE_LINT_ANSIBLE_DEP=ansible-core==2.16.* \
  tox -x testenv:ansible-lint.basepython=python3.12 -e ansible-lint

If we have to support 3 or more versions of ansible-lint, we may want to move to the way
we did that for ansible-test-X-Y versions.

Signed-off-by: Rich Megginson rmeggins@redhat.com

Summary by Sourcery

Allow testing against multiple versions of ansible-lint and ansible-test via configurable tox environments.

Build:

  • Make ansible-lint tox environments configurable via environment variables for ansible-lint and ansible-core versions.
  • Add a dedicated ansible-test milestone tox environment targeting the milestone branch with specific Python and collection version settings.

Tests:

  • Update tox merge fixture to reflect the new ansible-lint configuration and base Python settings.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Apr 1, 2026

Reviewer's Guide

Adds configurability for ansible-lint (including its matching ansible-core/python versions) and introduces a dedicated tox environment for running milestone ansible-test, to support Automation Hub / partner certification workflows.

Flow diagram for configurable ansible-lint tox environment

flowchart TD
  A["Start: Developer runs tox"] --> B["Command: tox -e ansible-lint"]
  B --> C{"LSR_ANSIBLE_LINT_DEP set?"}

  C -->|Yes| D["Use LSR_ANSIBLE_LINT_DEP as ansible-lint dependency"]
  C -->|No| E["Use default ansible-lint (latest)"]

  D --> F{"LSR_ANSIBLE_LINT_ANSIBLE_DEP set?"}
  E --> F

  F -->|Yes| G["Use LSR_ANSIBLE_LINT_ANSIBLE_DEP as ansible-core dependency"]
  F -->|No| H["Use default ansible-core dependency"]

  G --> I["Create testenv:ansible-lint with basepython=python3"]
  H --> I

  I --> J["Run ansible-lint-helper.sh pre"]
  J --> K["Run ansible-lint in configured environment"]
  K --> L["Run ansible-lint-helper.sh post"]
  L --> M["End"]
Loading

File-Level Changes

Change Details Files
Make ansible-lint environments configurable via environment variables so multiple ansible-lint/ansible-core/python versions can be tested.
  • Set an explicit default basepython=python3 for ansible-lint and ansible-lint-collection tox environments.
  • Replace hardcoded ansible-lint dependency with LSR_ANSIBLE_LINT_DEP env var defaulting to ansible-lint.
  • Add LSR_ANSIBLE_LINT_ANSIBLE_DEP env var to install the matching ansible-core version alongside ansible-lint.
  • Mirror these ansible-lint configuration changes into the test_tox_merge_ini expected result fixture.
src/tox_lsr/config_files/tox-default.ini
tests/fixtures/test_tox_merge_ini/result.ini
Introduce a separate tox environment for running milestone ansible-test to validate against Automation Hub gating versions.
  • Add [testenv:ansible-test-milestone] using basepython=python3.14 and enabling docker-based ansible-test runs.
  • Set LSR_COLLECTION_VERSION to the current stable collection version used for milestone sanity-ignore handling.
  • Install ansible-test from the ansible "milestone" branch via LSR_ANSIBLE_TEST_DEP env var.
  • Reuse the common runansible-test.sh command for executing ansible-test in the milestone environment.
src/tox_lsr/config_files/tox-default.ini

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • The ansible-lint and ansible-lint-collection testenvs now duplicate the same basepython/deps configuration; consider extracting the common bits into a shared factor or section to avoid drift between them in future changes.
  • In the ansible-test-milestone env, hardcoding both basepython=python3.14 and LSR_COLLECTION_VERSION=2.20.0 may require frequent manual updates; consider driving these via environment variables or a single version constant so they can be adjusted in one place.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The ansible-lint and ansible-lint-collection testenvs now duplicate the same basepython/deps configuration; consider extracting the common bits into a shared factor or section to avoid drift between them in future changes.
- In the ansible-test-milestone env, hardcoding both basepython=python3.14 and LSR_COLLECTION_VERSION=2.20.0 may require frequent manual updates; consider driving these via environment variables or a single version constant so they can be adjusted in one place.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

This is for Ansible partner certification checking
https://github.com/ansible-collections/partner-certification-checker/blob/main/README.md

We must be able to test with the versions used by Automation Hub gating as well as the
latest versions.

Create separate testenvs for different versions of ansible-test so that we can easily
test with that version and ensure all of the dependencies are correct.  Note that
the milestone version number is the next one after the current stable version number,
for the sanity ignore files.

By default, `tox -e ansible-lint` will use the latest version of ansible-lint, and the
latest versions of ansible-core and python that ansible-lint requires.

If you want to use a different version of ansible-lint, you must also specify the ansible-core
and python versions required by that version of ansible-lint.  For example:

```
LSR_ANSIBLE_LINT_DEP=ansible-lint==24.12.* LSR_ANSIBLE_LINT_ANSIBLE_DEP=ansible-core==2.16.* \
  tox -x testenv:ansible-lint.basepython=python3.12 -e ansible-lint
```

If we have to support 3 or more versions of ansible-lint, we may want to move to the way
we did that for ansible-test-X-Y versions.

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
@richm richm force-pushed the ci-ansible-lint-version branch from 0a23311 to 6f9f2ba Compare April 1, 2026 16:36
@richm richm merged commit d4e5225 into linux-system-roles:main Apr 1, 2026
8 checks passed
@richm richm deleted the ci-ansible-lint-version branch April 1, 2026 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant