Skip to content

Update merge train position using GraphQL

Miguel Rincon requested to merge 429263-use-graphql-merge-train-status into master

What does this MR do and why?

This MR depends on !153954 (merged) being deployed to production. EDIT: Done! Relates to #442453 (closed).

This refactor changes the way in to fetch data about the position of a merge request in a merge train so the fetch is done via GraphQL API.

This change helps us prepare to update the merge train state timely when we use subscriptions in the near future.

MR chain
Adds a mergeTrainIndex field to merge requests (!153954 - merged)
Update merge train position using GraphQL (!153973 - merged) you are here!
Show toast message when merge request is remove... (!153974 - merged) UX change approved now!

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

No changes are expected, the merge request indicator stays the same
image

How to set up and validate locally

I set up a simple project with a pipeline that fails only on merge trains:

workflow:
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'

stages:
  - build

normal-job:
  stage: build
  environment: production
  script:
    - echo "Running..."
    - sleep 30
    - echo "Done."

fail-on-merge-train:
  stage: build
  rules:
    - if: $CI_MERGE_REQUEST_EVENT_TYPE == 'merge_train'
  script:
    - echo $CI_MERGE_REQUEST_EVENT_TYPE
    - sleep 30
    - echo "Failing becuase this is a merge train, sorry!"
    - exit 1

I also enabled Merge trains for the project at Settings -> Merge requests (e.g. http://gdk.test:3000/my-group/merge-trains/-/settings/merge_requests.

When I open any MR, I can test different states on this, without having the MR merged.

Related to #429263 (closed)

Edited by Miguel Rincon

Merge request reports