+
Skip to content

Conversation

edmundmiller
Copy link
Contributor

Summary

  • Set up comprehensive post-edit hooks that automatically run tests, linting, and type checking after file edits
  • Add intelligent hook script that detects file types and runs appropriate commands using uv run
  • Configure hooks to trigger on Edit/MultiEdit/Write tool usage

Key Features

  • Smart Test Execution: Automatically runs specific test files when test_*.py files are edited
  • Related Test Discovery: When editing source files in nf_core/, automatically finds and runs corresponding test files
  • Code Quality Checks: Runs ruff linting, formatting validation, and mypy type checking on Python files
  • Project Convention Compliance: Uses uv run commands per project standards
  • Clear Feedback: Provides emoji-based success/failure indicators with detailed error output

Technical Implementation

  • Hook Script: .claude/hooks/post-edit.py - Python script that analyzes edited files and executes appropriate commands
  • Configuration: Updated .claude/settings.local.json with PostToolUse hooks for Edit/MultiEdit/Write tools
  • Error Handling: Proper timeout management (3 minutes) and meaningful error messages
  • File Intelligence: Distinguishes between test files, source files, and other Python files for targeted actions

Test Plan

  • Test hook triggers on file edits
  • Verify test execution for both test files and source files
  • Confirm linting and type checking run on appropriate files
  • Validate error handling and feedback mechanisms

🤖 Generated with Claude Code

nh13 and others added 30 commits June 5, 2025 15:08
Tools like picard, fgbio, and samtools all have sub-commands.  It is
onerous to have to update them all individually using nf-core modules
bump-version.  This change allows the module name to update to have a
trailing forward slash, which will be interpreted as specifying that all
subcommands should be updated.  E.g. nf-core modules bump-version
samtools/
…dling

- Renamed test functions for clarity.
- Introduced DummyModule and DummyLint classes to simulate module and lint behavior.
- Enhanced tests for handling invalid, empty, and missing dependencies in environment.yml files.
- Improved assertions to validate sorting and schema compliance.
- Replaced yaml library with ruamel.yaml for improved YAML processing.
- Added schema validation for environment.yml files.
- Implemented sorting for dependencies and channels, ensuring proper order.
- Updated file writing to include schema lines and sorted content.
- Enhanced logging for sorting actions and validation results.
…processing

- Updated the YAML library from ruamel.yaml to PyYAML for improved compatibility.
- Changed YAML loading to use safe_load for better security.
- Enhanced YAML dumping with specific formatting options for clarity.
- Adjusted error handling to reflect the new library usage.
…ent.yml processing"

This reverts commit 34d5b00.

Co-authored-by: mashehu <mashehu@users.noreply.github.com>
…endencies

Co-authored-by: mashehu <mashehu3@gmail.com>
…l sorting

- Removed channel sorting logic from environment.yml processing.
- Updated related tests to reflect channel preservation instead of sorting.
- Adjusted logging messages to focus solely on dependency sorting.

Co-authored-by: mashehu <mashehu3@gmail.com>
- Introduced factory fixtures for creating DummyModule and DummyLint instances to streamline test setup.
- Updated tests to utilize the new setup_lint_environment fixture for improved clarity and maintainability.
- Enhanced assertions for YAML parsing results in the environment.yml sorting tests.
- Added parameterized tests for handling invalid and empty YAML files.
- Updated pytest.ini_options in pyproject.toml to include a new "integration" marker for better test categorization.
…nt_test attribute

- Changed the assertion to check for the "environment_yml_sorted" in the lint.passed list using the lint_test attribute instead of the previous tuple structure.
but it is a link to another json file
mirpedrol and others added 18 commits August 22, 2025 15:34
Remove workflow.trace from nf-test snapshot
ignore files in gitignore also for pipeline_if_empty_null lint test
Add GHA to update template nf-test snapshots
- Replace assertions in setUp methods with skipTest() for proper error handling
- Remove unnecessary setUp methods where only one test needs module installation
- Eliminate manual test cleanup code relying on test framework isolation
- Consolidate module installation in setUp where all tests in class need it
- Update registry test to properly expect failures with mismatched registries

Addresses code review feedback on test best practices and structure.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Add new lint check `test_snap_version_content` to ensure version information
in test snapshots contains actual content instead of MD5/SHA hash values.
This addresses the issue where version snapshots were storing hash values
like "versions.yml:md5,949da9c6297b613b50e24c421576f3f1" instead of
actual version content like {"ALE": {"ale": "20180904"}}.

Changes:
- Add version content validation in module_tests.py with regex patterns
- Add comprehensive tests for both invalid (hash) and valid (content) cases
- Add pytest issue marker support for linking tests to GitHub issues
- Update pyproject.toml with new pytest marker configuration

Fixes: nf-core/modules#6505

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
…egex and error handling

- Extract version checking logic into dedicated helper functions for better modularity
- Implement more precise regex patterns with proper word boundaries to avoid false positives
- Optimize performance by reducing string conversions from multiple to single per test
- Add comprehensive test coverage for SHA hashes, mixed scenarios, and edge cases
- Enhance error messages with clearer guidance and examples for developers
- Improve code maintainability and readability through separation of concerns

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Fix critical indentation issue where version checking ran outside the test loop
- Remove redundant _check_version_content_format function for cleaner logic
- Ensure version content validation runs for each test individually
- Improve regex patterns with word boundaries for more precise hash detection
- Add comprehensive test coverage for SHA hashes, mixed scenarios, and edge cases
- All new tests now pass correctly after fixing the loop structure

Related to: nf-core/modules#6505
Fixed in: #3676

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Contributor

This PR is against the main branch ❌

  • Do not close this PR
  • Click Edit and change the base to dev
  • This CI test will remain failed until you push a new commit

Hi @edmundmiller,

It looks like this pull-request is has been made against the nf-core/tools main branch.
The main branch on nf-core repositories should always contain code from the latest release.
Because of this, PRs to main are only allowed if they come from the nf-core/tools dev branch.

You do not need to close this PR, you can change the target branch to dev by clicking the "Edit" button at the top of this page.
Note that even after this, the test will continue to show as failing until you push a new commit.

Thanks again for your contribution!

Copy link

codecov bot commented Sep 27, 2025

Codecov Report

❌ Patch coverage is 89.72973% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.95%. Comparing base (75e643a) to head (7e90309).

Files with missing lines Patch % Lines
nf_core/modules/lint/main_nf.py 50.00% 4 Missing ⚠️
nf_core/__main__.py 88.88% 3 Missing ⚠️
nf_core/components/components_completion.py 87.50% 3 Missing ⚠️
nf_core/pipelines/list.py 80.00% 3 Missing ⚠️
nf_core/pipelines/lint/pipeline_if_empty_null.py 80.00% 2 Missing ⚠️
nf_core/commands_modules.py 50.00% 1 Missing ⚠️
nf_core/modules/bump_versions.py 90.90% 1 Missing ⚠️
nf_core/modules/lint/environment_yml.py 98.00% 1 Missing ⚠️
nf_core/modules/lint/module_tests.py 97.05% 1 Missing ⚠️

☔ 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.

- Clean up AI-generated comments and verbose documentation  
- Improve version hash detection to handle both content and keys
- Add test case for version hash in snapshot keys scenario
- Update CHANGELOG.md with feature description
- Preserve all existing pytest-workflow logic for separate PR

Addresses feedback from @mashehu and @mirpedrol
Related to: nf-core/modules#6505
@mirpedrol
Copy link
Member

I can't change the base branch to dev because it already has a PR, #3676. Which one is the correct one? let's close one of them to avoid confusion.

@mirpedrol mirpedrol modified the milestones: 3.4.0, 3.5.0 Oct 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

9 participants

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载