-
Notifications
You must be signed in to change notification settings - Fork 10
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
New option for adding Synced label to GitHub issues after sync with Jira #59
New option for adding Synced label to GitHub issues after sync with Jira #59
Conversation
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.
thanks for the PR
I think we can make the PR more lightweight and make the label name static
bc7a7b2
to
01e235f
Compare
Applied both suggestions and signed commits. |
also, gh-jira-sync-bot/ARCHITECTURE.md Line 18 in 7305729
|
01e235f
to
bee4e48
Compare
@lorenzo-medici can you please fix the unittests? |
The test that is not passing needs a realistic body for adding a non existent label to be placed in |
@beliaev-maksim I realized you might not have gotten the notification from the previous comment depending on your settings. (If you have, I apologize for spamming)
|
another thing that I discovered while debugging. When we apply label, it sends another webhook which adds unnecessary load on the server. Can we validate that this is caused by our label and ignore it? here is the payload example Details
{
"action": "labeled",
"issue": {
"url": "https://api.github.com/repos/beliaev-maksim/test-ci/issues/6",
"repository_url": "https://api.github.com/repos/beliaev-maksim/test-ci",
"labels_url": "https://api.github.com/repos/beliaev-maksim/test-ci/issues/6/labels{/name}",
"comments_url": "https://api.github.com/repos/beliaev-maksim/test-ci/issues/6/comments",
"events_url": "https://api.github.com/repos/beliaev-maksim/test-ci/issues/6/events",
"html_url": "https://github.com/beliaev-maksim/test-ci/issues/6",
"id": 2749886114,
"node_id": "I_kwDONftXdM6j5-6i",
"number": 6,
"title": "6",
"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", "user_view_type": "public", "site_admin": false
}
,
"labels": [ {
"id": 7904220484, "node_id": "LA_kwDONftXdM8AAAAB1yDVRA", "url": "https://api.github.com/repos/beliaev-maksim/test-ci/labels/synced-to-jira", "name": "synced-to-jira", "color": "ededed", "default": false, "description": null
}
],
"state": "open",
"locked": false,
"assignee": null,
"assignees": [],
"milestone": null,
"comments": 0,
"created_at": "2024-12-19T10:35:22Z",
"updated_at": "2024-12-19T10:35:47Z",
"closed_at": null,
"author_association": "OWNER",
"active_lock_reason": null,
"body": null,
"reactions": {
"url": "https://api.github.com/repos/beliaev-maksim/test-ci/issues/6/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0
}
,
"timeline_url": "https://api.github.com/repos/beliaev-maksim/test-ci/issues/6/timeline",
"performed_via_github_app": null,
"state_reason": null
}
,
"label": {
"id": 7904220484, "node_id": "LA_kwDONftXdM8AAAAB1yDVRA", "url": "https://api.github.com/repos/beliaev-maksim/test-ci/labels/synced-to-jira", "name": "synced-to-jira", "color": "ededed", "default": false, "description": null
}
,
"repository": {
"id": 905664372,
"node_id": "R_kgDONftXdA",
"name": "test-ci",
"full_name": "beliaev-maksim/test-ci",
"private": false,
"owner": {
"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", "user_view_type": "public", "site_admin": false
}
,
"html_url": "https://github.com/beliaev-maksim/test-ci",
"description": null,
"fork": false,
"url": "https://api.github.com/repos/beliaev-maksim/test-ci",
"forks_url": "https://api.github.com/repos/beliaev-maksim/test-ci/forks",
"keys_url": "https://api.github.com/repos/beliaev-maksim/test-ci/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/beliaev-maksim/test-ci/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/beliaev-maksim/test-ci/teams",
"hooks_url": "https://api.github.com/repos/beliaev-maksim/test-ci/hooks",
"issue_events_url": "https://api.github.com/repos/beliaev-maksim/test-ci/issues/events{/number}",
"events_url": "https://api.github.com/repos/beliaev-maksim/test-ci/events",
"assignees_url": "https://api.github.com/repos/beliaev-maksim/test-ci/assignees{/user}",
"branches_url": "https://api.github.com/repos/beliaev-maksim/test-ci/branches{/branch}",
"tags_url": "https://api.github.com/repos/beliaev-maksim/test-ci/tags",
"blobs_url": "https://api.github.com/repos/beliaev-maksim/test-ci/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/beliaev-maksim/test-ci/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/beliaev-maksim/test-ci/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/beliaev-maksim/test-ci/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/beliaev-maksim/test-ci/statuses/{sha}",
"languages_url": "https://api.github.com/repos/beliaev-maksim/test-ci/languages",
"stargazers_url": "https://api.github.com/repos/beliaev-maksim/test-ci/stargazers",
"contributors_url": "https://api.github.com/repos/beliaev-maksim/test-ci/contributors",
"subscribers_url": "https://api.github.com/repos/beliaev-maksim/test-ci/subscribers",
"subscription_url": "https://api.github.com/repos/beliaev-maksim/test-ci/subscription",
"commits_url": "https://api.github.com/repos/beliaev-maksim/test-ci/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/beliaev-maksim/test-ci/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/beliaev-maksim/test-ci/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/beliaev-maksim/test-ci/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/beliaev-maksim/test-ci/contents/{+path}",
"compare_url": "https://api.github.com/repos/beliaev-maksim/test-ci/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/beliaev-maksim/test-ci/merges",
"archive_url": "https://api.github.com/repos/beliaev-maksim/test-ci/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/beliaev-maksim/test-ci/downloads",
"issues_url": "https://api.github.com/repos/beliaev-maksim/test-ci/issues{/number}",
"pulls_url": "https://api.github.com/repos/beliaev-maksim/test-ci/pulls{/number}",
"milestones_url": "https://api.github.com/repos/beliaev-maksim/test-ci/milestones{/number}",
"notifications_url": "https://api.github.com/repos/beliaev-maksim/test-ci/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/beliaev-maksim/test-ci/labels{/name}",
"releases_url": "https://api.github.com/repos/beliaev-maksim/test-ci/releases{/id}",
"deployments_url": "https://api.github.com/repos/beliaev-maksim/test-ci/deployments",
"created_at": "2024-12-19T09:29:31Z",
"updated_at": "2024-12-19T09:34:32Z",
"pushed_at": "2024-12-19T09:30:36Z",
"git_url": "git://github.com/beliaev-maksim/test-ci.git",
"ssh_url": "[email protected]:beliaev-maksim/test-ci.git",
"clone_url": "https://github.com/beliaev-maksim/test-ci.git",
"svn_url": "https://github.com/beliaev-maksim/test-ci",
"homepage": null,
"size": 1,
"stargazers_count": 0,
"watchers_count": 0,
"language": null,
"has_issues": true,
"has_projects": true,
"has_downloads": true,
"has_wiki": false,
"has_pages": false,
"has_discussions": false,
"forks_count": 0,
"mirror_url": null,
"archived": false,
"disabled": false,
"open_issues_count": 6,
"license": null,
"allow_forking": true,
"is_template": false,
"web_commit_signoff_required": false,
"topics": [],
"visibility": "public",
"forks": 0,
"open_issues": 6,
"watchers": 0,
"default_branch": "master"
}
,
"sender": {
"login": "test-payload-17-10-2023[bot]",
"id": 148206313,
"node_id": "BOT_kgDOCNVy6Q",
"avatar_url": "https://avatars.githubusercontent.com/u/51964909?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/test-payload-17-10-2023%5Bbot%5D",
"html_url": "https://github.com/apps/test-payload-17-10-2023",
"followers_url": "https://api.github.com/users/test-payload-17-10-2023%5Bbot%5D/followers",
"following_url": "https://api.github.com/users/test-payload-17-10-2023%5Bbot%5D/following{/other_user}",
"gists_url": "https://api.github.com/users/test-payload-17-10-2023%5Bbot%5D/gists{/gist_id}",
"starred_url": "https://api.github.com/users/test-payload-17-10-2023%5Bbot%5D/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/test-payload-17-10-2023%5Bbot%5D/subscriptions",
"organizations_url": "https://api.github.com/users/test-payload-17-10-2023%5Bbot%5D/orgs",
"repos_url": "https://api.github.com/users/test-payload-17-10-2023%5Bbot%5D/repos",
"events_url": "https://api.github.com/users/test-payload-17-10-2023%5Bbot%5D/events{/privacy}",
"received_events_url": "https://api.github.com/users/test-payload-17-10-2023%5Bbot%5D/received_events", "type": "Bot", "user_view_type": "public", "site_admin": false
}
,
"installation": {
"id": 42979996, "node_id": "MDIzOkludGVncmF0aW9uSW5zdGFsbGF0aW9uNDI5Nzk5OTY="
}
} |
here is the example of response with labels. It looks like label is created if label does not exist. Can you check the docs? Details
- response:
auto_calculate_content_length: false
body: '[{"id":7904251331,"node_id":"LA_kwDONftXdM8AAAAB1yFNww","url":"https://api.github.com/repos/beliaev-maksim/test-ci/labels/synced-to-jira","name":"synced-to-jira","color":"ededed","default":false,"description":null}]'
content_type: text/plain
headers:
Access-Control-Allow-Origin: '*'
Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP,
X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource,
X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval,
X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset
Cache-Control: private, max-age=60, s-maxage=60
Content-Security-Policy: default-src 'none'
ETag: W/"27d4a15dae729ce6fc531eeddd17d6834055ee847c6ea86d9ecbf1c1818363fd"
Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
Transfer-Encoding: chunked
Vary: Accept, Authorization, Cookie, X-GitHub-OTP,Accept-Encoding, Accept, X-Requested-With
X-Content-Type-Options: nosniff
X-Frame-Options: deny
X-GitHub-Media-Type: github.v3; format=json
X-GitHub-Request-Id: 66A2:AD2C0:2ADEB5D:2BCC1E4:6763F8F3
X-RateLimit-Limit: '7950'
X-RateLimit-Remaining: '7941'
X-RateLimit-Reset: '1734608131'
X-RateLimit-Resource: core
X-RateLimit-Used: '9'
X-XSS-Protection: '0'
x-accepted-github-permissions: issues=write; pull_requests=write
x-github-api-version-selected: '2022-11-28'
method: POST
status: 200
url: https://api.github.com:443/repos/beliaev-maksim/test-ci/issues/8/labels |
@beliaev-maksim there is nothing in the docs (at least the ones I found here) that says that a label will be created if it doesn't exist, and the Is the webhook you mentioned in the bot server or on the GitHub server? If it is the latter it might be creating the label automatically in the background, in which case we should just remove the |
it looks like we can remove try block and we can remove the comment then, that it cannot add a label. |
this one is a separate issue. As soon as we label, it is another event that GH will send to our server |
…ble 'Synced' label
bee4e48
to
22ad5e0
Compare
@beliaev-maksim Handled both issues in the two latest commits. |
opened GH doc issue I just tested with cURL and got two labels created |
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.
that is a high quality work, thank you!
Added two settings parameters
add_gh_synced_label
andgh_synced_label_name
.When the first one is
true
, a label with the namegh_synced_label_name
will be added to newly created GitHub issues, if it already exists in the repo. Otherwise, nothing will be done on the issue.If
add_gh_comment
is alsotrue
, comments will still be added to the GitHub issue together with the label, and if the synced label feature is misconfigured, a warning will be appended to it.Closes #51