+
Skip to content

Conversation

edmundmiller
Copy link
Contributor

@edmundmiller edmundmiller commented Jul 11, 2025

Waiting on #3592 to get merged.

PR checklist

  • This comment contains a description of changes (with reason)
  • CHANGELOG.md is updated
  • If you've fixed a bug or added code that should be tested, add tests!
  • Documentation in docs is updated

Copy link
Contributor

@mashehu mashehu left a comment

Choose a reason for hiding this comment

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

Will have a deeper look once the two other PRS it contains are cleared up.

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>
edmundmiller added a commit that referenced this pull request Aug 26, 2025
- 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>
- 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>
@edmundmiller edmundmiller marked this pull request as ready for review August 26, 2025 19:36
Copy link

codecov bot commented Aug 26, 2025

Codecov Report

❌ Patch coverage is 97.05882% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 75.95%. Comparing base (2bc29fd) to head (1ddf9ce).
⚠️ Report is 401 commits behind head on dev.

Files with missing lines Patch % Lines
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.

r"\bversions\.yml:sha[0-9]*,[a-f0-9]+\b", # SHA format with variable length
]

# Convert to string only once and search efficiently
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# Convert to string only once and search efficiently

# Check if version content is actual content vs MD5/SHA hash
# Related to: https://github.com/nf-core/modules/issues/6505
# Ensures version snapshots contain actual content instead of hash values
if _contains_version_hash(snap_content[test_name]):
Copy link
Member

Choose a reason for hiding this comment

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

From the previous if statement, looks like the version can be a key of snap_content, so we whould take this option into account too.

- 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
Comment on lines +40 to +45
# Check specific test's keys for version hashes
test_data = snap_content.get(test_name, {})
if isinstance(test_data, dict):
for key in test_data.keys():
if _contains_version_hash(str(key)):
return True
Copy link
Member

Choose a reason for hiding this comment

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

Will this block ever be run if we check the whole test content in the previous lines?
Also, I am not sure why we are checking keys, if hashes should be inside lists. Or is this applied to a different use case?

"""Test linting a nf-test module with version information as MD5 hash instead of actual content, which should fail."""
snap_file = self.bpipe_test_module_path / "tests" / "main.nf.test.snap"
snap = json.load(snap_file.open())
snap_file.read_text()
Copy link
Member

Choose a reason for hiding this comment

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

I think this is not needed

Suggested change
snap_file.read_text()

"""Test linting a nf-test module with version information as actual content, which should pass."""
snap_file = self.bpipe_test_module_path / "tests" / "main.nf.test.snap"
snap = json.load(snap_file.open())
snap_file.read_text()
Copy link
Member

Choose a reason for hiding this comment

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

not needed?

Suggested change
snap_file.read_text()

"""Test linting a nf-test module with version information as SHA hash, which should fail."""
snap_file = self.bpipe_test_module_path / "tests" / "main.nf.test.snap"
snap = json.load(snap_file.open())
snap_file.read_text()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
snap_file.read_text()

"""Test linting when version hash appears in snapshot keys rather than content."""
snap_file = self.bpipe_test_module_path / "tests" / "main.nf.test.snap"
snap = json.load(snap_file.open())
snap_file.read_text()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
snap_file.read_text()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

3 participants

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