CodeScene Integration with GitHub Checks

Codescene can integrate with GitHub to provide quality gates for Pull Requests on the Checks tab. To do this, you must create a GitHub App and use the settings for that app when configuring CodeScene.

Follow these steps to enable the Check:

1. Creating a GitHub App

Follow Steps 1–5 here to start creating your GitHub App. Then do the following settings.

  • Homepage URL. The Homepage URL setting is required by GitHub, but you can set it to anything (such as https://www.codescene.io/).

  • Webhook. Set to not active. You will activate it after doing settings in CodeScene.

  • Repository Permissions Grant the following permissions:

Permission

Access

Checks

Read & write

Pull Requests

Read & write

  • Click Create GitHub App. This will take you to your new GitHub App’s page.

  • Private Key. Scroll down to the bottom of the page and click Generate Private Key. This will download a .pem file.

  • Click Save changes.

2. Configure CodeScene’s PR integration

Go to the PR integration tab in the CodeScene project configuration and do the following settings:

  • Select GitHub App.

  • App ID. Copy the value from your GitHub App and set it here.

  • Private Key. Select the .pem file you downloaded when creating the App.

  • Webhook Secret. Specify a value that will be used for encrypting webhook calls.

  • Save the CodeScene GitHub App configuration.

3. Configure the webhooks on your GitHub App

Go to the configuration page for your GitHub App and do the following settings:

  • Webhook. Set to active

  • Webhook URL. Copy the value from the CodeScene GitHub App configration and set it here.

  • Webhook Secret. Set the same value as in your CodeScene Github App configuration.

  • Subscribe to events. Go to the Permissions & Events tab and add subscriptions to Check run, Check suite and Pull request events.

  • Click Save Changes

Install your GitHub App from the settings page for the app. Codescene will now receive webhook calls when PRs are created or updated on any repositories where you have installed the App.

GitHub result presentation

CodeScene integrates with pull requests via GitHub’s checks API. If any Quality Gate is triggered, CodeScene will fail the check and present the results on the Check Run details page:

GitHub Check Run details

Fig. 35 Example of Check Run details in GitHub

GitHub annotations

CodeScene can also create annotations for all Code Health changes in a Pull Request. The annotations will be visible on the Check Run details page:

GitHub annotations in Check Run details

Fig. 36 Example of annotations in GitHub Check Run details

The annotations will link directly to code being modified in the Pull Request, and will also be visible when reviewing the modified files:

GitHub annotations in file view

Fig. 37 Example of annotations in GitHub file view

Annotations will be produced for improvements as well as for degradations. If the Code Health score for the specific biomarker is not degrading, the annotations will be created as notices rather than warnings.

You can enable the annotations by checking an option in the Pull Request integration settings:

Enable GitHub annotations

Fig. 38 Enable GitHub annotations