# Git workflow using Moropo API

Moropo supports the basic usage of a [git workflow](https://docs.github.com/en/get-started/using-github/github-flow), which at its basic level breaks down into the below stages;

1. [#create-branch](#create-branch "mention")
2. [#make-changes](#make-changes "mention")
3. [#create-a-pull-request](#create-a-pull-request "mention")
4. [#address-review-comments](#address-review-comments "mention")
5. [#merge-pull-request](#merge-pull-request "mention")
6. [#delete-branch](#delete-branch "mention")

All git platforms are different, but all adhere to this basic workflow.\
\
Moropo can be used to complement this workflow using CI workflows to ensure that changes are tested when a PR is raised, and results fed back.

The below sections will go through Moropo's suggested implementation of the git workflow using the Moropo platform. However, we realise every organisation is different and needs can be complex. If you feel that the workflow isn't quite right for you, let us know and we will help work out a solution.

### Assumptions

Before continuing it is worth stating the assumptions made by us in this guide

1. You are using git
2. You are using a CI system which has access to your git repository
3. You wish to version control your tests in your git repository
4. Test editing can be done either locally or on the Moropo platform

### Create Branch

When creating a branch in your git platform, CI can be configured to replicate this branch in Moropo by;

1. Creating a branch using the [Branches](/ci-integration/moropo-api/branches.md) endpoint
2. Uploading any tests required to the branch using the [Tests](/ci-integration/moropo-api/tests.md)endpoint.&#x20;

{% hint style="warning" %}
By default, branches are initialised in an empty state. If you wish to create a copy of an existing branch, download and then upload tests between the source and target branches.
{% endhint %}

### Make Changes

Changes to tests can be made locally on git, or on the Moropo platform. We don't prescribe how you write your tests.

### Create a Pull Request

As part of CI pipeline logic for creating a PR, we suggest that tests are synced between git & Moropo before any test runs are triggered. We would therefore suggest

1. Either uploading or downloading tests from/to Moropo using the [Tests](/ci-integration/moropo-api/tests.md) endpoint to ensure the two systems are in sync.&#x20;
2. Uploading any builds once built by the CI pipeline using the [Builds](/ci-integration/moropo-api/builds.md) endpoint
3. Triggering tests against the required branch using the [Test Runs](/ci-integration/moropo-api/test-runs.md), ensuring the buildId for the uploaded is build is passed to the action.
4. Polling the [Test Runs](/ci-integration/moropo-api/test-runs.md) endpoint for the status of the test to set the CI check statuses.

### Address Review Comments

If any comments required changes to code, or to the tests, we would expect the actions in [#create-a-pull-request](#create-a-pull-request "mention") to be ran again.

### Merge Pull Request

In order to make sure the Moropo target branch is up to date with the changes, tests must be uploaded to the target branch using the [Tests](/ci-integration/moropo-api/tests.md) endpoint to ensure the tests in the Moropo UI are kept up to date with git.

{% hint style="info" %}
Consider the merge strategy required when merging. See [Tests](/ci-integration/moropo-api/tests.md#example-upload-tests) for more information.
{% endhint %}

### Delete Branch

Once the git workflow is complete, the branch can be deleted in Moropo by calling the [Branches](/ci-integration/moropo-api/branches.md) endpoint.


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.moropo.com/guides/git-workflow-using-moropo-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
