Introducing GitLab Duo with Amazon Q

Amazon Q Developer has transformed the traditional development workflow by integrating a wide range of generative AI capabilities within the environments where developers work from. This seamless integration helps to maintain focus while accelerating a wide range of development tasks beyond coding for enhanced productivity.

With its vast community of developers, GitLab is a popular DevSecOps platform where many development teams spend their time building and collaborating on projects. That’s why we are so excited to introduce GitLab Duo with Amazon Q. This is a new integration that brings the power of Amazon Q Developer agent capabilities to GitLab using GitLab Duo, transforming it into a unified development experience powering AI-driven DevSecOps. GitLab Duo with Amazon Q leverages AI agents to assist complex, multi-step tasks such as new feature development and codebase upgrades for Java 8 and 11. It also offers enhanced capabilities for code review and unit testing – all within the same familiar GitLab platform.

Interacting with Amazon Q Developer is straightforward through GitLab quick actions— type /q directly inside either the issue description, a general comment, or a merge request comment to start using it to help you accelerate your daily tasks or tackle more complex workflows.

Let’s have a quick tour.

Feature development
Let me show you first how straightforward it is to start using Amazon Q Developer within your GitLab environment when developing new features or improving existing ones.

Imagine that you are working on a web application and you’ve been assigned the task to create a full signup flow. You can ask Amazon Q Developer to generate the whole code for you based on the contents of the issue by adding the /q dev command as a comment.

invoking q dev

Amazon Q Developer analyzes your entire codebase and generates new code, whether in the form of updates to existing files or entirely new ones. After it’s done, it automatically creates a merge request and adds an entry to the Activity history with a link so it can be reviewed.

q generated solution with merge request

On the merge request review page, you’ll notice two interesting things. The first is that Amazon Q Developer has added a comment giving context about the request with instructions for how to request changes if you want to keep iterating. The second one is a follow-up comment where Amazon Q Developer warns that the generated code contains some third-party source material. It provides you with a file that you can download to look up the original code and decide for yourself whether this is something that you’re happy to include in your codebase or not. This makes it effortless to make use of open source responsibly while keeping records for traceability and audit.

the merge request

Before proceeding, you can look through the code and make in-line comments, much like you would with any other merge request. You can then instruct Amazon Q Developer to make changes to the code based on the comments and continue to iterate like that until you’re fully happy with the results . Let’s imagine that your company’s coding standards include a requirement to implement logging for key operations in your code. Unfortunately, this was not included with the initial requirements in the issue’s description before running the /q dev command. However, you can still use Amazon Q Developer to seamlessly add that code during the review process.

To do this, navigate to the Changes tab, find the relevant code lines, and add in-line comments as you would when reviewing a developer’s merge request. For instance, below line 39, a comment is added stating “add logging” to highlight a part of the code that handles errors when calling the signup API. Below it, another comment is added with only /q dev as the text. This standalone comment triggers a quick action to invoke Amazon Q Developer, so it’s essential to keep it separate. Amazon Q Developer will then generate a new revision based on all the comments provided.

It’s worth noting that the /q dev command can be issued from anywhere in GitLab where comments are supported. Although it was convenient to add it here on line 39, the outcome would be the same if the command was issue as a comment on the Overview page, or against any other line of code in the Merge requests page.

After it’s done, Amazon Q Developer notifies you by adding another comment to the merge request history. Again, it also notifies that the generated content contains open source code providing more information about it so you can review it prior to accepting the merge. Upon closer inspection, it’s clear that it has used the logger library, which makes perfect sense considering the request.

Reviewing the code, it’s impressive to see that Amazon Q Developer didn’t only add the calls to log operations where they happen, but also used context to add the relevant log levels, such as info, and warning. Moreover, it also modified the code in other places to make sure the build doesn’t break. For example, it added the import statement at the top of the file and initiated the logger variable.

By using this new development flow, you can move much faster from requirements to code by relying on Amazon Q Developer to help get the tasks done from the convenience of your GitLab environment. After submitting a merge request though, it’s time to perform a code review. Again, you can also use GitLab Duo with Amazon Q Developer to help you accelerate and improve the quality of that process.

Performing code reviews
Let’s work with a different code base, in this case, a Java application. To initiate the assisted code review process, in the merge request overview page, you can submit a comment with the text of /q review. Amazon Q Developer will add an automatic comment to the history informing that it has initiated a review of the merge. It scans all changes looking for security vulnerabilities, quality issues such as code that doesn’t follow best practices, and any other potential problems with the code.

After it’s finished, it will add each finding as a comment that includes a snippet of the problematic code found, a description of the issue, and a severity rating.

You can then take it one step further and ask Amazon Q Developer for a fix! Reply to the findings comment by entering the /q fix command and it will inform you that it is generating a fix for the issue before following it up on the same thread with a solution that you can review. It provides you with a diff view of the changes and an opportunity to accept and commit them.

Upgrading legacy code
In addition to helping you with new code and features, GitLab Duo with Amazon Q Developer can also help automate and accelerate code base migration from Java 8 or 11 to Java 17. Start by creating a new issue and give it a descriptive title such as “Upgrade project to Java 17”. Then, in the Description field, add the command /q transform.

After you create the issue, Amazon Q Developer will follow the same pattern as before and add a comment to the issue’s history to inform you that it’s working on migrating the code base. This comment will be updated after Amazon Q Developer is finished and contain a link to the merge request much like we encountered earlier. It’ll also generate a migration plan that you can review while you wait. The plan contains a collapsible step-by-step list of actions to be taken with detailed information plus links that you can use for further reading.

The merge request produced is rich in details too. It contains general stats such as the number of lines of code that were migrated and the total time taken, among others. It also has a full report with links that you can you use to navigate to different sections so you can read the build log summary, review changes in dependencies, inspect all files changes, and more.

When yo’re ready to review the code, you can accept changes partially or fully, much like with any other merge request.

Conclusion
GitLab Duo with Amazon Q bring together the most comprehensive DevSecOps platform with the most capable generative AI powered assistant for software development. Together, GitLab Duo and Amazon Q offer a seamless developer experience with new capabilities to accelerate feature development and transform workloads, all within the same familiar GitLab environment that developers are used to.

Things to know

  • Getting started – GitLab Duo with Amazon Q is available in preview for GitLab self-managed customers with an Ultimate subscription. Read more on how to get started to learn more about it.
  • Availability – GitLab Duo with Amazon Q is available now under preview for all GitLab self-managed customers with an ultimate tier subscription.

Matheus Guimaraes | @codingmatheus

from AWS News Blog https://ift.tt/5c4PFY9

Share this content:

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top