Skip to content

fix: enable CI tests for openSUSE leap; handle missing /etc/sudoers#112

Merged
richm merged 2 commits intolinux-system-roles:mainfrom
HVSharma12:feat/opensuse-leap-ci
Apr 15, 2026
Merged

fix: enable CI tests for openSUSE leap; handle missing /etc/sudoers#112
richm merged 2 commits intolinux-system-roles:mainfrom
HVSharma12:feat/opensuse-leap-ci

Conversation

@HVSharma12
Copy link
Copy Markdown
Contributor

@HVSharma12 HVSharma12 commented Apr 15, 2026

Enhancement: Enable openSUSE Leap CI testing and fix scan_sudoers crash

Reason: CI tests dont run on openSUSE Leap & scan_sudoers crashes with filenotfounderror on systems using config pattern (/usr/etc/sudoers) eg sles16/leap16/tumbleweed, causing the role to fail before it can run. fix added os.path.isfile() check in scan_sudoers.py.

Result: CI test to be enabled for Leap. scan_sudoers does not crash with FileNotFoundError.

Issue Tracker Tickets (Jira or BZ if any): na

Summary by Sourcery

Enable openSUSE Leap support and prevent sudoers scanning from failing when the sudoers file is missing.

Bug Fixes:

  • Avoid crashing in sudoers scanning when the configured sudoers file path does not exist.

Enhancements:

  • Declare openSUSE Leap as a supported platform and ensure its CI tests can run by updating collection requirements.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Apr 15, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds openSUSE Leap as a supported platform and enables its CI testing by updating collection requirements, and hardens scan_sudoers to avoid crashing when the sudoers file path does not exist (e.g., systems using /usr/etc/sudoers).

File-Level Changes

Change Details Files
Prevent scan_sudoers from crashing when the sudoers file path does not exist.
  • Add an os.path.isfile(path) guard at the start of get_config_lines to check for file existence.
  • Return an empty dict early from get_config_lines when the sudoers file is missing instead of attempting to open it.
library/scan_sudoers.py
Update collection requirements to support Leap CI and features.
  • Add community.general collection as a requirement.
  • Constrain community.general to version >=6.6.0 and <12.0.0 to match supported feature set.
meta/collection-requirements.yml
Declare openSUSE Leap as a supported platform.
  • Add leap to the supported platforms list in the collection metadata so Leap CI can be enabled and recognized as a target platform.
meta/main.yml

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:

  • In get_config_lines, consider using a context manager (with open(path) as fp:) instead of manual open/close to make the file handling more robust and idiomatic.
  • Since you're now treating a missing sudoers file as non-fatal by returning {}, you might also want to catch and handle other I/O errors (e.g., permission issues) around open(path, "r") to avoid unexpected crashes on systems with restricted sudoers permissions.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `get_config_lines`, consider using a context manager (`with open(path) as fp:`) instead of manual open/close to make the file handling more robust and idiomatic.
- Since you're now treating a missing sudoers file as non-fatal by returning `{}`, you might also want to catch and handle other I/O errors (e.g., permission issues) around `open(path, "r")` to avoid unexpected crashes on systems with restricted sudoers permissions.

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.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 15, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@554dec1). Learn more about missing BASE report.

Files with missing lines Patch % Lines
library/scan_sudoers.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #112   +/-   ##
=======================================
  Coverage        ?   52.29%           
=======================================
  Files           ?        1           
  Lines           ?      348           
  Branches        ?        0           
=======================================
  Hits            ?      182           
  Misses          ?      166           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread tests/unit/test_scan_sudoers.py
@richm
Copy link
Copy Markdown
Contributor

richm commented Apr 15, 2026

[citest]

@richm richm merged commit 3cf11b1 into linux-system-roles:main Apr 15, 2026
46 checks passed
---
collections:
- name: ansible.posix
- name: community.general
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One question, why you added community general to the list of reqs?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

3 participants