Commit d2595a48 authored by Rémy Coutable's avatar Rémy Coutable

Cache the qa/vendor/ruby folder to speed up the build-qa-image job

Signed-off-by: Rémy Coutable's avatarRémy Coutable <remy@rymai.me>
parent fdf9fcdd
Pipeline #88035195 failed with stages
in 76 minutes and 56 seconds
# `build_from_dir` can't find Dockerfile when `.dockerignore` is "*"
# See https://github.com/swipely/docker-api/issues/484
# Ignore all folders except qa/, config/initializers and the root of lib/ since
# the files we need to build the QA image are in these folders.
# Following are the files we need:
# - ./config/initializers/0_inject_enterprise_edition_module.rb
# - ./ee/app/models/license.rb
# - ./lib/gitlab.rb
# - ./lib/gitlab/utils.rb
# - ./qa/
# - ./INSTALLATION_TYPE
# - ./VERSION
# Ignore all folders except for the files we need to build the QA image.
/.git/
/.go/pkg/mod/
/.yarn-cache/
/app/
/bin/
/builds/
/changelogs/
/config/environments/
/config/helpers/
/config/knative/
/config/locales/
/config/prometheus/
/config/routes/
/config/
/danger/
/db/
/doc/
/docker/
/ee/bin/
/ee/changelogs/
/ee/config/
/ee/db/
/ee/fixtures/
/ee/lib/
/ee/locale/
/ee/spec/
/ee/
/fixtures/
/templates/
/lint/
/lib/api/
/lib/assets/
/lib/backup/
/lib/banzai/
/lib/bitbucket/
/lib/server/
/lib/constraints/
/lib/registry/
/lib/policy/
/lib/feature/
/lib/flowdock/
/lib/generators/
/lib/gitaly/
/lib/api/
/lib/token/
/lib/mattermost/
/lib/teams/
/lib/storage/
/lib/auth/
/lib/peek/
/lib/prometheus/
/lib/quality/
/lib/rouge/
/lib/flaky/
/lib/zip/
/lib/sentry/
/lib/serializers/
/lib/support/
/lib/check/
/lib/tasks/
/lib/
/locale/
/log/
/modules/
......@@ -80,3 +32,15 @@
/symbol/
/tmp/
/vendor/
# Following are the files we need:
!/config/initializers/0_inject_enterprise_edition_module.rb
!/ee/app/models/license.rb
!/lib/gitlab.rb
!/lib/gitlab/utils.rb
!/vendor/ruby/
# Plus the following:
# - ./qa/
# - ./INSTALLATION_TYPE
# - ./VERSION
# - ./vendor/ruby
......@@ -23,6 +23,7 @@
build-qa-image:
extends:
- .default-cache
- .review-docker
- .only-code-qa-changes
only:
......@@ -30,6 +31,9 @@ build-qa-image:
- $CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAMESPACE == "gitlab-org"
stage: prepare
script:
- mkdir -p ./qa/vendor
- mv "${CI_PROJECT_DIR}/vendor/ruby" "${CI_PROJECT_DIR}/qa/vendor/ruby"
- ls -l "${CI_PROJECT_DIR}/qa/vendor/ruby"
- '[[ ! -d "ee/" ]] || export GITLAB_EDITION="ee"'
- export QA_IMAGE="${CI_REGISTRY}/${CI_PROJECT_PATH}/gitlab/gitlab-${GITLAB_EDITION}-qa:${CI_COMMIT_REF_SLUG}"
- time docker build --cache-from gitlab/gitlab-${GITLAB_EDITION}-qa:nightly --tag ${QA_IMAGE} --file ./qa/Dockerfile ./
......
......@@ -48,7 +48,6 @@ RUN export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)" && \
apt-get update -y && apt-get install google-cloud-sdk kubectl -y
WORKDIR /home/gitlab/qa
COPY ./qa/Gemfile* /home/gitlab/qa/
COPY ./config/initializers/0_inject_enterprise_edition_module.rb /home/gitlab/config/initializers/
# Copy VERSION to ensure the COPY succeeds to copy at least one file since ee/app/models/license.rb isn't present in FOSS
# The [b] part makes ./ee/app/models/license.r[b] a pattern that is allowed to return no files (which is the case in FOSS)
......@@ -56,7 +55,10 @@ COPY VERSION ./ee/app/models/license.r[b] /home/gitlab/ee/app/models/
COPY ./lib/gitlab.rb /home/gitlab/lib/
COPY ./lib/gitlab/utils.rb /home/gitlab/lib/gitlab/
COPY ./INSTALLATION_TYPE ./VERSION /home/gitlab/
RUN cd /home/gitlab/qa/ && bundle install --jobs=$(nproc) --retry=3 --quiet
COPY ./qa/Gemfile* /home/gitlab/qa/
COPY ./vendor/ruby /home/gitlab/qa/vendor/
RUN ls -l /home/gitlab/qa/vendor/ruby
RUN cd /home/gitlab/qa/ && bundle install --clean --jobs=$(nproc) --path=vendor --retry=3 --quiet
COPY ./qa /home/gitlab/qa
ENTRYPOINT ["bin/test"]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment