-
Notifications
You must be signed in to change notification settings - Fork 22
chore: update watchflow rules #54
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
Changes from all commits
d4cbac3
562fd20
1b30219
aedfa1d
8a239b6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,44 +1,29 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||
| rules: | ||||||||||||||||||||||||||||||||||||||||||||||||
| # Essential Open Source Rules | ||||||||||||||||||||||||||||||||||||||||||||||||
| - description: "Pull requests must have descriptive titles following conventional commit format" | ||||||||||||||||||||||||||||||||||||||||||||||||
| - description: "PRs must reference a linked issue in the description or title (e.g. Fixes #123)." | ||||||||||||||||||||||||||||||||||||||||||||||||
| enabled: true | ||||||||||||||||||||||||||||||||||||||||||||||||
| severity: "medium" | ||||||||||||||||||||||||||||||||||||||||||||||||
| severity: "high" | ||||||||||||||||||||||||||||||||||||||||||||||||
| event_types: ["pull_request"] | ||||||||||||||||||||||||||||||||||||||||||||||||
| parameters: | ||||||||||||||||||||||||||||||||||||||||||||||||
| title_pattern: "^feat|^fix|^docs|^style|^refactor|^test|^chore|^perf|^ci|^build|^revert" | ||||||||||||||||||||||||||||||||||||||||||||||||
| require_linked_issue: true | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| - description: "New contributors require approval from at least one past contributor" | ||||||||||||||||||||||||||||||||||||||||||||||||
| - description: "When a PR modifies paths with CODEOWNERS, those owners must be added as reviewers." | ||||||||||||||||||||||||||||||||||||||||||||||||
| enabled: true | ||||||||||||||||||||||||||||||||||||||||||||||||
| severity: "medium" | ||||||||||||||||||||||||||||||||||||||||||||||||
| severity: "high" | ||||||||||||||||||||||||||||||||||||||||||||||||
| event_types: ["pull_request"] | ||||||||||||||||||||||||||||||||||||||||||||||||
| parameters: | ||||||||||||||||||||||||||||||||||||||||||||||||
| min_past_contributors: 1 | ||||||||||||||||||||||||||||||||||||||||||||||||
| require_code_owner_reviewers: true | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| - description: "Code changes must include corresponding tests" | ||||||||||||||||||||||||||||||||||||||||||||||||
| - description: "PR total lines changed must not exceed a maximum (e.g. 500 lines)." | ||||||||||||||||||||||||||||||||||||||||||||||||
| enabled: true | ||||||||||||||||||||||||||||||||||||||||||||||||
| severity: "medium" | ||||||||||||||||||||||||||||||||||||||||||||||||
| event_types: ["pull_request"] | ||||||||||||||||||||||||||||||||||||||||||||||||
| parameters: | ||||||||||||||||||||||||||||||||||||||||||||||||
| pattern: "tests/.*\\.py$|test_.*\\.py$" | ||||||||||||||||||||||||||||||||||||||||||||||||
| condition_type: "files_match_pattern" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| - description: "Changes to critical files require review from code owners" | ||||||||||||||||||||||||||||||||||||||||||||||||
| enabled: true | ||||||||||||||||||||||||||||||||||||||||||||||||
| severity: "high" | ||||||||||||||||||||||||||||||||||||||||||||||||
| event_types: ["pull_request"] | ||||||||||||||||||||||||||||||||||||||||||||||||
| parameters: | ||||||||||||||||||||||||||||||||||||||||||||||||
| critical_owners: [] | ||||||||||||||||||||||||||||||||||||||||||||||||
| max_pr_loc: 500 | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| - description: "When a PR modifies paths with CODEOWNERS, those owners must be added as reviewers" | ||||||||||||||||||||||||||||||||||||||||||||||||
| - description: "PR titles must follow a pattern (e.g. feat:, fix:, docs:) and descriptions must align diff." | ||||||||||||||||||||||||||||||||||||||||||||||||
| enabled: true | ||||||||||||||||||||||||||||||||||||||||||||||||
| severity: "high" | ||||||||||||||||||||||||||||||||||||||||||||||||
| severity: "medium" | ||||||||||||||||||||||||||||||||||||||||||||||||
| event_types: ["pull_request"] | ||||||||||||||||||||||||||||||||||||||||||||||||
| parameters: | ||||||||||||||||||||||||||||||||||||||||||||||||
| require_code_owner_reviewers: true | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| - description: "No direct pushes to main branch - all changes must go through PRs" | ||||||||||||||||||||||||||||||||||||||||||||||||
| enabled: true | ||||||||||||||||||||||||||||||||||||||||||||||||
| severity: "critical" | ||||||||||||||||||||||||||||||||||||||||||||||||
| event_types: ["push"] | ||||||||||||||||||||||||||||||||||||||||||||||||
| parameters: | ||||||||||||||||||||||||||||||||||||||||||||||||
| no_force_push: true | ||||||||||||||||||||||||||||||||||||||||||||||||
| title_pattern: "^feat|^fix|^docs|^style|^refactor|^test|^chore|^perf|^ci|^build|^revert" | ||||||||||||||||||||||||||||||||||||||||||||||||
| min_description_length: 50 | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+23
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rule description currently overstates enforcement scope. The text says descriptions “must align diff,” but configured parameters only enforce 📝 Suggested wording tweak- - description: "PR titles must follow a pattern (e.g. feat:, fix:, docs:) and descriptions must align diff."
+ - description: "PR titles must follow a pattern (e.g. feat:, fix:, docs:) and descriptions must meet minimum detail requirements."📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -225,9 +225,9 @@ class MaxPrLocCondition(BaseCondition): | |
|
|
||
| name = "max_pr_loc" | ||
| description = "Validates that total lines changed (additions + deletions) in a PR do not exceed a maximum; enforces a maximum LOC per pull request." | ||
| parameter_patterns = ["max_lines"] | ||
| parameter_patterns = ["max_lines", "max_pr_loc", "max_changed_lines"] | ||
| event_types = ["pull_request"] | ||
| examples = [{"max_lines": 500}, {"max_lines": 1000}] | ||
| examples = [{"max_lines": 500}, {"max_pr_loc": 1000}] | ||
|
|
||
| async def evaluate(self, context: Any) -> list[Violation]: | ||
| """Evaluate max PR LOC condition. | ||
|
|
@@ -241,7 +241,9 @@ async def evaluate(self, context: Any) -> list[Violation]: | |
| parameters = context.get("parameters", {}) | ||
| event = context.get("event", {}) | ||
|
|
||
| max_lines = parameters.get("max_lines", 0) | ||
| max_lines = ( | ||
| parameters.get("max_lines") or parameters.get("max_pr_loc") or parameters.get("max_changed_lines") or 0 | ||
| ) | ||
|
Comment on lines
+244
to
+246
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Read the relevant sections of the file
echo "=== Lines 228-250 (evaluate method) ==="
sed -n '228,250p' src/rules/conditions/filesystem.py
echo ""
echo "=== Lines 265-280 (validate method) ==="
sed -n '265,280p' src/rules/conditions/filesystem.pyRepository: warestack/watchflow Length of output: 1664 🏁 Script executed: #!/bin/bash
# Check the full structure around these lines to understand the methods better
wc -l src/rules/conditions/filesystem.pyRepository: warestack/watchflow Length of output: 101 🏁 Script executed: #!/bin/bash
# Search for usages of the parameters (max_lines, max_pr_loc, max_changed_lines) to understand intent
rg "(max_lines|max_pr_loc|max_changed_lines)" src/rules/conditions/filesystem.py -B 2 -A 2Repository: warestack/watchflow Length of output: 2196 🏁 Script executed: #!/bin/bash
# Check if there are tests that use these parameters with explicit 0
find . -name "*.py" -type f | xargs rg "max_lines.*0|max_pr_loc.*0|max_changed_lines.*0" -lRepository: warestack/watchflow Length of output: 148 🏁 Script executed: #!/bin/bash
# Check the test file to understand the expected behavior
echo "=== Test file content for max_pr_loc ==="
rg "MaxPrLocCondition|max_lines|max_pr_loc|max_changed_lines" tests/unit/rules/conditions/test_filesystem.py -B 1 -A 3Repository: warestack/watchflow Length of output: 3063 🏁 Script executed: #!/bin/bash
# Look for any documentation or configuration examples
find . -name "*.md" -o -name "*.yaml" -o -name "*.yml" | xargs rg "max_lines|max_pr_loc|max_changed_lines" 2>/dev/null || echo "No matches in docs"Repository: warestack/watchflow Length of output: 2511 🏁 Script executed: #!/bin/bash
# Check if there's any explicit 0 usage in test fixtures or examples
rg "max_lines.*0|max_pr_loc.*0|max_changed_lines.*0" tests/ -B 3 -A 3Repository: warestack/watchflow Length of output: 5105 Extract The current Refactor to fix precedence+ `@staticmethod`
+ def _resolve_max_lines(parameters: dict[str, Any]) -> int:
+ for key in ("max_lines", "max_pr_loc", "max_changed_lines"):
+ if key in parameters and parameters[key] is not None:
+ return int(parameters[key])
+ return 0
+
async def evaluate(self, context: Any) -> list[Violation]:
- max_lines = (
- parameters.get("max_lines") or parameters.get("max_pr_loc") or parameters.get("max_changed_lines") or 0
- )
+ max_lines = self._resolve_max_lines(parameters)
async def validate(self, parameters: dict[str, Any], event: dict[str, Any]) -> bool:
- max_lines = (
- parameters.get("max_lines") or parameters.get("max_pr_loc") or parameters.get("max_changed_lines") or 0
- )
+ max_lines = self._resolve_max_lines(parameters)🤖 Prompt for AI Agents |
||
| if not max_lines: | ||
| logger.debug("MaxPrLocCondition: No max_lines specified, skipping validation") | ||
| return [] | ||
|
|
@@ -266,7 +268,9 @@ async def evaluate(self, context: Any) -> list[Violation]: | |
|
|
||
| async def validate(self, parameters: dict[str, Any], event: dict[str, Any]) -> bool: | ||
| """Legacy validation interface for backward compatibility.""" | ||
| max_lines = parameters.get("max_lines", 0) | ||
| max_lines = ( | ||
| parameters.get("max_lines") or parameters.get("max_pr_loc") or parameters.get("max_changed_lines") or 0 | ||
| ) | ||
| if not max_lines: | ||
| return True | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,7 +65,7 @@ async def test_enrich_event_data(enricher, mock_task, mock_github_client): | |
| async def test_fetch_acknowledgments(enricher, mock_github_client): | ||
| mock_github_client.get_issue_comments.return_value = [ | ||
| { | ||
| "body": "🚨 Watchflow Rule Violations Detected\n\n**Reason:** valid reason\n\n---\nThe following violations have been overridden:\n• **Rule** - Pull request does not have the minimum required approvals\n", | ||
| "body": "🚨 Watchflow Rule Violations Detected\n\n**Reason:** valid reason\n\n---\nThe following violations have been overridden:\n• PR has 1 approvals, requires 2\n", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Grammatical issue in violation text: "1 approvals" should be "1 approval". The test expectation contains "PR has 1 approvals, requires 2" which has incorrect pluralization. If this reflects the actual production output, the source should be fixed to use proper grammar (e.g., "PR has 1 approval, requires 2" or dynamic pluralization). 🤖 Prompt for AI Agents |
||
| "user": {"login": "reviewer"}, | ||
| } | ||
| ] | ||
|
|
||
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.
🧩 Analysis chain
🏁 Script executed:
Repository: warestack/watchflow
Length of output: 1258
title_patterndoes not enforce the colon required by Conventional Commits standard.Line 23 description shows examples with colons (
feat:,fix:,docs:), but the pattern allows any string starting with those prefixes. Update the pattern to require the colon and proper format.Suggested pattern update
📝 Committable suggestion
🤖 Prompt for AI Agents