Difference between revisions of "GitHub Pull Requests"

From Lingoport Wiki
Jump to: navigation, search
(Example of a Pull Request Analyzed with Globalyzer)
(Example of a Pull Request Analyzed with Globalyzer)
Line 11: Line 11:
 
[[File:PrNewSummaryAnalysis.png]]
 
[[File:PrNewSummaryAnalysis.png]]
   
This is pull request <b>#44</b>. The change to the code in the pull request was to add multiple embedded strings and a locale-sensitive method to the files <code>ExampleMain.java</code> & <code>ExamplePanel.java</code>. This pull request is reporting 25 different issues, however since the <code>sonar-project.properties</code> attribute is set to <code>sonar.github.disableInlineComments=true</code>, the top ten issues (sorted by severity, by component, then by line) are put into a summary analysis as a pull request comment.
+
This is pull request <b>#8</b>. The change to the code in the pull request was to add a file containing one embedded string, one locale-sensitive method, one general pattern, and one static file reference to illustrate the different sections of the analysis summary. At the top of the analysis, are issue totals. Then the issues are displayed by type, with the top (up to) ten issues displayed.
   
Globalyzer analysis flagged these lines as critical issues. Clicking on the link next to the issue number will send the user to the line of code in that respective file.
+
Clicking on the file#line link will send the user to the line of code in that respective file. If an issue has associated help, as in the case for most locale-sensitive methods, the issue will appear as a link and clicking the issue will display the associated help.
   
Before merging the code back to master, the developer would typically externalize these strings, fix the locale-sensitive method issue, and re-submit the changed code / resource files for further analysis.
+
Before merging the code back to master, the developer would typically externalize embedded strings, fix locale-sensitive method issues, general pattern issues, and static file references and re-submit the changed code / resource files for further analysis.
   
 
== Pull Request Analysis Configuration ==
 
== Pull Request Analysis Configuration ==

Revision as of 18:18, 27 November 2019

GitHub

GitHub is a Web-based Git repository hosting service. It offers all of the distributed revision control and source code management (SCM) functionality of Git as well as adding its own features.

Git Pull Requests

Files can be committed in a Git branch or directly in Master. When committing files in a branch, pull requests let you know what changes you've made to a repository before they are committed to the repository's master branch. Once a pull request is sent, interested parties can review the set of changes, discuss potential modifications, and even push follow-up commits if necessary.

You can configure Globalyzer to scan the files that changed between the two branches of the pull request, and post a Globalyzer Analysis Summary on the pull request in Github.

Example of a Pull Request Analyzed with Globalyzer

PrNewSummaryAnalysis.png

This is pull request #8. The change to the code in the pull request was to add a file containing one embedded string, one locale-sensitive method, one general pattern, and one static file reference to illustrate the different sections of the analysis summary. At the top of the analysis, are issue totals. Then the issues are displayed by type, with the top (up to) ten issues displayed.

Clicking on the file#line link will send the user to the line of code in that respective file. If an issue has associated help, as in the case for most locale-sensitive methods, the issue will appear as a link and clicking the issue will display the associated help.

Before merging the code back to master, the developer would typically externalize embedded strings, fix locale-sensitive method issues, general pattern issues, and static file references and re-submit the changed code / resource files for further analysis.

Pull Request Analysis Configuration

  1. Configure github.properties
  2. You must create the file /var/lib/jenkins/Lingoport_Data/Dashboard/github.properties with the following contents:

      github.login=<your github login>
      github.oauth=<your github token>
    

    Note: To create a token for yourself on Github, navigate to https://github.com, select Settings from login dropdown, select Developer Settings on left, select Personal access tokens, click Generate new token.

  3. Create a Pull Request Jenkins Job
  4. Create a new Jenkins job named <YourRepoName>-PullRequest by copying the existing RepoName-PullRequest job.
    You only need to configure the token for this new job.

  5. Create a Web Hook for your Github Repository
  6. The Pull Request on GitHub needs to trigger a Web hook back to Lingoport's Jenkins instance. To do so:

    • Navigate to the GitHub repository as an Admin account
    • In Settings tab for the GitHub repository (available if the account has Admin permissions), add a Webhook
    • The Web hook should follow this pattern:
      Payload URL: http(s)://JENKINS_URL/jenkins/buildByToken/buildWithParameters/build?job=YourRepoName-PullRequest&token=YourToken
    
      Content type: application/x-www-form-urlencoded
    
      Pull Request event selected
    
      Active
    

    For example:

    GitHubWebhook.png

    • Test the Web hook and especially check for firewall issues going back to the Jenkins system