-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adopt CEL expressions for ignoring issues
With intent to let teams ignore the parent link rule
- Loading branch information
Showing
6 changed files
with
54 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,20 @@ | ||
import celpy | ||
import jira | ||
|
||
from utils.cel import issue_as_cel | ||
|
||
def check_parent_link(issue: jira.resources.Issue, context: dict, _: bool) -> None: | ||
|
||
def check_parent_link( | ||
issue: jira.resources.Issue, context: dict, _: bool, ignore: str = "" | ||
) -> None: | ||
if ignore: | ||
env = celpy.Environment() | ||
program = env.program(env.compile(ignore)) | ||
if program.evaluate(issue_as_cel(issue)): | ||
context["updates"].append( | ||
f"! Ignoring {issue.key} for parent link rule, per cel expression {ignore}." | ||
) | ||
return | ||
if issue.raw["Context"]["Related Issues"]["Parent"] is None: | ||
context["non-compliant"] = True | ||
context["comments"].append(" * Issue is missing the link to its parent.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import celpy | ||
import jira | ||
|
||
|
||
def issue_as_cel(issue: jira.resources.Issue): | ||
return dict( | ||
key=issue.key, | ||
labels=celpy.json_to_cel([label for label in issue.fields.labels]), | ||
components=celpy.json_to_cel( | ||
[component.name for component in issue.fields.components] | ||
), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
cel-python | ||
click | ||
jira | ||
pyyaml | ||
|