> For the complete documentation index, see [llms.txt](https://help.autify.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.autify.com/nocode-web/en/autify-university/integrations/integrate-with-code-review-process.md). Agents can also search and read this documentation through its [MCP server](https://help.autify.com/~gitbook/mcp).

# Integrate with code review process

You can run Autify's end-to-end testing during code review process so that the proposed changes can be verified just like you do on staging/production environments. This document describes what is the benefit of this integration and how to do that.

{% hint style="info" %}
**Recommend to read** [**CI/CD with Autify**](https://help.autify.com/nocode-web/en/autify-university/integrations/cicd-with-autify.md) **first**

[CI/CD with Autify](https://help.autify.com/nocode-web/en/autify-university/integrations/cicd-with-autify.md) describes general concept of CI/CD and several possible CI/CD integrations including code review process.

If you haven't read it yet, we highly recommend to read it first!
{% endhint %}

## Why running Autify during code review process?

Code review is the first step of the software release process. A person proposes some changes to the code base and the other person reviews the change whether they are valid, working as expected, and won't break unnecessary functionalities, etc. There are lots of automated techniques to make code reviews easier, reliable and wider perspective, such as unit test. Unit test can cover bunch of functionalities of the software, but you also want to test some kind of end-to-end experience such as login operation by real browser. Historically, implementing such end-to-end test scenario by code is not an easy task but Autify can provide a solution here. By using Autify's intuitive recorder and scenario editor, you can create an end-to-end test scenario in 5 minutes and no need to worry about the maintenance of the scenarios because Autify can resolve and learn majority of UI changes like CSS class. Therefore, Autify can validate whether the proposed code changes can pass the same end-to-end scenario recorded in the production environment and this gives more confidence to the reviewer.

![](https://1964297753-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVdZPTgwISYb3LhjgKnw6%2Fuploads%2Fgit-blob-516522b06e12bbe84de1219d7319d67ce19d6094%2FCI_CD-with-Autify-2.png?alt=media)

## How to run Autify during code review process?

Autify needs an endpoint i.e. URL accessible from its test execution engine in cloud for running test scenarios. Therefore, you need to setup an ephemeral endpoint per Pull request on GitHub, for example, and tell Autify to replace the recorded URL e.g. production URL to the generated ephemeral URL.

How to setup such ephemeral endpoint depends on your infrastructure. For example, some deployment providers like Vercel have a preview feature and a preview endpoint will be automatically created for every pull request out-of-the-box. Or, you can setup your own deployment workflow by using Infrastructure as a Code solution and spin up an ephemeral environment for the pull request.

In summary, you will need a workflow engine that controls task dependencies, and a mechanism to generate ephemeral endpoints to the apps built based on your changes. See the table below to get more insights:

| What you need             | Why you need?                             | Examples                                     |
| ------------------------- | ----------------------------------------- | -------------------------------------------- |
| **Workflow engine**       | To kick a job to setup ephemeral endpoint | GitHub Actions, GitHub App, CircleCI, etc... |
| **(Deployment) Platform** | To setup and run an ephemeral endpoint    | Vercel, Netlify, Amazon EC2, etc...          |

{% hint style="danger" %}
**In most cases, this setup of the ephemeral endpoint is the hardest part for you.**

Because you need to think carefully about all other resources like database, microservices, 3rd partiy integrations such as Auth0, Stripe, etc. Some can be created as an isolated resource but some others can't be.
{% endhint %}

{% hint style="info" %}
**Autify Connect integration**

Autify Connect has a really interesting feature to enable this capability easily by running a development server inside CI/CD runners. See more details [here](https://help.autify.com/nocode-web/en/autify-university/integrations/autify-connect-integration.md).

<img src="https://1964297753-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVdZPTgwISYb3LhjgKnw6%2Fuploads%2Fgit-blob-94c8978aa0b24a4dd06efb1cb6a0d1c9f66f2f21%2Fautify-connect-case-3.png?alt=media" alt="" data-size="original">
{% endhint %}

If you *already have such workflows*, though, you can easily hook it up and run Autify test scenarios against the ephemeral endpoint. In short, the steps are like below:

1. **Fetch the ephemeral endpoint in your CI/CD solution when a code review is created/updated**
2. **Run Autify tests to the ephemeral endpoint**
3. **Feedback to the code review**

In the following example, we will demonstrate this with GitHub Actions and Vercel.

## Example setup: GitHub and Vercel

In this example, we're going to use GitHub as a source code repository and Vercel as an ephemeral deployment environment but you can still get some idea if you use different solutions.

### Vercel's preview URL is an ephemeral endpoint

Once you connect your GitHub repository to Vercel, Vercel automatically executes preview deployment on each push to any pull request and generates a unique preview URL out-of-the-box. This is a good example of the ephemeral endpoint describe above and Vercel bot notifies the preview URL to you via GitHub issue (pull request) comment. See [Vercel's document](https://vercel.com/docs/concepts/git/vercel-for-github#preview-urls-for-the-latest-changes-for-each-pull-request) for more details.

### GitHub Actions can be used as the workflow engine

GitHub Actions is a workflow triggered by various events on GitHub such as code push and it runs pre-defined jobs on the runners. There is a GitHub event when a comment on a GitHub issue is created/edited/etc. so that we can trigger a GitHub Actions workflow whenever the Vercel bot writes a comment on your pull request e.g. preview deployment is done and run any arbitrary jobs like starting Autify tests and feedback the result URL as a comment on the same pull request.

### How to setup GitHub Actions to integrate with pull request?

Since Vercel's preview URL is generated without any other action, we don't have to worry about how to setup the ephemeral endpoint alerted above. We just need to implement the steps 1-3 above. Here is an example setup of GitHub Actions on the repository you deploy to Vercel.

Put the file below at `.github/workflows/issue_comment.yml` under your repository:

{% hint style="warning" %}
This is just an example to demonstrate the idea of the integration with code review process.
{% endhint %}

````yaml
on:
  issue_comment:
    types: [created, edited]

jobs:
  vercel_commented:
    runs-on: ubuntu-latest
    if: ${{ github.event.issue.pull_request && github.event.comment.user.login == 'vercel[bot]' }}
    steps:
      - name: Get preview URL
        id: get-url
        run: |
          body=$(cat <<EOS
          ${{ github.event.comment.body }}
          EOS
          )
          url=$(echo -e "$body" | grep -Eo 'https://[^\/]+\.vercel\.app') || true
          echo ::set-output name=result::"$url"

      - name: Run test on Autify NoCode Web
        id: run
        if: ${{ startsWith(steps.get-url.outputs.result, 'http') }}
        uses: autifyhq/actions-web-test-run@v2
        with:
          access-token: ${{ secrets.AUTIFY_WEB_ACCESS_TOKEN }}
          autify-test-url: https://app.autify.com/projects/00/scenarios/000
          url-replacements: YOUR_RECORDED_VERCEL_URL=${{ steps.get-url.outputs.result }}
        continue-on-error: true

      - name: Comment Autify test result URL on the pull request
        if: ${{ steps.run.conclusion == 'success' }}
        uses: marocchino/sticky-pull-request-comment@v2
        with:
          number: ${{ github.event.issue.number }}
          message: |
            Autify test was started. Check ${{ steps.run.outputs.result-url }}
            ```
            ${{ steps.run.outputs.log }}
            ```

      - name: Comment failed to start Autify test on the pull request
        if: ${{ steps.run.conclusion == 'failure' }}
        uses: marocchino/sticky-pull-request-comment@v2
        with:
          number: ${{ github.event.issue.number }}
          message: |
            Autify test was failed to start.
            ```
            ${{ steps.run.outputs.log }}
            ```
````

{% hint style="info" %}
`YOUR_RECORDED_VERCEL_URL` in "Run test on Autify NoCode Web" step must be replaced by your Vercel application URL e.g. `https://***.vercel.app` that was used when you record the target test scenario on Autify. This `url-replacements` option tells Autify to replace that URL to the ephemeral endpoint when executing the test scenario.

If you'd like to know more about our CI/CD integrations like GitHub Actions integrations above, see [CI/CD with Autify](https://help.autify.com/nocode-web/en/autify-university/integrations/cicd-with-autify.md).
{% endhint %}

Once you create a pull request, Vercel bot will comment on the pull request once the preview deployment is done like below:

![](https://1964297753-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVdZPTgwISYb3LhjgKnw6%2Fuploads%2Fgit-blob-6f96c2a727f087625f57f8939e96a13af31db37a%2FScreen%20Shot%202022-08-20%20at%2011.40.21%20PM\(1\).png?alt=media)

Then, the GitHub Actions workflow you created above will be triggered, then it will start the Autify test scenario you specified and comment the Autify test result URL and log like below:

![](https://1964297753-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVdZPTgwISYb3LhjgKnw6%2Fuploads%2Fgit-blob-7d45040f04d789a8730c5aaf2bc079b323b3fdf2%2FScreen%20Shot%202022-08-20%20at%2011.51.05%20PM\(1\).png?alt=media)

Now, the reviewer (and of course the requester) can check the test result by clicking the link easily!

{% hint style="warning" %}
**This example intentionally just starts the Autify test but not waits for the test result inside the GitHub Actions workflow.**

Depending on the length of the scenarios, your Autify test execution might take longer time like one hour. If you wait for the test result and feedback whether it succeeded to the comment or GitHub Checks, you need to keep running the "Run test on Autify NoCode Web" step longer like one hour and it might consume your GitHub Actions hosted runner's minutes for one hour if the repository is private. In other word, it could cost much higher. Be aware of that cost if you want to do so.
{% endhint %}

## Conclusion

This document describes the benefit and the concept of Autify integration with code review process and shows an example to run Autify test against Vercel preview URL using GitHub Actions. We hope it would help you to implement your Autify integration with code review process.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.autify.com/nocode-web/en/autify-university/integrations/integrate-with-code-review-process.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
