Skip to content
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

[gitlabcomments] Add enricher to handle gitlab comments #881

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vchrombie
Copy link
Member

This PR proposes a new gitlab enricher to handle gitlab comments. The old enricher is left in place to avoid breaking changes with existing customer dashboards.

Ref: chaoss/grimoirelab#208

@vchrombie
Copy link
Member Author

vchrombie commented May 26, 2020

The PR has a lot of pending work, I will be working on this. I will mark ready for review after completing some good work.

Please let me know if you are having any suggestions.
Thanks.

@valeriocos
Copy link
Member

Hi @vchrombie , please ping me when I can review this PR. I had a look at the current status and the start looks promising :)

WRT tests (if this can be of any help), you should run Perceval and copy some docs to a test file, which will be finally put in the folder tests/data. The name is important since it is used to automatically identify the file and load its content (https://github.com/chaoss/grimoirelab-elk/blob/master/tests/base.py#L137)

If needed you can tweak the test data (e.g., changing value attributes) to make sure that all code is covered when running the tests.

@vchrombie
Copy link
Member Author

Hi @valeriocos
I have completed the major part of the PR. I am yet to complete the __get_reactions function and I am working on that right now.

@valeriocos
Copy link
Member

Thanks for the update @vchrombie

@vchrombie
Copy link
Member Author

vchrombie commented Jun 4, 2020

I will mark this PR ready-for-review once I complete the __get_reactions function too. 🚀

@vchrombie vchrombie force-pushed the gitlabcomments branch 2 times, most recently from 95edbc8 to c61362e Compare June 6, 2020 21:19
@coveralls
Copy link

coveralls commented Jun 6, 2020

Pull Request Test Coverage Report for Build 1227039055

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 30 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.5%) to 82.719%

Files with Coverage Reduction New Missed Lines %
/home/runner/work/grimoirelab-elk/grimoirelab-elk/grimoire_elk/utils.py 30 66.54%
Totals Coverage Status
Change from base Build 1220934812: 0.5%
Covered Lines: 9042
Relevant Lines: 10931

💛 - Coveralls

@vchrombie vchrombie marked this pull request as ready for review June 6, 2020 22:11
Copy link
Member

@valeriocos valeriocos left a comment

Choose a reason for hiding this comment

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

Hi @vchrombie, thank you for advancing with this PR. I tested it on a battery of gitlab repos (taken from the gitlab:issue section at https://gitlab.com/Bitergia/c/gitlab/sources/-/blob/master/projects.json).

After fixing some minor errors (check comments), the execution was working fine.
I also checked that the url generated for comments work fine and allows to jump on the original comment on gitlab:

"sub_type" : "issue_comment",
          "body" : "@sabbap \"This merge request at least does something with the chevron until @JobV returns from his vacation when he can implement the scrolling.\"\r\n\r\n@JobV your call if this is good enough or not",
          "body_analyzed" : "@sabbap \"This merge request at least does something with the chevron until @JobV returns from his vacation when he can implement the scrolling.\"\r\n\r\n@JobV your call if this is good enough or not",
          "url" : "https://gitlab.com/gitlab-com/www-gitlab-com/issues/272#note_948621", <----
          "comment_updated_at" : "2015-03-13T00:16:20.314Z",
          "id" : "160818_merge_comment_948621",
          "grimoire_creation_date" : "2015-03-13T00:16:20.314000+00:00",
          "is_gitlab_issue_comment" : 1,

Can you add the tests and schema? Thanks

grimoire_elk/enriched/gitlabcomments.py Show resolved Hide resolved
grimoire_elk/enriched/gitlabcomments.py Outdated Show resolved Hide resolved
grimoire_elk/enriched/gitlabcomments.py Outdated Show resolved Hide resolved
@vchrombie
Copy link
Member Author

#881 (review)

Thanks for the review @valeriocos.
I have just updated the PR with the changes you have suggested.

Can you add the tests and schema?

Sure, I will be working on it and add them here soon.

@vchrombie vchrombie force-pushed the gitlabcomments branch 3 times, most recently from 705ed10 to 2d14167 Compare June 9, 2020 19:26
@vchrombie
Copy link
Member Author

vchrombie commented Jun 9, 2020

Hi @valeriocos

Recent updates to the PR

  1. I removed the reactions mapping as we discussed it is not needed and also implemented the new __get-reactions() function.
  2. added the schema using the gitlabcomments-mrs/issues_enriched index.
  3. added the tests, (highly need a review on this as I'm not really good with it).

I'm right now checking the coverage, will update the PR if needed.

Once the PR is perfect, I can squash the commits and rebase them with the latest changes too.

@vchrombie vchrombie force-pushed the gitlabcomments branch 3 times, most recently from 240e81d to c2a40cb Compare June 10, 2020 06:26
Copy link
Member

@valeriocos valeriocos left a comment

Choose a reason for hiding this comment

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

Hi @vchrombie , thank you for working on this PR. Overall it looks good, I left some minor comments.

I also successfully executed the enricher on a short list of gitlab repos.

grimoire_elk/enriched/gitlabcomments.py Outdated Show resolved Hide resolved
grimoire_elk/enriched/gitlabcomments.py Outdated Show resolved Hide resolved
grimoire_elk/enriched/gitlabcomments.py Outdated Show resolved Hide resolved
grimoire_elk/enriched/gitlabcomments.py Outdated Show resolved Hide resolved
schema/gitlabcomments_issues.csv Outdated Show resolved Hide resolved
grimoire_elk/enriched/gitlabcomments.py Outdated Show resolved Hide resolved
grimoire_elk/enriched/gitlabcomments.py Outdated Show resolved Hide resolved
grimoire_elk/enriched/gitlabcomments.py Outdated Show resolved Hide resolved
schema/gitlabcomments_merges.csv Outdated Show resolved Hide resolved
tests/test_gitlabcomments.py Outdated Show resolved Hide resolved
@vchrombie
Copy link
Member Author

Thanks @valeriocos.
I left a lot of things pending, my bad.
I will get back to you after fixing them. 👍

@valeriocos
Copy link
Member

No worries, thank you for working on this PR

@@ -11,10 +11,10 @@ assignee_org_name,keyword,true,"Assignee organization name."
assignee_user_name,keyword,true,"Assignee user name from SortingHat."
assignee_uuid,keyword,true,"Assignee UUID from SortingHat."
author_bot,boolean,true,"True if the given author is identified as a bot, from SortingHat profile."
author_domain,keyword,true,"Domain associated to the author in SortingHat profile."
Copy link
Member Author

Choose a reason for hiding this comment

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

Hi @valeriocos
I was confused about this deletion.

I didn't see this (author_domain) in the mapping too, but assignee_domain and merged_by_domain are present.
Can you check test the enricher once and let me know if you have this?

The same deletion is present in the merge_request too.

Copy link
Member

Choose a reason for hiding this comment

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

*_domain fields are added by SortingHat. By default GitLab users don't have their emails exposed on the API. However, if you execute sortinghat with a matching algorithm that joins the identities based on username and email (the algorithms are available here), the email information can be collected. The *_domain fields should be filled and thus they will appear in the mapping.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, got it. So, I will add them back to the schema then.

Copy link
Member

Choose a reason for hiding this comment

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

Perfect, let me know when I can review the PR, thanks!

@vchrombie
Copy link
Member Author

Also, I have made a small script to generate schema file of an es index, generate-es-index-schema-py.
This was built on top of @animeshk08's script as it had some backlogs.

The script can be improved by adding the idea of default field and adding descriptions. Please leave your comments in the gist or you can open an issue here, vchrombie/grimoirelab-scripts. Feedback is highly welcomed. ^^

@vchrombie
Copy link
Member Author

Hi @valeriocos
I have updated the PR as per your suggestions.
Can you review this when you are free?
Thanks.

Copy link
Member

@valeriocos valeriocos left a comment

Choose a reason for hiding this comment

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

Hi @vchrombie ,

The PR is almost ready to be merged, thank you for your work! Please check the comments (for the ones concerning the test coverage, try to address them if possible).

Please check the actions below too:

"type": "text",
"index": true
},
"id": {
Copy link
Member

Choose a reason for hiding this comment

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

Is this mapping needed?

grimoire_elk/enriched/gitlabcomments.py Show resolved Hide resolved
grimoire_elk/enriched/gitlabcomments.py Show resolved Hide resolved

item = self.items[0]
eitem = enrich_backend.get_rich_item(item)
self.assertEqual(item['category'], 'issue')
Copy link
Member

Choose a reason for hiding this comment

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

can you add an assert to check the item_type? This applies also to the other items in this test

grimoire_elk/enriched/gitlabcomments.py Outdated Show resolved Hide resolved
grimoire_elk/enriched/gitlabcomments.py Show resolved Hide resolved
rich_mr.update(self.get_item_project(rich_mr))

if 'project' in item:
rich_mr['project'] = item['project']
Copy link
Member

Choose a reason for hiding this comment

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

Not covered by the tests

grimoire_elk/enriched/gitlabcomments.py Outdated Show resolved Hide resolved
grimoire_elk/enriched/gitlabcomments.py Show resolved Hide resolved
grimoire_elk/enriched/gitlabcomments.py Show resolved Hide resolved
@valeriocos
Copy link
Member

please @vchrombie ping me when the PR is ready for review, thanks

@almereyda
Copy link

Coming from outside and having dismissed GrimoireLab previously for lacking GitLab support, I would still like to see it support additional code forges other than GitHub, as per the arguments in inhttps://github.com/chaoss/grimoirelab/issues/284#issuecomment-827155190).

Is there something me as an outsider can contribute to the formal aspects of the PR, in so the remaining technical questions can be answered more easily? Speaking of:

  • rebase on master
  • update elk readme
  • add mordred supported data sources documentation (PR)
  • update tests for edge cases and error conditions

@vchrombie
Copy link
Member Author

vchrombie commented Apr 27, 2021

Hi @almereyda, thanks for your comment.

Coming from outside and having dismissed GrimoireLab previously for lacking GitLab support

Sorry about it, but the current GrimoireLab supports analyzing issues and merge requests from the gitlab projects (reference). This PR is an additional enricher which can analyze the comments of the gitlab issues and mrs. I couldn't complete it because I completely forgot about this.

Is there something me as an outsider can contribute to the formal aspects of the PR, in so the remaining technical questions can be answered more easily? Speaking of:

Thanks for offering help, I appreciate it. But, I think I can complete the work on this PR. I can pull some time during the coming weekend and complete the pending work.

@vchrombie vchrombie force-pushed the gitlabcomments branch 2 times, most recently from 78a9e7f to 84580a1 Compare September 11, 2021 15:46
This commit adds a new enricher to handle gitlab comments
data. This is the github2 version for gitlab. The tests
are added accordingly.

Signed-off-by: Venu Vardhan Reddy Tekula <[email protected]>
@vchrombie vchrombie changed the title [enriched-gitlabcomments] New enricher to handle gitlab comments [gitlabcomments] Add enricher to handle gitlab comments Sep 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants