Skip to content

[HOTFIX] Regression tox fix #121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Sep 21, 2024
Merged

[HOTFIX] Regression tox fix #121

merged 6 commits into from
Sep 21, 2024

Conversation

reactive-firewall
Copy link
Collaborator

@reactive-firewall reactive-firewall commented Sep 20, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a help target in the build process for better user guidance.
    • Added a MANIFEST.in target to streamline file inclusion in builds.
  • Bug Fixes

    • Improved coverage reporting by excluding setup.py from the analysis.
  • Documentation

    • Enhanced readability and organization of documentation configuration.
  • Chores

    • Refined project configuration settings to improve clarity and functionality.
    • Expanded test suite with new test modules and cases for comprehensive coverage.

….py (- WIP #119 -)

### ChangeLog:

Changes in file setup.cfg:
 where =

Changes in file setup.py:
 def readFile(filename):

Changes in file tox.ini:
 commands =
 passenv =
Changes in file Makefile:
 * added HELP target
 * added MANIFEST.in target

Changes in file setup.cfg:
 * tweaked configuration

Changes in file tox.ini:
 * tweaked configuration
…& PR #118 -)

Changes in file .codecov.yml:
 * minor tweak to leave setup.py un-flagged

Changes in file Makefile:
 * Cleaned up a bit

Changes in file docs/conf.py:
 * refactored to comply with PEP-8 style

Changes in file setup.py:
 * refactored to comply with PEP-8 style

Changes in file tox.ini:
 * total refactor and debugging to ensure better stability
@reactive-firewall reactive-firewall self-assigned this Sep 20, 2024
@reactive-firewall reactive-firewall linked an issue Sep 20, 2024 that may be closed by this pull request
Copy link
Contributor

coderabbitai bot commented Sep 20, 2024

Walkthrough

The pull request introduces several modifications across multiple configuration files, including .codecov.yml, Makefile, docs/conf.py, setup.cfg, setup.py, and tests/. Key changes involve refining coverage reporting, enhancing the build process, and expanding the testing suite. Notably, setup.py now includes a new function for processing requirements, while the Makefile has been updated to improve usability. Additionally, new test files have been added to enhance test coverage.

Changes

File(s) Change Summary
.codecov.yml Removed setup.py from coverage paths; coverage target remains at 80%.
Makefile Added help and MANIFEST.in targets; updated build, test-tox, and clean targets for improved workflow.
docs/conf.py Removed unused import; reformatted extlinks and intersphinx_mapping for clarity.
setup.cfg Modified license_files, removed setup.py from scripts, and updated include and exclude sections.
setup.py Introduced parse_requirements_for_install_requires function for processing requirements from requirements.txt.
tests/__init__.py Expanded test suite with additional test modules and cases.
tests/test_build.py Added tests for building packages using PEP 517 standards.
tests/test_install_requires.py Added tests for parsing requirements from a requirements file.
tests/test_manifest.py Added tests for validating file inclusion/exclusion in source distribution.

Assessment against linked issues

Objective Addressed Explanation
Ensure TOX run completes without errors before project unit-tests (#119) It is unclear if the changes resolve the CI error related to install_requires.

Possibly related PRs

Suggested labels

Documentation

Poem

🐰 In the meadow where bunnies play,
Changes hop in, brightening the day.
With files polished and paths made clear,
Our code sings sweet, for all to hear!
Let’s build and test, with joy and cheer! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    -- I pushed a fix in commit <commit_id>, please review it.
    -- Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    -- @coderabbitai generate unit testing code for this file.
    -- @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    -- @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    -- @coderabbitai read src/utils.ts and generate unit testing code.
    -- @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    -- @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added Multicast Any main project file changes Python Lang Changes to Python source code Configs Improvements or additions to configuration labels Sep 20, 2024
Copy link

codecov bot commented Sep 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.158%. Comparing base (35f47b0) to head (cb676c4).
Report is 8 commits behind head on master.

✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #121   +/-   ##
=========================================
  Coverage   97.158%   97.158%           
=========================================
  Files            6         6           
  Lines          387       387           
  Branches        35        35           
=========================================
  Hits           376       376           
  Misses           7         7           
  Partials         4         4           
Flag Coverage Δ
3.10 97.090% <ø> (ø)
3.11 97.090% <ø> (ø)
3.12 97.090% <ø> (ø)
3.7 86.819% <ø> (ø)
3.8 86.932% <ø> (ø)
3.9 86.932% <ø> (ø)
macos-13 88.114% <ø> (ø)
macos-latest 97.090% <ø> (ø)
multicast 97.158% <ø> (ø)
ubuntu-latest 97.158% <ø> (ø)
windows-latest 84.755% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 35f47b0...cb676c4. Read the comment docs.

@reactive-firewall reactive-firewall added Linter Any linter tool or setting file enhancements documentation Improvements or additions to documentation labels Sep 20, 2024
@reactive-firewall
Copy link
Collaborator Author

Fix worked: https://github.com/reactive-firewall/multicast/actions/runs/10952835394/job/30412304622?pr=121 no-longer has the install_requires issue 🎉

@reactive-firewall reactive-firewall mentioned this pull request Sep 20, 2024
…uires Functio (- WIP #119 -)

See also PR #121

Additions in file tests/test_install_requires.py:
 - [x] Comprehensive Test Cases:
     * Valid Inputs:
       - Simple Version Constraints:
          - Test lines like package>=1.0 to ensure minimum versions are correctly parsed.
       - Multiple Version Constraints:
          - Test lines like package>=1.0,!=1.5,<2.0 and verify that only the minimum constraint (>=1.0) is captured.
       - Comments and Empty Lines:
          - Include full-line comments (# Comment) and inline comments (package>=1.0  # Inline comment).
          - Test with empty lines and lines with varying whitespace.
       - Options and URLs:
          - Ensure lines starting with -, --, or URLs (http://..., https://...) are ignored.
     * Invalid Inputs:
       - Malformed Lines:
          - Test lines with invalid syntax or unsupported specifiers to confirm they are handled gracefully.
       - Unsupported Specifiers:
          - Include lines with incompatible version specifiers to ensure they are skipped or reported appropriately.
 - [x] Integrated with Existing Testing Infrastructure

Fixes in file setup.py:
 + added fix for safely handling missing requirements.txt files
 + added constraint to safely require semi-pinned packages in requirements.txt files (must have version now)

Changes in file tests/__init__.py:
 - [x] Integrated with Existing Testing Infrastructure
…(- WIP #119 & PR #121 -)

New Test-Suite in file tests/test_manifest.py:
 - [x] Verify Source Distribution Contents
       * Intent: Confirm that all necessary files are included in the source distribution (sdist).
       * Actions:
         - Create Test Cases in tests/test_manifest.py:
         - Use setUp and tearDown methods to build the distribution and clean up after tests.
         - Utilize tarfile (for .tar.gz) or zipfile (for .zip) to inspect the contents.
         - Verify inclusion of crucial files (requirements.txt, README.md, LICENSE.md, CHANGELOG.md, etc.).
         - Ensure exclusion of unwanted files or directories as specified in MANIFEST.in.
…WIP #119 & PR #121 -)

Changes in file tests/__init__.py:
 * integrated test_build.py into existing tests

New Test-Suite in file tests/test_build.py:
 * tests for PEP-517 compliance
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Outside diff range and nitpick comments (1)
setup.py (1)

88-126: LGTM! The new function enhances the parsing of requirements.

The parse_requirements_for_install_requires function introduces a more robust parsing mechanism for the requirements.txt file. It effectively filters out comments, empty lines, and unsupported specifications, and extracts the minimal version constraints suitable for the install_requires parameter.

The regular expression used for parsing the package name and version is comprehensive and should cover most common scenarios. The function handles various edge cases and ensures that the install_requires list contains only the necessary information.

This change should resolve the tox issue encountered in the previous pull request, as mentioned in the PR objectives.

Here are a few suggestions for further improvement:

  1. Consider adding a brief comment explaining the purpose of the bad_prefixes list and why certain prefixes are considered bad.

  2. The regular expression used for parsing the package name and version can be slightly optimized. For example, you can use [^\s,;]+ instead of [^\s,;]+? to avoid unnecessary backtracking.

  3. Consider adding a few test cases to ensure that the function handles different scenarios correctly, such as packages with version specifiers like ==, >, <, etc.

These are minor suggestions and do not affect the overall functionality of the function.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 16920bd and cb676c4.

Files selected for processing (5)
  • setup.py (2 hunks)
  • tests/init.py (2 hunks)
  • tests/test_build.py (1 hunks)
  • tests/test_install_requires.py (1 hunks)
  • tests/test_manifest.py (1 hunks)
Additional context used
Path-based instructions (4)
tests/__init__.py (1)

Pattern tests/*: When reviewing test-code for this project,

  1. Prioritize portability over clarity, especially when dealing with cross-Python compatibility. However, with the priority in mind, do still consider improvements to clarity when relevant.
  2. As a general guideline, consider the code-style advocated in the PEP-8 standard (excluding the use of spaces for indentation) and evaluate suggested changes for code-style compliance.
  3. As a general guideline, try to provide any relevant, official, and supporting documentation links to any tool's suggestions in review comments. This guideline is important for posterity.
  4. As a project rule, python source files, with names prefixed by the string "test_" and located in the project's "tests" directory, are the project's unit-testing code.
  5. As a project rule, any files with names prefixed by the string "check_" and located in the project's "tests" directory are the project's non-unit testing code. "Non-unit testing" in this context refers to any type of testing other than unit-testing, such as (but NOT limited to) functional testing, style linting, regression testing, etc. . It can also be assumed that non-unit testing code is usually written as bash shell-scripts.
tests/test_build.py (1)

Pattern tests/*: When reviewing test-code for this project,

  1. Prioritize portability over clarity, especially when dealing with cross-Python compatibility. However, with the priority in mind, do still consider improvements to clarity when relevant.
  2. As a general guideline, consider the code-style advocated in the PEP-8 standard (excluding the use of spaces for indentation) and evaluate suggested changes for code-style compliance.
  3. As a general guideline, try to provide any relevant, official, and supporting documentation links to any tool's suggestions in review comments. This guideline is important for posterity.
  4. As a project rule, python source files, with names prefixed by the string "test_" and located in the project's "tests" directory, are the project's unit-testing code.
  5. As a project rule, any files with names prefixed by the string "check_" and located in the project's "tests" directory are the project's non-unit testing code. "Non-unit testing" in this context refers to any type of testing other than unit-testing, such as (but NOT limited to) functional testing, style linting, regression testing, etc. . It can also be assumed that non-unit testing code is usually written as bash shell-scripts.
tests/test_install_requires.py (1)

Pattern tests/*: When reviewing test-code for this project,

  1. Prioritize portability over clarity, especially when dealing with cross-Python compatibility. However, with the priority in mind, do still consider improvements to clarity when relevant.
  2. As a general guideline, consider the code-style advocated in the PEP-8 standard (excluding the use of spaces for indentation) and evaluate suggested changes for code-style compliance.
  3. As a general guideline, try to provide any relevant, official, and supporting documentation links to any tool's suggestions in review comments. This guideline is important for posterity.
  4. As a project rule, python source files, with names prefixed by the string "test_" and located in the project's "tests" directory, are the project's unit-testing code.
  5. As a project rule, any files with names prefixed by the string "check_" and located in the project's "tests" directory are the project's non-unit testing code. "Non-unit testing" in this context refers to any type of testing other than unit-testing, such as (but NOT limited to) functional testing, style linting, regression testing, etc. . It can also be assumed that non-unit testing code is usually written as bash shell-scripts.
tests/test_manifest.py (1)

Pattern tests/*: When reviewing test-code for this project,

  1. Prioritize portability over clarity, especially when dealing with cross-Python compatibility. However, with the priority in mind, do still consider improvements to clarity when relevant.
  2. As a general guideline, consider the code-style advocated in the PEP-8 standard (excluding the use of spaces for indentation) and evaluate suggested changes for code-style compliance.
  3. As a general guideline, try to provide any relevant, official, and supporting documentation links to any tool's suggestions in review comments. This guideline is important for posterity.
  4. As a project rule, python source files, with names prefixed by the string "test_" and located in the project's "tests" directory, are the project's unit-testing code.
  5. As a project rule, any files with names prefixed by the string "check_" and located in the project's "tests" directory are the project's non-unit testing code. "Non-unit testing" in this context refers to any type of testing other than unit-testing, such as (but NOT limited to) functional testing, style linting, regression testing, etc. . It can also be assumed that non-unit testing code is usually written as bash shell-scripts.
Learnings (1)
Common learnings
Learnt from: reactive-firewall
PR: reactive-firewall/multicast#110
File: docs/CI.md:32-32
Timestamp: 2024-09-17T06:40:42.918Z
Learning: Reactive-firewall prefers to keep the word "own" in headings when emphasizing the user's personal test.
Learnt from: reactive-firewall
PR: reactive-firewall/multicast#110
File: docs/USAGE.md:66-66
Timestamp: 2024-09-17T03:38:28.677Z
Learning: Reactive-firewall prefers to use "Caveat" as a heading instead of "Note".
Ruff
tests/test_build.py

25-25: Local variable ImportErr is assigned to but never used

Remove assignment to unused variable ImportErr

(F841)


38-38: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)

tests/test_install_requires.py

26-26: Local variable ImportErr is assigned to but never used

Remove assignment to unused variable ImportErr

(F841)


39-39: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)

tests/test_manifest.py

26-26: Local variable ImportErr is assigned to but never used

Remove assignment to unused variable ImportErr

(F841)


40-40: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)

Additional comments not posted (19)
tests/test_build.py (1)

1-80: Great work on the PEP 517 build test!

The unit test file follows the project's naming convention and covers the essential aspects of building the package using PEP 517 standards. The imports are properly handled, and the test method verifies the expected output and the presence of the generated distribution files.

Tools
Ruff

25-25: Local variable ImportErr is assigned to but never used

Remove assignment to unused variable ImportErr

(F841)


38-38: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)

tests/test_install_requires.py (9)

49-53: LGTM!

The setUp method correctly sets up the temporary requirements file for testing.


54-60: LGTM!

The tearDown method correctly cleans up the temporary requirements file and ensures that the parent class's tearDown method is called.


62-64: LGTM!

The write_requirements method correctly writes the provided content to the temporary requirements file.


66-70: LGTM!

The test_simple_version_constraint method correctly tests parsing a simple version constraint.


72-76: LGTM!

The test_multiple_version_constraints method correctly tests parsing multiple version constraints.


78-89: LGTM!

The test_comments_and_empty_lines method correctly tests handling comments and empty lines in the requirements file.


91-102: LGTM!

The test_options_and_urls_ignored method correctly tests that options and URLs are ignored during parsing.


104-108: LGTM!

The test_malformed_lines method correctly tests handling of malformed requirement lines.


110-114: LGTM!

The test_nonexistent_requirements_file method correctly tests behavior when requirements file does not exist.

tests/test_manifest.py (3)

47-57: LGTM!

The setUp method is correctly setting up the test environment by cleaning previous builds and asserting the expected output.


58-90: LGTM!

The test_sdist_includes_required_files method is correctly testing that the source distribution includes all required files.


92-119: LGTM!

The test_sdist_excludes_unwanted_files method is correctly testing that the source distribution excludes unwanted files.

tests/__init__.py (4)

99-101: LGTM!

The new test module imports are syntactically correct, align with the PR objective of expanding the test suite, and follow the project's naming convention.


105-105: LGTM!

The depends list is correctly updated to include the new test modules, aligning with the PR objective and ensuring their inclusion in the test execution flow.


143-143: LGTM!

The test_cases tuple is correctly updated to include the new test classes, aligning with the PR objective and ensuring their inclusion in the test execution flow.


144-144: LGTM!

The test_cases tuple is correctly updated to include the new test class, aligning with the PR objective and ensuring its inclusion in the test execution flow.

setup.py (2)

169-187: Good practice to wrap the setup function in a conditional block.

Wrapping the setup function in the if __name__ == '__main__': conditional block is a good practice. It ensures that the setup code is executed only when the script is run directly, not when it is imported as a module.

This change follows the best practices for Python packaging and prevents unintended execution of the setup code when the module is imported.


129-129: Updating the requirements variable to use the new parsing function is a good fix.

Replacing the original line that read the requirements from the file with a call to the new parse_requirements_for_install_requires function ensures that the requirements are processed according to the new parsing logic.

This change should resolve the issue with the install_requires field that was causing the tox failures, as mentioned in the PR objectives. The requirements variable now contains the cleaned-up list of requirements that can be directly used in the package setup process.

@reactive-firewall reactive-firewall merged commit de67edb into master Sep 21, 2024
131 checks passed
@reactive-firewall reactive-firewall deleted the regression-tox-fix branch September 26, 2024 02:14
@coderabbitai coderabbitai bot mentioned this pull request Oct 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Configs Improvements or additions to configuration documentation Improvements or additions to documentation Linter Any linter tool or setting file enhancements Multicast Any main project file changes Python Lang Changes to Python source code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regression found in tox testing with CI
1 participant