Single Docker image tests don't test the MR changes

In !3289 (merged), we started testing the single Docker images by checking out the branch defined in the GITLAB_VERSION variable. While this solved the issue described in #1284 (closed), it introduced another issue: if we change single.Dockerfile in a merge request, the changes of the MR are not tested, since we're checking out another branch!

Solution 1

A possible solution would be to checkout the branch, but also apply the changes in the MR.

git checkout $CI_COMMIT_REF_NAME -- <list of files>

The question is which files to use to checkout. We'd need only single.Dockerfile and probably the associated CI file, like .gitlab/ci/docker-images.gitlab-ci.yml.

Solution 2

Fetch the patch and apply it:

curl "https://gitlab.com/gitlab-org/gitlab/-/merge_requests/$CI_MERGE_REQUEST_IID.patch" | git am

This has the caveat that the patch might not apply cleanly and the job fails.

Solution 3

The main issues for not using a stable branch when testing the single images are:

  • We don't pull the stable upstream branches. This could be fixed by setting up the CI_COMMIT_REF_NAME variable to be the same as GITLAB_VERSION.
  • We don't pull the respective stable branch of gitlab-docs which resulted to URL tests failing because of mismatch in the navigation.yaml. This could be fixed if we checked out the respective navigation.yaml file for the branch defined in GITLAB_VERSION:
    git checkout $GITLAB_VERSION -- content/_data/navigation.yaml

Solution 4

Since the changes we mostly want to test are in single.Dockerfile, we can fetch this file from the MR and build against that.

    - curl --output $DOCKERFILE "https://gitlab.com/$CI_PROJECT_PATH/-/raw/$CI_COMMIT_SHA/$DOCKERFILE"
Edited by Achilleas Pipinellis