-
-
Notifications
You must be signed in to change notification settings - Fork 7
feat: support nox and update readme #202
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
Conversation
…heck/noxfile.py: * lint - test-hook - build - install-wheel - commit-check - coverage - docs sessions marked with * are selected, sessions marked with - are skipped.
WalkthroughThe pull request introduces significant changes to the workflow configuration in Changes
Assessment against linked issues
Possibly related PRs
Warning Rate limit exceeded@shenxianpeng has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 15 minutes and 1 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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 (9)
noxfile.py (4)
44-45
: Consider session dependency tradeoffsThe removal of the
install-wheel
dependency makes this session more independent but might lead to duplicate work if both sessions are run in the same workflow.Consider adding a comment explaining the rationale for removing the dependency, or explore using
nox
's session chaining features if the wheel installation is still needed.
46-47
: Consider parameterizing commit-check optionsThe commit-check command options are currently hardcoded. Consider making them configurable through session arguments.
@nox.session(name="commit-check") def commit_check(session): session.install(".") - session.run("commit-check", "--message", "--branch", "--author-email") + args = session.posargs or ["--message", "--branch", "--author-email"] + session.run("commit-check", *args)
63-64
: Remove extra blank linesConsider removing one of the consecutive blank lines to maintain consistent spacing.
64-68
: Document the new docs-live featureThe new
docs-live
session is a great addition for development, but it needs documentation about its usage.Add a docstring to explain the feature:
@nox.session(name="docs-live") def docs_live(session): + """Start a live-reloading documentation server. + + This session provides real-time documentation updates while editing. + Access the live documentation at http://localhost:8000 by default. + """ session.install(".") session.install("-r", REQUIREMENTS["docs"], "sphinx-autobuild") session.run("sphinx-autobuild", "-b", "html", "docs", "_build/html").github/workflows/main.yml (3)
24-24
: Add error handling and caching for dependenciesConsider adding pip cache and error handling for more robust dependency installation.
+ - uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('requirements-dev.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + - - run: pip install -r requirements-dev.txt + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements-dev.txt || (echo "::error::Failed to install dependencies" && exit 1)
85-88
: Add docs build verification and cachingConsider adding verification and caching for the documentation build process.
+ - uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-docs-${{ hashFiles('requirements-dev.txt') }} + restore-keys: | + ${{ runner.os }}-pip-docs- + - - run: pip install -r requirements-dev.txt + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements-dev.txt || (echo "::error::Failed to install dependencies" && exit 1) - name: Build docs - run: nox -s docs + run: | + nox -s docs + # Verify docs were built successfully + test -f docs/_build/html/index.html || (echo "::error::Documentation build failed - index.html not found" && exit 1)
Line range hint
1-103
: Consider using reusable workflowsThe workflow could benefit from being split into reusable workflows for common steps (build, test, docs). This would:
- Reduce duplication if more workflows are added in the future
- Make maintenance easier
- Allow other repositories to reuse these workflows
Example structure:
# .github/workflows/reusable-build.yml name: Reusable Build on: workflow_call: inputs: python-version: required: false type: string default: '3.x' jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 # ... rest of build stepsThen in main.yml:
jobs: build: uses: ./.github/workflows/reusable-build.yml with: python-version: '3.x'README.rst (2)
75-75
: Enhance pre-commit hook documentationThe comment "requires prepare-commit-msg hook" might not be clear enough for users unfamiliar with git hooks. Consider adding:
- A brief explanation of why this hook is required
- Instructions on how to set up the prepare-commit-msg hook
- - id: check-message # requires prepare-commit-msg hook + - id: check-message # requires prepare-commit-msg hook to validate commit messages + # To enable this hook, create .git/hooks/prepare-commit-msg with: + # #!/bin/sh + # exec < /dev/tty
177-198
: Consider refactoring repeated ASCII artThe ASCII art error banner is duplicated across multiple examples. Consider:
- Moving the ASCII art to a separate section and referencing it
- Using a more concise representation in the examples
- Adding a note that this is how it appears in the terminal
+Error Banner +~~~~~~~~~~~~ + +All error messages are displayed with this banner: + +(ASCII art here) + +Examples +~~~~~~~~ + +Below are various error scenarios and their specific messages:
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (4)
.github/workflows/main.yml
(2 hunks)README.rst
(5 hunks)noxfile.py
(2 hunks)requirements-dev.txt
(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- requirements-dev.txt
🔇 Additional comments (4)
noxfile.py (2)
59-62
: LGTM! Installation process simplified
The removal of the -e
flag simplifies the installation process while maintaining functionality.
37-38
: Verify wheel building process reliability
The removal of the build
session dependency means we need to ensure the wheel building process is reliable within the install-wheel
session itself.
✅ Verification successful
Wheel building process is properly integrated
The wheel building process is correctly handled within the install-wheel
session:
- Uses standard
pip wheel
command to build the wheel - Properly installs the built wheel using the correct path
- Other sessions like
coverage
depend oninstall-wheel
, ensuring proper build order - Build configuration in pyproject.toml is correctly set up with required dependencies
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check if wheel building is consistently handled across the codebase
# Look for any other wheel building processes that might conflict
# Search for wheel building commands
rg -A 2 "pip.*wheel|setup.py.*bdist_wheel"
# Search for potential build configurations
fd -e toml -x cat {} \; | grep -A 5 "\[build-system\]"
Length of output: 431
Script:
#!/bin/bash
# Let's verify the implementation of install-wheel session to ensure it handles the build process correctly
# Check the complete implementation of install-wheel session
ast-grep --pattern 'def install_wheel(session):
$$$
}'
# Also check if there are any other build-related sessions or functions
rg -l "def.*build|session.*build"
Length of output: 105
Script:
#!/bin/bash
# Let's check the complete noxfile.py to understand the full context
cat noxfile.py
Length of output: 1959
.github/workflows/main.yml (1)
80-81
: LGTM! Good improvement for PR previews
Adding the branch ref ensures that documentation is built from the correct source, which is especially useful for PR previews.
README.rst (1)
103-103
: Verify CLI documentation completeness
Please ensure that all command-line options mentioned in the Git Hooks section (--message
, --branch
, etc.) are fully documented in the CLI help output.
✅ Verification successful
Let me gather more information about the CLI documentation.
Let me try one more search to find the CLI argument definitions.
Let me get the full context of these CLI arguments to verify their documentation.
CLI documentation is consistent with implementation
All command-line options mentioned in the Git Hooks section (--message
, --branch
, --author-name
, --author-email
, --commit-signoff
, --merge-base
) are properly implemented in the CLI with corresponding help text. The README correctly directs users to run commit-check --help
which will show these documented options. The documentation is complete and accurate.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check if all command-line options are documented
rg --type rst "(-{1,2}[a-zA-Z\-]+)" | grep -v "commit-check-"
Length of output: 5322
Script:
#!/bin/bash
# Check the CLI help output and documentation
ast-grep --pattern 'def add_arguments(parser: ArgumentParser) -> None:
$$$
}'
# Also check the documentation file mentioned in the README
cat docs/cli_args.html 2>/dev/null || echo "File not found"
Length of output: 145
Script:
#!/bin/bash
# Search for CLI argument definitions in Python files
rg -t py "add_argument\(" -A 1
Length of output: 911
Script:
#!/bin/bash
# Get full context of CLI argument definitions
rg -t py "add_argument\(" -B 1 -A 3
Length of output: 2054
@@ -79,20 +71,21 @@ | |||
- name: Install test | |||
# using a wildcard as filename on Windows requires a bash shell | |||
shell: bash | |||
run: python3 -m pip install dist/*.whl | |||
run: nox -s install-wheel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Verify successful wheel installation
Add a verification step to ensure the wheel was installed correctly.
- run: nox -s install-wheel
+ run: |
+ nox -s install-wheel
+ # Verify installation
+ python -c "import commit_check; print(commit_check.__version__)" || (echo "::error::Wheel installation verification failed" && exit 1)
Committable suggestion skipped: line range outside the PR's diff.
**Commit Check** is a free, powerful tool that enforces commit metadata standards, including commit message, branch naming, committer name/email, commit signoff and more. | ||
|
||
As an alternative to GitHub Enterprise `Metadata restrictions <https://docs.github.com/en/enterprise-server@3.11/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/available-rules-for-rulesets#metadata-restrictions>`_ and Bitbucket's paid puglin `Yet Another Commit Checker <https://marketplace.atlassian.com/apps/1211854/yet-another-commit-checker?tab=overview&hosting=datacenter>`_, Commit Check stands out by integrating DevOps principles and Infrastructure as Code (IaC). | ||
Fully customizable with error messages and suggested commands, it ensures compliance across teams. | ||
|
||
As an alternative to GitHub Enterprise `Metadata restrictions <https://docs.github.com/en/enterprise-server@3.11/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/available-rules-for-rulesets#metadata-restrictions>`_ and Bitbucket's paid plugin `Yet Another Commit Checker <https://marketplace.atlassian.com/apps/1211854/yet-another-commit-checker?tab=overview&hosting=datacenter>`_, Commit Check stands out by integrating DevOps principles and Infrastructure as Code (IaC). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Add pyproject.toml examples as requested in issue #181
The documentation currently only shows YAML-based configuration via .commit-check.yml
. Since issue #181 specifically requests pyproject.toml examples and is part of the v0.9.x milestone, please add a section demonstrating pyproject.toml configuration options.
- Add a new section under "Configuration" showing how to configure commit-check in pyproject.toml
- Include common usage examples similar to those shown in
.commit-check.yml
Note: This verification confirms that:
- The current documentation only covers YAML configuration
- Issue Add Examples #181 explicitly requests pyproject.toml examples
- This feature is planned for the v0.9.x milestone
- The examples are indeed missing from the documentation
🔗 Analysis chain
Add pyproject.toml configuration examples as mentioned in issue #181
While the overview changes improve clarity, the PR objectives mention adding examples for pyproject.toml
configuration (issue #181). Consider adding a section demonstrating how to configure commit-check within pyproject.toml
.
Would you like me to help draft the pyproject.toml configuration examples section?
The previous search was too specific. Let's broaden our search to understand:
- What configuration examples currently exist
- Verify if issue Add Examples #181 exists and its content
This will help us validate if pyproject.toml examples are indeed missing and required.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check if pyproject.toml examples exist anywhere in the documentation
rg -i "pyproject.toml"
Length of output: 22
Script:
#!/bin/bash
# Let's check if there are any existing configuration examples in the documentation
fd -e rst -e md | xargs rg -i "configuration|config" -A 5 -B 5
# Also check if issue #181 exists and its content
gh issue view 181
Length of output: 2987
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (2)
noxfile.py (2)
49-52
: Document the commit-check flagsConsider adding inline comments to explain the purpose of each flag (
--message
,--branch
,--author-email
) to improve maintainability.@nox.session(name="commit-check") def commit_check(session): session.install(".") + # Run commit-check with flags to validate: + # --message: Commit message format + # --branch: Branch naming convention + # --author-email: Author's email format session.run("commit-check", "--message", "--branch", "--author-email")
69-73
: Consider adding configuration options for sphinx-autobuildThe new docs-live session is a great addition for development! Consider enhancing it with useful sphinx-autobuild options:
@nox.session(name="docs-live") def docs_live(session): session.install(".") session.install("-r", REQUIREMENTS["docs"], "sphinx-autobuild") - session.run("sphinx-autobuild", "-b", "html", "docs", "_build/html") + session.run( + "sphinx-autobuild", + "-b", "html", + "--open-browser", # Open browser automatically + "--watch", "commit_check", # Watch source code changes + "--ignore", "*.pyc", # Ignore file patterns + "docs", "_build/html" + )
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
noxfile.py
(2 hunks)
🔇 Additional comments (2)
noxfile.py (2)
44-47
: Previous review comment about error handling is still applicable
The implementation still needs proper error handling and cleanup for the wheel building process.
64-67
: Verify the impact of removing editable mode installation
The removal of the -e
flag from session.install(".")
means the package is installed in non-editable mode. Please verify this won't impact the development workflow where live documentation updates might be needed.
✅ Verification successful
Let me check the content of CONTRIBUTING.md to understand the development workflow requirements.
Let me check if there are any other documentation-related tasks or development workflows in the codebase that might require live updates.
Let me check the content of docs/conf.py to see if there are any auto-documentation features that might require live updates.
Removal of editable mode installation is acceptable
The removal of -e
flag from session.install(".")
in the docs session is acceptable because:
- The only other usage of editable mode (
-e
) in the codebase is in CONTRIBUTING.md for debugging the commit-check package, not related to documentation. - While autodoc is enabled in conf.py, the docs session is specifically for building final documentation (
sphinx-build
) rather than development/live documentation updates. - There's no evidence of live documentation workflow (no sphinx-autobuild or livereload configurations) that would require editable mode.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check if any other nox sessions or documentation tools rely on editable installation
rg -l '\-e\s+\.' | grep -v 'noxfile.py'
Length of output: 55
Script:
#!/bin/bash
# Check the content of CONTRIBUTING.md for editable installation requirements
rg -A 5 -B 5 '\-e\s+\.' CONTRIBUTING.md
Length of output: 229
Script:
#!/bin/bash
# Check for documentation-related tasks and development workflows
rg -l 'sphinx-autobuild|sphinx.ext.autosummary|sphinx.ext.autodoc' docs/
# Check other nox sessions that might need live updates
ast-grep --pattern 'def docs|def dev|def develop'
Length of output: 139
Script:
#!/bin/bash
# Check the content of docs/conf.py for auto-documentation configurations
rg -A 2 'sphinx.ext.autodoc|sphinx.ext.autosummary' docs/conf.py
# Also check if there's a live/autobuild configuration
rg 'autobuild|livereload' docs/conf.py
Length of output: 190
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Outside diff range and nitpick comments (2)
.github/workflows/main.yml (2)
24-24
: Add pip caching to speed up buildsConsider adding pip caching to improve build times.
- uses: actions/setup-python@v5 with: python-version: '3.x' + - uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('requirements-dev.txt') }} + restore-keys: | + ${{ runner.os }}-pip- - run: pip install -r requirements-dev.txt
64-64
: Add pip caching to install jobSimilar to the build job, add pip caching to improve installation times across matrix builds.
- uses: actions/setup-python@v5 with: python-version: ${{ matrix.py }} + - uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-${{ matrix.py }}-pip-${{ hashFiles('requirements-dev.txt') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.py }}-pip- - run: pip install -r requirements-dev.txt
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
.github/workflows/main.yml
(3 hunks)
🔇 Additional comments (2)
.github/workflows/main.yml (2)
42-43
: Reusing existing review comment
The previous review comment about adding a failure condition for coverage is still valid.
28-29
: Consider combining lint and test-hook sessions
Running separate nox sessions for linting and test-hook might increase build time. Consider combining these into a single session in noxfile.py.
|
||
- name: Build wheel | ||
run: python3 -m pip wheel --no-deps -w dist . | ||
run: nox -s build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add wheel build verification
Verify that the wheel was successfully built before uploading.
- run: nox -s build
+ run: |
+ nox -s build
+ if [ ! -f dist/*.whl ]; then
+ echo "::error::Wheel file not found in dist directory"
+ exit 1
+ fi
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
run: nox -s build | |
run: | | |
nox -s build | |
if [ ! -f dist/*.whl ]; then | |
echo "::error::Wheel file not found in dist directory" | |
exit 1 | |
fi |
|
||
- name: Build docs | ||
working-directory: docs | ||
run: sphinx-build -E -W -b html . _build/html | ||
run: nox -s docs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add documentation build verification
Verify that the documentation was built successfully before uploading.
- run: nox -s docs
+ run: |
+ nox -s docs
+ if [ ! -d docs/_build/html ] || [ -z "$(ls -A docs/_build/html)" ]; then
+ echo "::error::Documentation not built successfully in docs/_build/html"
+ exit 1
+ fi
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
run: nox -s docs | |
run: | | |
nox -s docs | |
if [ ! -d docs/_build/html ] || [ -z "$(ls -A docs/_build/html)" ]; then | |
echo "::error::Documentation not built successfully in docs/_build/html" | |
exit 1 | |
fi |
replaced #201 to closes #181 #190
Summary by CodeRabbit
sphinx-autobuild
.requirements-dev.txt
to use a direct Git repository link fornox
.