Skip to content

Commit

Permalink
Warning comment always added in case of synced-with-jira label not ex…
Browse files Browse the repository at this point in the history
…isting
  • Loading branch information
lorenzo-medici committed Dec 17, 2024
1 parent 5530e38 commit 01e235f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,9 @@ settings:
# (Optional) (Default: false) Add a new comment in GitHub with a link to Jira created issue
add_gh_comment: false

# (Optional) (Default: false) Add a 'synced-to-jira' label to newly created issues when a corresponding
# ticket is created in Jira. This is meant to replace the comment depending on project preferences,
# but comments will still be added if <add_gh_comment> is true.
# The 'synced-to-jira' label must already be present in the GitHub repo and will not be created by the bot.
# (Optional) (Default: false) Add a 'synced-to-jira' label to newly created issues once a
# corresponding ticket is successfully created in Jira.
# This label serves as confirmation that the issue sync process was completed successfully.
add_gh_synced_label: false

# (Optional) (Default: true) Synchronize issue description from GitHub to Jira
Expand Down
2 changes: 1 addition & 1 deletion github_jira_sync_app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ async def bot(request: Request, payload: dict = Body(...)):
logger.warning(nonexistent_gh_label_warning)
synced_label_absent_in_repo = True

if settings["add_gh_comment"]:
if settings["add_gh_comment"] or synced_label_absent_in_repo:
gh_comment_body = gh_comment_body_template.format(jira_issue_link=new_issue.permalink())

if synced_label_absent_in_repo:
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ def test_issue_created_and_sync_label_not_present(signature_mock):
6. Validate via JQL that this issue does not exist in Jira
7. Create new issue in Jira
8. Try and validate that synced-to-jira label exists in repo
9. Label doesn't exist, nothing is done on the GitHub issue
9. Label doesn't exist, warning comment is added to GitHub issue even though
<add_gh_comment> is false
"""
responses._add_from_file(
UNITTESTS_DIR / "url_responses" / "auth_github_responses_sync_label_not_found.yaml"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,13 @@ responses:
method: GET
status: 404
url: https://api.github.com:443/repos/beliaev-maksim/test-ci/labels/synced-to-jira

# add comment to GitHub issue with warning about misconfiguration
- response:
auto_calculate_content_length: false
body: >
{"id":1,"node_id":"MDEyOklzc3VlQ29tbWVudDE=","url":"https://api.github.com:443/repos/beliaev-maksim/test-ci/issues/comments/12345","html_url":"https://github.com/beliaev-maksim/test-ci/issues/30#issuecomment-12345","body":"Thank you for reporting your feedback to us!\n\nThe internal ticket has been created:{jira_issue_link}.\n\n>This message was auto generated\n\nWarning: 'synced-to-jira' label doesn't exist in the GitHub repo.","user":{"login":"beliaev-maksim","id":51964909,"node_id":"MDQ6VXNlcjUxOTY0OTA5","avatar_url":"https://avatars.githubusercontent.com/u/51964909?v=4","gravatar_id":"","url":"https://api.github.com/users/beliaev-maksim","html_url":"https://github.com/beliaev-maksim","followers_url":"https://api.github.com/users/beliaev-maksim/followers","following_url":"https://api.github.com/users/beliaev-maksim/following{/other_user}","gists_url":"https://api.github.com/users/beliaev-maksim/gists{/gist_id}","starred_url":"https://api.github.com/users/beliaev-maksim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/beliaev-maksim/subscriptions","organizations_url":"https://api.github.com/users/beliaev-maksim/orgs","repos_url":"https://api.github.com/users/beliaev-maksim/repos","events_url":"https://api.github.com/users/beliaev-maksim/events{/privacy}","received_events_url":"https://api.github.com/users/beliaev-maksim/received_events","type":"User","site_admin":false},"created_at":"2011-04-14T16:00:49Z","updated_at":"2011-04-14T16:00:49Z","issue_url":"https://api.github.com:443/repos/beliaev-maksim/test-ci/issues/30","author_association":"COLLABORATOR"}
content_type: text/plain
method: POST
status: 201
url: https://api.github.com:443/repos/beliaev-maksim/test-ci/issues/30/comments

0 comments on commit 01e235f

Please sign in to comment.