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

feat: reviewing pull requests blog post #23

Merged
merged 2 commits into from
Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Now you are ready for the first contribution. For GitHub, a dedicated plugin is
image::/assets/img/contribute-to-a-project/github-plugin.png[[The 'GitHub' plugin]
{empty}

=== How can maintainers set up their projects to use {prod}?
=== How can maintainers set up their projects to use {prod}? [[set-up-project]]
Copy link
Contributor Author

@dkwon17 dkwon17 Feb 10, 2022

Choose a reason for hiding this comment

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

[[set-up-project]] was added so that this section can be linked here:

Please refer to these references on how to set up your project with {prod}:
* <<../../01/11/@ilya.buziuk-contributing-for-the-first-time-to-a-project#set-up-project,How can maintainers set up their projects to use Eclipse Che?>>


- Deploy {prod} on a {orch-name} cluster or use link:https://workspaces.openshift.com/[Eclipse Che hosted by Red Hat].

Expand Down
174 changes: 174 additions & 0 deletions _posts/2022-02-16-reviewing-pull-requests.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
---
title: Reviewing pull requests
layout: post
author: David Kwon
description: >-
Reviewing pull requests with Eclipse Che.
categories: []
keywords: ['GitHub', 'pull request', 'review', 'reviewng', 'PR']
slug: /@david.kwon/reviewing-pull-requests
---

Reviewing pull requests for a GitHub project integrated with {prod}.

=== Using {prod} to review pull requests

With Google Chrome, {prod} makes it possible to review a pull request (PR) without setting up runtimes, build tools, or any extra software on the local machine.

This blog post will showcase the typical workflow of reviewing PRs of a GitHub project that is well-integrated with Eclipse Che. Here is the GitHub project used in this blog post: link:https://github.com/che-incubator/quarkus-api-example[www.github.com/che-incubator/quarkus-api-example].

You can refer to these articles on how to set up your project with {prod}:

* <<../../01/11/@ilya.buziuk-contributing-for-the-first-time-to-a-project#set-up-project,How can maintainers set up their projects to use Eclipse Che?>>
* link:https://www.eclipse.org/che/docs/che-7/end-user-guide/authoring-devfiles-version-2[Authoring a devfile v2]

NOTE: Your project must contain a well-defined `devfile.yaml` file to make the most out of your development experience with {prod}. Use the devfile to define your project’s development environment such as development commands, containers, endpoints, and so on.

WARNING: The following scenario uses devfile v2, and {prod} is deployed alongside the {devworkspace} engine which is currently not used on link:https://workspaces.openshift.com/[Eclipse Che Hosted by Red Hat]. To open the test GitHub project on Eclipse Che Hosted by Red Hat, please use the link:https://github.com/che-incubator/quarkus-api-example/tree/devfilev1[devfilev1] branch which supports the deprecated devfile v1.

=== The scenario

Imagine that you're developing a REST API with Quarkus that interacts with `Food` resources from a PostgreSQL database.
[source,java]
----
/* Food.java */

@Entity
public class Food extends PanacheEntity {

@Column(length = 40)
public String name;

@Column(length = 40)
public String restaurantName;

public double price;

}
----

In the current state of the project, there are four endpoints:
[cols="1,1,1"]
|===
|Method |Endpoint |Description

|`GET`
|`/food`
|Lists all Food resources

|`GET`
|`/food/{id}`
|Retrieves the Food resource with the specified ID

|`GET`
|`/food/search/{name}`
|Retrieves a Food resource with the specified name

|`POST`
|`/food`
|Creates a Food resource
|===

It looks like your colleague has opened a new PR that adds a new `GET` endpoint, `/food/restaurant/{restaurantName}`. The endpoint retrieves a list of all `Food` resources served from a specified restaurant:

image::/assets/img/reviewing-pull-requests/pr.png[The pull request to review]
Figure 1: The GitHub PR you need to review.

Review this PR by launching a new {prod} workspace. Here you can verify the PR by running unit tests, running the application, accessing the endpoint, and building the application, all within your web browser.

Start the workspace and Web IDE editor on link:https://www.eclipse.org/che/docs/che-7/hosted-che/hosted-che/[Eclipse Che Hosted by Red Hat] by clicking the {prod} badge from the base GitHub repository's `README`:

image::/assets/img/reviewing-pull-requests/badge.png[Badge used to start workspaces]
Figure 2: Clicking on a badge from the base repository's `README.md` launches a developer workspace.

=== Launching a workspace and reviewing the PR
image::/assets/img/reviewing-pull-requests/ide.png[The Che-theia editor]
Figure 3: The Che-Theia editor.

After you start the workspace, the web IDE will open automatically and you'll see that the project has been cloned already (see the Explorer view on the left-hand side).

To use the link:https://github.com/Microsoft/vscode-pull-request-github[GitHub Pull Requests and Issues] extension, you must first authenticate with GitHub by clicking on the Accounts icon on the bottom left of the editor. The extension adds the GitHub view to the sidebar and provides integration with GitHub. As a result, you can make PR comments, in-editor comments, approve PRs, and much more, all from the web IDE.


Click on "Sign in to user GitHub Pull Requests and Issues (1)".
You will be prompted to enter your GitHub credentials to sign in.

image::/assets/img/reviewing-pull-requests/sign-in.png[The context menu appears after clicking the Accounts icon, 600]
Figure 4: The menu appears after clicking the Accounts icon.

After signing in, navigate to the GitHub view from the sidebar to see an overview of PRs against the base repository. Under the "Assigned To Me" drop-down, you can see the PR that you'll review.

image::/assets/img/reviewing-pull-requests/github-view.png[Viewing the PR within the web IDE, 400]
Figure 5: The GitHub view, opened by clicking on the fifth icon from the top.

WARNING: If you start a workspace with a badge generated using the link:https://github.com/marketplace/actions/try-in-web-ide[Try in Web IDE] GitHub action on a PR from a forked repository, you must manually set up Git remotes to use the GitHub Pull Requests and Issues extension. Please see link:https://github.com/redhat-actions/try-in-web-ide/issues/14[redhat-actions/try-in-web-ide#14].

The "Description" menu item, as well as a file hierarchy with all changed files, are in the drop-down menu below the PR. In this case, the changed files are `FoodResource.java`, `FoodEndpointTest.java`, and `README.md`. Click on the files to open a diff view within the web IDE. Examine these files and verify that the PR adds a new endpoint, as well as a unit test.

Click on the "Description" menu item to open a new web view displaying the PR in a UI similar to GitHub. Check out the branch by clicking "Checkout" at the top right of Figure 6.

image::/assets/img/reviewing-pull-requests/pr-view.png[Viewing the PR within the web IDE]
Figure 6: A webview displaying details about the PR. This web view appears after clicking the "Description" menu item from Figure 5.

The test project includes a preinstalled link:https://github.com/redhat-developer/vscode-java[Language support for Java ™] extension in the web IDE. With this extension, you can check the Problem view to verify that there are no compilation problems such as syntax errors.

image::/assets/img/reviewing-pull-requests/no-problems.png[No problems reported by the Java extension]
Figure 7: No problems reported by the Java extension in the Problems view.

=== Running unit tests and building
The devfile also defines commands for testing, building, and launching the application. Run the unit tests by opening the Workspace view from the right side and clicking `(User Runtimes -> tools -> runtests)`.

This runs the test command (`./mvnw test`) within the `tools` container as specified in the devfile. You can view the test output in the output panel.

image::/assets/img/reviewing-pull-requests/run-tests.png[Running the unit tests]
Figure 8: Unit testing by clicking `runtests` from the Workspace view on the right.

As you can see in the output from Figure 8, you passed the tests successfully.

You can also run other commands such as `(User Runtimes -> tools -> package)` to build the application.

image::/assets/img/reviewing-pull-requests/build.png[Successfully building the application]
Figure 9: Successfully building the application.

NOTE: The `packagenative` command is used to build a native image with GraalVM. The command would fail for this test project on link:https://www.eclipse.org/che/docs/che-7/hosted-che/hosted-che/[Eclipse Che Hosted by Red Hat] due to the 7GB memory usage limit.

=== Running the application
Run the Quarkus application in link:https://quarkus.io/guides/getting-started#development-mode[development mode] by running the `(User Runtimes -> tools -> startdev)` command to access the endpoint.

image::/assets/img/reviewing-pull-requests/start-dev.png[Starting the application in development mode]
Figure 10: Starting the Quarkus project in development mode by clicking `startdev` from the Workspace view on the right.

Next, access the new `/food/restaurant/{restaurantName}` endpoint. Here, you access `/food/restaurant/Local Deli` to get all `Food` resources from the restaurant named `Local Deli`.

image::/assets/img/reviewing-pull-requests/access-endpoint.png[Accessing the new endpoint]
Figure 11: Response from `/food/restaurant/Local Deli`.

The response contains two `Food` resources from the `Local Deli` restaurant. This is a match with the `Food` resources from this restaurant in the link:https://github.com/che-incubator/quarkus-api-example/blob/main/src/main/resources/import.sql[`import.sql`] file.

=== Providing feedback and merging the PR
So far, you have successfully run tests, ran the build, as well as ran the application in development mode to verify that the PR is working correctly.
Next, merge the PR from the web IDE.

Go back to the GitHub PR view (see Figure 5) to provide more comments, and approve the PR. Merge the PR to `main`.

image::/assets/img/reviewing-pull-requests/merge.png[Merging to main from the web IDE]
Figure 12: Clicking "Merge Pull Request" to merge.

image::/assets/img/reviewing-pull-requests/merged.png[Merged to main from the web IDE]
Figure 13: PR has been merged.

=== Conclusion
You have finished reviewing the PR and have successfully merged it from the web IDE editor.
In summary, we have:

* Opened a new {prod} workspace to review the PR
* Checked out the feature branch
* Ran the unit tests
* Built the application
* Ran the application in development mode to verify that the feature works as intended
* Used the GitHub Pull Requests and Issues extension and the Language support for Java ™ extension
* Merged the PR from the web IDE

without any prior setup on your local machine.

Thank you for reading!
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/reviewing-pull-requests/badge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/reviewing-pull-requests/build.png
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.
Binary file added assets/img/reviewing-pull-requests/ide.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/reviewing-pull-requests/merge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/reviewing-pull-requests/merged.png
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.
Binary file added assets/img/reviewing-pull-requests/pr.png
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.
Binary file added assets/img/reviewing-pull-requests/sign-in.png
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.