Operations 10 min read

GitLab Code Review Workflow and Configuration Guide

This article provides a comprehensive guide to GitLab code review, covering environment setup, Git flow basics, review methods, configuration of approvals, templates, issue linking, Code Quality integration with CI/CD, step‑by‑step practice, and recommendations for choosing between Community and Enterprise editions.

NetEase Game Operations Platform
NetEase Game Operations Platform
NetEase Game Operations Platform
GitLab Code Review Workflow and Configuration Guide

1. Environment

The article uses GitLab Community Edition 11.11.4 and GitLab Enterprise Edition 12.6.7; features marked as Enterprise (Starter) are only available in the paid version.

2. Git Flow Overview

Typical branches such as master , hotfix , release , develop and feature are introduced, with a diagram illustrating their purposes.

3. GitLab Code Review Methods

Two common approaches are described: local (merge source branch into target locally then push) and remote (push source branch and create a Merge Request on GitLab).

4. Code Review Configuration

4.1 Approvals and Merge Request Customization

Merge Requests can be configured to require a successful pipeline and all discussions marked as resolved; source‑branch deletion is an Enterprise (Starter)‑only feature.

4.2 Issue and Merge Request Templates

Templates can be added under .gitlab/issue_templates/Issue.md and .gitlab/merge_request_templates/Merge_Request.md to standardize issue and MR content.

4.3 Issue‑MR Linking

When committing to the default branch, keywords such as fix , close , resolve followed by an issue number (with a trailing space) automatically link the commit to the issue.

4.4 Code Quality Feature

The open‑source Code Climate engines can be integrated for code quality checks; displaying the report in the MR UI requires Enterprise (Starter). Example runner and .gitlab-ci.yml configurations are provided.

[runners]
  name = "gitlab_runner_name"
  url = "https://git-test.xxx.com/"
  token = "your_token"
  executor = "docker"
  [runners.custom_build_dir]
  [runners.docker]
    tls_verify = false
    image = "docker:stable"
    privileged = true  # must enable privileged mode
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/cache"]
    shm_size = 0
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
code_quality:
  stage: check
  tags:
    - codequality
  image: registry.test.com/library/debian_ci
  allow_failure: false
  services:
    - name: docker:stable-dind
      alias: docker-codequality
  variables:
    DOCKER_TLS_CERTDIR: ""
    DOCKER_HOST: "tcp://docker-codequality:2375"
    DOCKERHUB_URL: "registry.test.com"
    GIT_LFS_SKIP_SMUDGE: "1"
    AUTH_TOKEN_TTL: "1800"
  before_script:
    - |
      if ! [ -f .codeclimate.yml -o -f .codeclimate.json ] ; then
        cp .gitlab/ci/codeclimate/.codeclimate.yml ./
      fi
    - |
      if ! [ -f tox.ini ] ; then
        # pep8
        cp .gitlab/ci/codeclimate/tox.ini ./
      fi
    - |
      if ! [ -f .pylintrc ] ; then
        cp .gitlab/ci/codeclimate/.pylintrc ./
      fi
    - |
      if ! [ -f .cppcheck-suppressions ] ; then
        cp .gitlab/ci/codeclimate/.cppcheck-suppressions ./
      fi
    - |
      AUTH_TOKEN=`python $PWD/.gitlab/ci/dockerhub/get_token.py`
      docker login -u "$AUTH_USER" -p "$AUTH_TOKEN" "$DOCKERHUB_URL"
      docker run --env CFG="$CFG" \
        --volume /root/.docker:/root/.docker \
        alpine sh -c 'echo "$CFG" > /root/.docker/config.json'
  script:
    - |
      if ! docker info &>/dev/null; then
        if [ -z "$DOCKER_HOST" -a "$KUBERNETES_PORT" ]; then
          export DOCKER_HOST='tcp://localhost:2375'
        fi
      fi
    - docker run --env SOURCE_CODE="$PWD" \
        --env ENGINE_MEMORY_LIMIT_BYTES=4000000000 \
        --volume "$PWD":/code \
        --volume /var/run/docker.sock:/var/run/docker.sock \
        --volume /root/.docker:/root/.docker \
        "$DOCKERHUB_URL"/test/codequality:12-3-stable /code
    - |
      if [ -f gl-code-quality-report.json ]; then
        REPORT=$(head -n 1 gl-code-quality-report.json)
        if [ "$REPORT" != '[]' ]; then
          exit 1
        fi
      fi
  after_script:
    - docker logout "$DOCKERHUB_URL"
  artifacts:
    reports:
      codequality: gl-code-quality-report.json
    paths: [gl-code-quality-report.json]
    when: on_failure
    expire_in: 1 week
  only:
    refs:
      - merge_requests
    changes:
      - .gitlab/ci/Code-Quality.gitlab-ci.yml
      - .gitlab/ci/codeclimate/*
      - Client/Content/Scripts/**/*.py
      - Server/Logic/**/*.py
      - Server/GameCpp/GameCore/**/*.{cpp,h}
  except:
    variables:
      - $CODE_QUALITY_DISABLED

5. GitLab Code Review Practice

Step‑by‑step demonstration using a test project: select source and target branches, create a Merge Request, configure MR parameters (approval rules, dependencies – Enterprise only), conduct the review, resolve discussions, handle merge conflicts (either via the web UI or locally), and finally merge into the target branch.

6. Recommendations and Summary

Choosing between Community (CE) and Enterprise (Starter) depends on business needs; if multiple approvals, “Finish review” by many users, and Code Quality reports in MR are required, the Enterprise edition is preferred, otherwise the Community edition is sufficient.

ci/cdDevOpscode reviewGitLabCode Qualitygit flow
NetEase Game Operations Platform
Written by

NetEase Game Operations Platform

The NetEase Game Automated Operations Platform delivers stable services for thousands of NetEase titles, focusing on efficient ops workflows, intelligent monitoring, and virtualization.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.