Commit 6037092b authored by Dan Plumbley's avatar Dan Plumbley Committed by Ian Ernst
Browse files

Resolve "ILT Lab Update - GitLab Duo Principles"

parent abb66c79
Loading
Loading
Loading
Loading
+6 −8
Original line number Diff line number Diff line
@@ -15,11 +15,11 @@ In this task, we are going to generate a basic 'hello world' program in Go using

1. Navigate to your *Duo Demo* project.

1. Select **Edit > Web IDE**.
1. Select **Code > Web IDE**.

    > **Note:** In this lab we are using the Web IDE, but you can also use Duo Chat and other Duo tools in your local IDE. [See available extensions](https://docs.gitlab.com/ee/user/project/repository/code_suggestions/supported_extensions.html#supported-editor-extensions).

1. In the Web IDE, locate the GitLab Duo Chat icon. This icon will be the last item in the left side bar, showing the GitLab icon.
1. In the Web IDE, locate the GitLab Duo Chat icon. This icon will be the last item in the left side bar, showing a chat bubble icon.

1. In the chat text input, enter the text `How do I create a hello world Go program?`

@@ -55,7 +55,7 @@ Being able to generate code is only one part of the software development process

1. In the Web IDE, highlight all of the code in your `main.go` file.

1. Select the GitLab Duo icon from the left sidebar.
1. Select the GitLab Duo Chat icon from the left sidebar.

1. With the code still highlighted, type `/explain` into the chat prompt text box.

@@ -73,7 +73,7 @@ Now that you have code generated and you understand the code, you can commit the

1. Select `Go to Project` to return to your GitLab repository.

## Task D. Add a `.gitlab-ci.yml` File
## Task D. Add a .gitlab-ci.yml File

The last step of this lab is to create a `.gitlab-ci.yml` file to build our Go application.

@@ -98,12 +98,10 @@ The last step of this lab is to create a `.gitlab-ci.yml` file to build our Go a
   ```

   > This `.gitlab-ci.yml` file has one stage `build` with a job `build app` that runs as part of the stage. This job runs our `main.go` app.
   >
   > Again, feel free to highlight the YAML and use `/explain` in GitLab Duo chat to explain the CI pipeline!

1. In the **Commit message**, type any appropriate message.
1. Commit this code. In the **Commit message**, type any appropriate message.

1. Ensure the **Target Branch** field is set to main.
1. Ensure the **Branch** selection is set to "Commit to the current `main` branch".

1. Select **Commit changes**.

+20 −12
Original line number Diff line number Diff line
@@ -15,17 +15,13 @@ GitLab Duo extends beyond just code generation. GitLab Duo can support you throu

1. In your project, from the left sidebar, select **Plan > Issues**.

1. Select **New issue**.
1. Select **New item**.

1. For the Title, input `Update hello world visuals`.

1. If your editor is in **rich text editing** mode, Select `Switch to plain text editing` at the bottom of the issue description.
1. Leave the description blank for now and create the issue by selecting **Create issue**.

   > GitLab Duo will only display in plain text editing mode. If you do not see the Tanuki button, you are likely in rich text editing mode.

1. In the Description box, select the Tanuki button, then select **Generate issue description**.

1. In the issue description generation box, type the prompt: `We want to make our "hello world" application more visually appealing for the end user. We want to incorporate the Go Figure module into our application to print out more exciting text.`
1. Let's get Duo's help with the description. Open the newly-created issue by selecting it from the Issue list. In a Chat window, type the prompt: `Please generate me a description for this issue. We want to make our "hello world" application more visually appealing for the end user. We want to incorporate the Go Figure module into our application to print out more exciting text.`

1. Select **Submit**.

@@ -37,13 +33,11 @@ GitLab Duo extends beyond just code generation. GitLab Duo can support you throu
   The current "hello world" application prints basic text without any formatting or visual elements. We want to enhance the user experience and make the application output more interesting to look at.

   The Go Figure module allows printing text in different styles and formats. Integrating this module into our "hello world" code will let us customize how the message is displayed, such as changing fonts, colors, effects and more. This will make our application stand out more and be more enjoyable for end users to interact with.

   ***
   _Description was generated using AI_

   ```

1. Assign the issue to yourself and select **Create issue**.
1. Copy this response, and add it as the description to your issue by selecting the **edit** button and pasting the ai-generated description into the Description field.

1. Assign the issue to yourself and select **Save changes**.

## Task B. Creating a Merge Request

@@ -76,6 +70,8 @@ GitLab Duo extends beyond just code generation. GitLab Duo can support you throu
   }
   ```

   > **NOTE**: Ensure that you are no longer importing the `fmt` module, as this will cause a pipeline error now that we are not using it.

1. Copy the generated code.

1. From the left sidebar, select the Explorer icon.
@@ -140,6 +136,18 @@ GitLab Duo extends beyond just code generation. GitLab Duo can support you throu
       - go run main.go
   ```

1. As we are now dealing with Go modules, we will need a go.mod file. Again, this is something Duo can help us with! In the GitLab Duo chat panel, write something like: `Please create the go.mod file for this application`. It will return something like the below:

   ```go
   module hello-world-figure

   go 1.21

   require github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be
   ```

1. Copy this code, and add it to a new file called `go.mod`.

1. From the left sidebar, select the Source Control icon.

1. Enter any commit message and select the **Commit** button to commit the code changes.
+11 −42
Original line number Diff line number Diff line
@@ -13,9 +13,7 @@ In this lab, you will see how GitLab Duo can help with explaining and resolving

1. Navigate to your *Duo Demo* project.

1. Select the `.gitlab-ci.yml` file.

1. Select **Edit > Edit in pipeline editor**.
1. Select **Build > Pipeline editor**.

1. Remove all previous YAML and add the following code. Your `.gitlab-ci.yml` should look as follows:

@@ -27,7 +25,7 @@ In this lab, you will see how GitLab Duo can help with explaining and resolving
      - template: Security/SAST.gitlab-ci.yml
    ```

1. Input any Commit message, set the target branch to **main**, then select **Commit changes**.
1. Input any Commit message, ensure the target branch is set to **main**, then select **Commit changes**.

1. In the left sidebar, select **Code > Repository**.

@@ -65,13 +63,11 @@ In this lab, you will see how GitLab Duo can help with explaining and resolving

1. Once the pipeline completes, in the left sidebar navigate to **Secure > Vulnerability Report**.

    > You will see a single vulnerability, `Slowloris` displayed in your report.

1. Select the vulnerability "Uncontrolled resource consumption...".
1. Select the vulnerability "Allocation of resources without limits or throttling".

    > This will navigate you to the vulnerability overview page.

1. At the top right of vulnerability overview, select the **Explain or Resolve with AI** dropdown.
1. At the top right of vulnerability overview, select the **AI vulnerability management** dropdown.

1. Select **Explain with AI**.

@@ -79,46 +75,19 @@ In this lab, you will see how GitLab Duo can help with explaining and resolving

## Task B. Resolve the Vulnerability (Optional)

1. Adapt the suggestion from Duo chat to our `main.go` file.
  > Now that we have a clear understanding of the vulnerability, let's get it fixed!

1. It should look something like the following:
1. At the top right of vulnerability overview, select the **AI vulnerability management** dropdown.

    ```go
    package main
1. Select **Resolve with AI**

    import (
      "net/http"
      "fmt"
      "math/rand"
      "time"
    )
1. Duo will create a new branch for you, make the necessary code changes, and then create the MR and redirect you to it. 

    func randomGitlab(w http.ResponseWriter, r *http.Request) {
      words := []string{"git", "lab", "repo", "commit", "branch"}
      word := words[rand.Intn(len(words))]
1. Select the **Changes** tab of the newly-created MR to check that you are happy with the changes Duo has made.

      fmt.Fprintf(w, word)
    }


    func main() {

        http.HandleFunc("/random", randomGitlab)
        // Create a new HTTP server with timeout configurations
        server := &http.Server{
            Addr:           ":8080",
            ReadTimeout:    10 * time.Second,
            WriteTimeout:   10 * time.Second,
            MaxHeaderBytes: 1 << 20, // 1 MB
        }

        // Start the server
        server.ListenAndServe()
      
    }
    ```
1. If so, head back to the **Overview** tab, read through Duo's MR description and then click **Merge**. 

1. Run the pipeline again to check for the resolved vulnerability.
1. Once the pipeline from this merge has successfully completed, check the **Vulnerability Report** again to make sure the vulnerability has been resolved.

## Lab Guide Complete

+8 −8
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@ By the end of this lab, you will learn how to:

## Task A: Create issues and Merge Requests via Duo Agentic Chat

1. Select the **New project** button.
1. On the top of your screen, select **+ > New project/repository**.

1. Select the **Create from template** tile.

@@ -25,13 +25,15 @@ By the end of this lab, you will learn how to:

1. In the Project name field, enter **DAP Demo**.

1. In the Project URL field, select your **group** from the dropdown (not your user).

1. Leave everything else as default and select **Create project**

    Throughout this workshop, you will get AI-generated support from GitLab Duo Chat.
    Throughout this workshop, you will get Agentic AI-generated support from GitLab Duo Chat.

1. In the upper-right corner, select the GitLab Duo Chat icon and choose `Add new Chat`.
1. In the upper-right corner, select the GitLab Duo Chat icon.

1. Select GitLab Duo. If you are already using the GitLab Duo agent, click **Current GitLab Duo Chat**.
1. Select the GitLab Duo agent. If you are already using the GitLab Duo agent, click **Current GitLab Duo Chat**.

    **NOTE:** If you didn't get the option of choosing the agent, it is probably because you are not using Agentic chat. If this is the case, simply click on the `Agentic` slider just above the input field to activate Agentic chat. Then repeat the step above.

@@ -66,8 +68,6 @@ By the end of this lab, you will learn how to:
    - Any errors encountered
    ```

    > These features are early access and prone to mistake. If you encounter an error /reset, or clicking **New GitLab Duo Chat** again can help.

1. If you are asked to `Approve` an action Duo Chat wants to execute, please do so.

    > Duo Chat will create issues, merge Request on existing branches for us, so that we have a project setup we can work with. It will be around 9 approvals you need to give. You are the HITL (Human in the Loop). Then you will see as a closing statement a `Completion Report`
@@ -96,9 +96,9 @@ Let's explore how GitLab Duo Chat can act as an intelligent agent to help with v

1. Edit the Assignees section, and assign the issue to yourself.

1. Again click **Add new chat** button, and select **GitLab Duo Chat**.
1. Again click **Add new chat** button, and select **GitLab Planner Agent**.

1. Prompt in the chatbox with the following (make sure Agentic mode is switched on):
1. Prompt in the chatbox with the following:

    ```prompt
    Give me the Quick Wins for this project.