Single Docker image tests don't test the MR changes
In gitlab-org/gitlab-docs!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 gitlab-org/gitlab-docs#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
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_NAMEvariable to be the same asGITLAB_VERSION. - We don't pull the respective stable branch of
gitlab-docswhich resulted to URL tests failing because of mismatch in thenavigation.yaml. This could be fixed if we checked out the respectivenavigation.yamlfile for the branch defined inGITLAB_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"