Preview GitLab changes
GDK is a common way to do GitLab development. It provides all the necessary structure to run GitLab locally with code changes to preview the result. This provides:
- A fast feedback loop, because you don’t need to wait for a GitLab Review App to be deployed to preview changes.
- Lower costs, because you can run GitLab and tests locally, without incurring the costs associated with running pipelines in the cloud.
These instructions explain how to preview user-facing changes, not how to do GitLab development.
Prepare GDK for previewing
To prepare GDK for previewing GDK changes:
Go to your GDK directory:
cd <gdk-dir>
Update and start GDK. This ensures your GDK environment is close to the environment the changes:
- Were made in, if you are previewing someone else’s changes.
- Are to be made in, if you are making your own changes.
Go to your local GitLab in your web browser and sign in (by default,
http://localhost:3000
). Verify that GitLab runs properly.Verify the current behavior of the feature affected by the changes. For Enterprise Edition features, you may need to perform additional tasks.
Make changes to GitLab
The process for applying changes to GitLab depends on whether you are:
- Making the changes yourself. When making your own changes, install and run:
- Front-end linting tools when making front-end changes.
- Lefthook when making back-end changes.
- Previewing someone else’s changes.
To make your own changes:
Go to your
gitlab
directory, throw away any changes GDK made when updating that left your checkout unclean, and switch to a newgitlab
project branch:cd <gdk-dir>/gitlab git checkout -- . git checkout -b <your branch name>
Make the necessary changes within the
gitlab
directory.
To apply changes someone else made:
- Switch to the branch containing the changes. The easiest way to do this is to:
Go to the MR with the submitted changes.
From the Overview tab, click the Check out branch button. This displays a procedure.
Copy the commands from Step 1. of the procedure. This adds to the clipboard all the commands required to switch to the branch locally.
Go to your local
gitlab
directory and check you’re on a clean checkout ofmaster
:git status
You can discard any modifications caused by
gdk update
by runninggit checkout -- .
.Paste the contents of the clipboard into your command line window and run them (for example, press enter). Your
gitlab
project branch should now be the branch containing the changes you want to preview. Confirm by running:git status git log
Enable or disable GitLab feature flags
Some work-in-progress features are introduced behind feature flags. To preview features behind disabled flags, you need to first enable the appropriate flag.
To enable a feature flag in your GDK instance:
- Start the Rails console.
- Enable or disable desired flags.
- Exit the Rails console by running
quit
.
Preview changes
After the changes are applied to GitLab:
Go to GitLab in your web browser to preview your changes (by default,
http://localhost:3000
). It might be necessary to refresh the page, or even restart GDK:cd <gdk-dir> gdk restart
If previewing your changes, when you are satisfied with your changes and want to submit them for review, follow the process for submitting a merge request for a
gitlab
branch from the command line.Once the work is completed, we recommend updating GDK again. This means that the next time you want to run it, GDK is based on the default branch for GitLab and not on the changed branch.