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

Add GitHub PRs to the Static Analysis integrations #20981

Merged
merged 37 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
79dfed1
Add GitHub PRs to the integrations
jhgilbert Dec 12, 2023
300a7de
Update _index.md
jhgilbert Dec 12, 2023
e59f81d
Update content/en/continuous_integration/static_analysis/_index.md
jhgilbert Dec 12, 2023
2afc082
Update _index.md
jhgilbert Dec 12, 2023
3a6c873
Merge branch 'master' into jen.gilbert/DOCS-5928-github-static-analysis
jhgilbert Dec 20, 2023
103e199
Write feature overview for GitHub source code management
jhgilbert Dec 21, 2023
f7c51e0
Sketch in content outline
jhgilbert Dec 21, 2023
9222b42
Add page to the TOC
jhgilbert Dec 21, 2023
01cb74d
Add section on configuring a GitHub App
jhgilbert Dec 21, 2023
7e60ab2
Add product shot
jhgilbert Dec 21, 2023
da93571
Update product screenshot
jhgilbert Dec 21, 2023
7acc9e3
Flesh out GitHub App instructions
jhgilbert Dec 21, 2023
c713009
Finish first draft of instructions
jhgilbert Dec 21, 2023
b6fba8a
Update content/en/static_analysis/github_source_code_management.md
jhgilbert Dec 21, 2023
b2bec6b
Update content/en/static_analysis/github_source_code_management.md
jhgilbert Dec 21, 2023
02c217b
Update content/en/static_analysis/github_source_code_management.md
jhgilbert Dec 21, 2023
74a05d1
Update content/en/static_analysis/github_source_code_management.md
jhgilbert Dec 21, 2023
de607a0
Update content/en/static_analysis/github_source_code_management.md
jhgilbert Dec 22, 2023
7142033
Integrate feedback
jhgilbert Dec 22, 2023
0dd815d
Rename file
jhgilbert Dec 22, 2023
60dd1bd
Update URL
jhgilbert Dec 22, 2023
63105fc
Integrate feedback
jhgilbert Dec 22, 2023
e63c49b
Update identifier
jhgilbert Dec 22, 2023
10908c8
Update _index.md
jhgilbert Dec 22, 2023
fd283a8
Tweak instructions
jhgilbert Jan 2, 2024
cc0d1d8
Integrate feedback
jhgilbert Jan 3, 2024
63a3296
Update content/en/static_analysis/github_pull_requests.md
jhgilbert Jan 5, 2024
0555113
Update content/en/static_analysis/github_pull_requests.md
jhgilbert Jan 5, 2024
b31fe1c
Update content/en/static_analysis/github_pull_requests.md
jhgilbert Jan 5, 2024
29bc8bb
Update content/en/static_analysis/github_pull_requests.md
jhgilbert Jan 5, 2024
37fca7e
Update content/en/static_analysis/github_pull_requests.md
jhgilbert Jan 5, 2024
9257e83
Update content/en/static_analysis/github_pull_requests.md
jhgilbert Jan 5, 2024
e9b04bf
Update content/en/static_analysis/github_pull_requests.md
jhgilbert Jan 5, 2024
75e6515
Update content/en/static_analysis/github_pull_requests.md
jhgilbert Jan 5, 2024
bb62493
Update content/en/static_analysis/github_pull_requests.md
jhgilbert Jan 5, 2024
e8b23df
Update content/en/static_analysis/github_pull_requests.md
jhgilbert Jan 5, 2024
d8c4970
Spacing Nit
alai97 Jan 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions config/_default/menus/menus.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2620,6 +2620,11 @@ main:
parent: static_analysis
identifier: static_analysis_github_actions
weight: 103
- name: GitHub Pull Requests
url: static_analysis/github_pull_requests
parent: static_analysis
identifier: static_analysis_github_prs
weight: 103
- name: Quality Gates
url: quality_gates/
pre: ci
Expand Down
7 changes: 6 additions & 1 deletion content/en/static_analysis/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,17 @@

## Integrations

### CI Providers
### CI providers

Check warning on line 42 in content/en/static_analysis/_index.md

View workflow job for this annotation

GitHub Actions / vale

Datadog.headings

'CI providers' should use sentence-style capitalization.
{{< whatsnext desc="With Static Analysis, you can integrate feedback on code reviews for various languages in any CI platform provider of choice. See the documentation for information about the following integrations:">}}
{{< nextlink href="continuous_integration/static_analysis/circleci_orbs" >}}CircleCI Orbs{{< /nextlink >}}
{{< nextlink href="continuous_integration/static_analysis/github_actions" >}}GitHub Actions{{< /nextlink >}}
{{< /whatsnext >}}

### Source code management
{{< whatsnext desc="During code reviews, source code management (SCM) integrations check for Static Analysis violations in pull requests for repos that have at least one ruleset applied. Violations are flagged with a comment on the relevant line of code. Certain violations also include suggested changes that can be applied directly in the UI of the SCM tool." >}}
{{< nextlink href="static_analysis/github_pull_requests" >}}GitHub Pull Requests{{< /nextlink >}}
{{< /whatsnext >}}

### IDEs
{{< whatsnext desc="With Static Analysis, you can get real-time feedback as you edit a file in your Integrated Development Environment (IDE). See the documentation for information about the following integrations:">}}
{{< nextlink href="developers/ide_integrations/idea/" >}}Datadog Plugin for IntelliJ IDEA{{< /nextlink >}}
Expand Down
76 changes: 76 additions & 0 deletions content/en/static_analysis/github_pull_requests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
title: GitHub Pull Requests
kind: documentation
description: Learn how to use Static Analysis in GitHub pull requests.
further_reading:
- link: "/integrations/github/"
tag: "Documentation"
text: "Learn about the GitHub integration"
- link: "/static_analysis/"
tag: "Documentation"
text: "Learn about Static Analysis"
---

## Overview

Static Analysis can automatically flag rule violations in pull requests on GitHub. To configure the [GitHub integration][2] to include Static Analysis features, see [the setup instructions](#set-up-static-analysis-for-github-pull-requests).

During code reviews on GitHub, the integration checks for Static Analysis violations in pull requests for repos that have at least one ruleset applied. Violations are flagged with a review comment on the relevant line of code.

{{< img src="ci/static-analysis-pr-comment-example.png" alt="Example of a Static Analysis comment on a pull request" style="width:90%;" >}}

The comment includes the name, ID, severity, category, and description of the violation. Certain violations also include suggested changes that can be applied directly in the GitHub UI.

## Set up Static Analysis for GitHub pull requests

Check warning on line 24 in content/en/static_analysis/github_pull_requests.md

View workflow job for this annotation

GitHub Actions / vale

Datadog.headings

'Set up Static Analysis for GitHub pull requests' should use sentence-style capitalization.

### Enable Static Analysis on Datadog

Check warning on line 26 in content/en/static_analysis/github_pull_requests.md

View workflow job for this annotation

GitHub Actions / vale

Datadog.headings

'Enable Static Analysis on Datadog' should use sentence-style capitalization.

To use Datadog Static Analysis, add the appropriate configuration files to your repository, as described in the [setup instructions][1].

### Configure a GitHub App

Check warning on line 30 in content/en/static_analysis/github_pull_requests.md

View workflow job for this annotation

GitHub Actions / vale

Datadog.headings

'Configure a GitHub App' should use sentence-style capitalization.

To use Static Analysis on GitHub, you can do one of the following:

- Create a GitHub App in Datadog.
- Update an existing GitHub App, if you have already created one in Datadog.

The permissions you grant to the GitHub App determine which [GitHub integration][2] features are available for setup.

#### Create and install a GitHub App

1. In Datadog, navigate to [**Integrations > GitHub Applications > Add New GitHub Application**][3].
1. Fill out any required details, such as the GitHub organization name.
1. Under **Select Features**, check the **Static Analysis: Pull Request Review Comments** box.
1. Under **Edit Permissions**, verify that the **Pull Requests** permission is set to **Read & Write**.
1. Click **Create App in GitHub**.
1. Enter a name for your app, and submit it.
1. Click **Install GitHub App**.
1. Choose which repositories the app should be installed into, then click **Install & Authorize**.

{{< img src="ci/static-analysis-install-github-app.png" alt="GitHub App installation screen" style="width:50%;" >}}

#### Update an existing GitHub App

1. In Datadog, navigate to [**Integrations > GitHub Applications**][5], and search for the GitHub App you want to use for Static Analysis.
{{< img src="ci/static-analysis-existing-github-app.png" alt="Example of a Static Analysis comment on a pull request" style="width:90%;" >}}
1. On the **Features** tab, look at the **Static Analysis: Pull Request Comments** section to determine whether your GitHub App needs additional permissions. If so, click **Update permissions in GitHub** to edit the app settings.
1. Under **Repository permissions**, set the **Pull Requests** access to **Read and write**.
{{< img src="ci/static-analysis-pr-read-write-permissions.png" alt="The dropdown for the pull request read and write permission" style="width:90%;" >}}
1. Under the **Subscribe to events** heading, check the **Pull request** box.
{{< img src="ci/static-analysis-pr-review-comment.png" alt="The checkbox for the pull request review comment permission" style="width:90%;" >}}

### Enable Static Analysis PR comments for your repositories

Check warning on line 62 in content/en/static_analysis/github_pull_requests.md

View workflow job for this annotation

GitHub Actions / vale

Datadog.headings

'Enable Static Analysis PR comments for your repositories' should use sentence-style capitalization.

1. In Datadog, navigate to [**CI Settings** > **Static Analysis Settings**][4].
1. Click the toggle switch next to a given repository to enable **GitHub Comments**. In the example below, comments are enabled for the `demo-static-analysis-gates` repository.

{{< img src="ci/static-analysis-github-comments.png" alt="Example of a Static Analysis comment on a pull request" style="width:100%;" >}}

jhgilbert marked this conversation as resolved.
Show resolved Hide resolved
## Further Reading

{{< partial name="whats-next/whats-next.html" >}}
alai97 marked this conversation as resolved.
Show resolved Hide resolved
[1]: /static_analysis#setup
[2]: /integrations/github/
[3]: https://app.datadoghq.com/integrations/github/add
[4]: https://app.datadoghq.com/ci/settings/static-analysis
[5]: https://app.datadoghq.com/integrations/github/configuration
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
jhgilbert marked this conversation as resolved.
Show resolved Hide resolved
jhgilbert marked this conversation as resolved.
Show resolved Hide resolved
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading