Skip to content

improve the /Sanity/rules-d test for CentOS stream#17

Open
milosmalik wants to merge 1 commit intolinux-application-whitelisting:mainfrom
milosmalik:fix-rules-d-test
Open

improve the /Sanity/rules-d test for CentOS stream#17
milosmalik wants to merge 1 commit intolinux-application-whitelisting:mainfrom
milosmalik:fix-rules-d-test

Conversation

@milosmalik
Copy link
Collaborator

WIP - do not merge yet

@gemini-code-assist
Copy link

Summary of Changes

Hello @milosmalik, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request aims to enhance the /Sanity/rules-d test suite for CentOS Stream environments. The changes primarily involve updating package dependencies to their current names and modifying the test setup script to streamline the process of acquiring and building fapolicyd from source, ensuring the test environment is correctly prepared for execution.

Highlights

  • Dependency Updates: The main.fmf file has been updated to use rpm-build instead of rpmbuild and added yum-utils to the recommended packages, aligning with modern CentOS stream practices.
  • Test Script Refinement: The runtest.sh script now bypasses rlCheckMakefileRequires and rhel-CRB repository checks, instead directly downloading the fapolicyd source RPM and installing its build dependencies using yum-builddep.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request aims to improve the Sanity/rules-d test for CentOS Stream. The changes to package requirements in main.fmf are appropriate. However, the modifications in runtest.sh introduce some concerns. Key test validations have been commented out, and a risky --enablerepo '*' flag has been added. I've provided a suggestion to replace this with more robust, distribution-aware logic. Additionally, there's some code redundancy that should be cleaned up to improve maintainability. Overall, the changes are a good step towards CentOS Stream support but require refinement for robustness and clarity.

Comment on lines +35 to +39
# tcfRun "rlCheckMakefileRequires" || rlDie "cannot continue"
# rlRun "dnf repolist enabled | grep rhel-CRB" 0 "Check if required rhel-CRB repo is enabled" || rlDie "cannot continue"
# || "dnf config-manager --set-enabled rhel-CRB"
rlRun "yumdownloader --source fapolicyd"
rlRun "yum-builddep ./fapolicyd-*.src.rpm --enablerepo '*' -y"

Choose a reason for hiding this comment

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

high

This block has a couple of issues that should be addressed for robustness and maintainability:

  1. Disabled Checks: Important checks for RHEL environments on lines 35-36 have been commented out. This can hide potential issues on RHEL. These should be executed conditionally.
  2. Broad Repository Enablement: Using --enablerepo '*' on line 39 is risky as it can pull dependencies from unexpected sources. It's much safer to enable only the specific repositories required.

A better approach is to detect the distribution and configure the necessary repositories (like rhel-CRB for RHEL or crb for CentOS Stream) before installing build dependencies. This makes the test more reliable.

Suggested change
# tcfRun "rlCheckMakefileRequires" || rlDie "cannot continue"
# rlRun "dnf repolist enabled | grep rhel-CRB" 0 "Check if required rhel-CRB repo is enabled" || rlDie "cannot continue"
# || "dnf config-manager --set-enabled rhel-CRB"
rlRun "yumdownloader --source fapolicyd"
rlRun "yum-builddep ./fapolicyd-*.src.rpm --enablerepo '*' -y"
if rlIsRHEL; then
tcfRun "rlCheckMakefileRequires" || rlDie "cannot continue"
rlRun "dnf repolist enabled | grep rhel-CRB" 0 "Check if required rhel-CRB repo is enabled" || rlDie "cannot continue"
elif rlIsRHELLike; then
# For RHEL-like distros (e.g., CentOS Stream), enable the 'crb' repository.
rlRun "dnf config-manager --set-enabled crb" 0 "Enable crb repo for build dependencies"
fi
rlRun "yumdownloader --source fapolicyd"
rlRun "yum-builddep ./fapolicyd-*.src.rpm -y"

Comment on lines +38 to +39
rlRun "yumdownloader --source fapolicyd"
rlRun "yum-builddep ./fapolicyd-*.src.rpm --enablerepo '*' -y"

Choose a reason for hiding this comment

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

medium

These commands to download the source RPM and install build dependencies appear to be redundant with rlFetchSrcForInstalled on line 51 and the yum-builddep call on line 53. To improve clarity and avoid duplicate effort, please consider removing the older, redundant commands. This may already be planned as part of this work-in-progress.

The test should not exit prematurely when the CRB repository is not
available.
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