Search code examples
gitlabcontinuous-integrationcicd

Is there a way to pre-run tests on the would-be merge commit, if branch were merged, before merge?


We are automatically running tests on feature branches. After the feature is complete and tests pass, it is merged into the main branch.

But now we have to wait for tests to run on master, before deploying it (manually).

So, is there a way to automatically run tests on the would-be merge commit for the Feature Branch, before it is merged to master?

If that were possible, then we would know that tests on master will pass after the Feature Branch is merged.


Solution

  • For this the merged results pipelines might be useful for you. Take a look at https://docs.gitlab.com/ee/ci/pipelines/merged_results_pipelines.html

    Quoting from docs

    A merged results pipeline is a type of merge request pipeline. It is a pipeline that runs against the results of the source and target branches merged together.

    So you could have the tests run preemptively and run the deploy manually

    This functionality is available if your organization has a Gitlab account which is at least in PREMIUM tier.

    By default they are not enabled, to enable merged results pipelines in a project, you must have at least the Maintainer role:

    1. On the top bar, select Menu > Projects and find your project.
    2. On the left sidebar, select Settings > General.
    3. Expand Merge requests.
    4. Select Enable merged results pipelines.
    5. Select Save changes.