Skip to content

Conversation

@cidrblock
Copy link
Contributor

@cidrblock cidrblock commented Aug 17, 2025

The GHA tests pull the lock file from main which pointed to an older version.

For older version of lint:

WARNING: ansible-lint 25.5.0 does not provide the extra 'lock'

so the current get used from a previous test which used the lock file in main

GitHub Action Lock File Issue Analysis

Problem Summary

The ansible-lint GitHub Action fails when testing older versions (like v25.5.0) with the error:

an AnsibleCollectionFinder has not been installed in this process

Root Cause Analysis

Issue #1: Missing [lock] Extra in Older Versions

Current Action Command:

pip install "ansible-lint[lock] @ git+https://github.com/ansible/[email protected]"

Problem: The [lock] extra was added after v25.5.0 was released.

Evidence:

  • v25.5.0: No [lock] extra defined in pyproject.toml
  • main branch: Has optional-dependencies.lock = {file = [".config/requirements-lock.txt"]}

Result: When pip encounters a non-existent extra, it:

  1. Ignores the [lock] extra (shows warning)
  2. Falls back to normal dependency resolution using requirements.in
  3. Installs latest ansible-compat>=25.1.5 which is 25.8.0 (incompatible)

Issue #2: Incompatible Dependency Versions

ansible-lint v25.5.0 dependency specification:

ansible-compat>=25.1.5

What gets installed:

  • With [lock] extra: Would use ansible-compat==25.5.0 (compatible)
  • Without [lock] extra: Installs ansible-compat==25.8.0 (incompatible)

Timeline:

  • Aug 13, 2025: ansible-compat 25.8.0 released (with bug)
  • Aug 14, 2025: ansible-compat 25.8.1 released (with fix)
  • Aug 17, 2025: GitHub Actions test fails using cached 25.8.0

Impact

Who is Affected:

  1. GitHub Action users using versioned releases like ansible/[email protected]
  2. CI/CD pipelines that pin to specific ansible-lint versions
  3. Any workflow using ansible-lint versions released before the [lock] extra was added

What Happens:

  • Action downloads correct lock file from tag (contains ansible-compat==25.5.0)
  • Action installs ansible-lint but ignores lock file due to missing extra
  • pip resolves to incompatible ansible-compat==25.8.0
  • Runtime fails with AnsibleCollectionFinder error

Solutions

Option 1: Conditional Lock Extra (Recommended)

Modify the GitHub Action to check if the target version supports [lock] extra:

# Check if lock extra exists
if pip show "ansible-lint[lock] @ git+https://github.com/ansible/ansible-lint@$GH_ACTION_REF" 2>/dev/null; then
    pip install "ansible-lint[lock] @ git+https://github.com/ansible/ansible-lint@$GH_ACTION_REF"
else
    # Fallback: install with constraints file
    pip install -c requirements-lock.txt "ansible-lint @ git+https://github.com/ansible/ansible-lint@$GH_ACTION_REF"
fi

Option 2: Always Use Constraints File

# Download and use lock file as constraints
pip install -c requirements-lock.txt "ansible-lint @ git+https://github.com/ansible/ansible-lint@$GH_ACTION_REF"

Option 3: Version Detection

# Extract version and conditionally use lock extra
VERSION=$(echo $GH_ACTION_REF | sed 's/v//')
if version_compare "$VERSION" ">=" "25.8.0"; then
    pip install "ansible-lint[lock] @ git+https://github.com/ansible/ansible-lint@$GH_ACTION_REF"
else
    pip install -c requirements-lock.txt "ansible-lint @ git+https://github.com/ansible/ansible-lint@$GH_ACTION_REF"
fi

Why We Need to Update the Lock File

Current Lock File Status:

  • main branch: ansible-compat==25.8.0 (incompatible - needs update to 25.8.1)
  • Older tags: ansible-compat==25.x.x (version-specific, immutable)

The Chain of Events:

  1. Steps 1-3: Install from main using [lock] extra → gets ansible-compat==25.8.0
  2. Step 4: Try to install v25.5.0 with [lock] extra → fails silently, reuses existing 25.8.0
  3. Result: Incompatible version causes AnsibleCollectionFinder error

Short-term Fix:

Update the lock file on main branch from ansible-compat==25.8.0 to ansible-compat==25.8.1:

After update:

  • Steps 1-3: Will install working ansible-compat==25.8.1
  • Step 4: Will reuse the working 25.8.1 version (assuming backward compatibility)
  • Result: Should resolve the immediate issue

Assumption:

This fix assumes ansible-compat==25.8.1 maintains backward compatibility with ansible-lint==25.5.0 and no breaking changes were introduced between ansible-compat versions 25.5.0 → 25.8.1.

Long-term Solution:

The GitHub Action should still be made backward compatible to properly handle versions that don't support the [lock] extra, ensuring each version uses its intended dependency versions.

Immediate Actions Required

Priority 1 (Quick Fix):

  1. Update lock file on main branch: Change ansible-compat==25.8.0 to ansible-compat==25.8.1
  2. Test the fix: Verify the updated lock file resolves the GitHub Actions test failure

Priority 2 (Long-term Fix):

  1. Update GitHub Action to handle missing [lock] extra gracefully
  2. Test with multiple versions to ensure backward compatibility
  3. Document the version compatibility requirements
  4. Consider deprecation strategy for very old versions if needed

Testing Strategy

Test the action with:

  • v25.5.0 (no lock extra)
  • v25.8.0 (has lock extra)
  • main (latest)

Verify each uses the correct dependency versions from their respective lock files.


Related Issues: #4728, ansible/ansible-compat#519

@cidrblock cidrblock merged commit 22689f2 into ansible:main Aug 17, 2025
25 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant