Skip to content

Bundling directly on $GITLAB

Marcia Ramos requested to merge update-gl-dep into master

The problem

  • Bundler cannot find pg dependencies in another dir
  • mimemagic gem doesn't work either

Possible workaround

The mimemagic issue (introduced by gitlab@58c405c9) could be resolved by adding this function to gitlab-dep.sh:

vendor_workaround(){
  # Workaround for https://gitlab.com/gitlab-org/gitlab/-/commit/58c405c948393108eaec5fc56fadd91a99fb189f
  # Escape $GITLAB/vendor path
  EGL=$(echo $GITLAB/vendor | sed 's/\//\\\//g')
  # If the vendor path is present
  if (grep 'vendor' .gitlab-gemfile >/dev/null) ; then
   # Replace vendor with the path in $GITLAB
   sed -i "" "s|vendor|$EGL|g" .gitlab-gemfile
  fi
}

Then calling it in:

gl-gemfile() {
  curl -s https://gitlab.com/gitlab-org/gitlab/-/raw/master/Gemfile > .gitlab-gemfile
  vendor_workaround
}

And the pg issue could be resolved similarly.

Solution

Bundle from the $GITLAB dir itself:

# If GDK is set, install all GL dependencies:
if [[ $DGDK == '0' ]]; then
    echo `tput setaf 5`"Bundling all GitLab gems. This might take a while..."`tput sgr0`
    # Pull GDK first
    cd $GDK_SEP
    echo `tput setaf 5`"Pulling GDK..."`tput sgr0`
    git_pull_check
    # For $GITLAB haml-lint:
    cd $GITLAB
    echo `tput setaf 5`"Pulling GitLab..."`tput sgr0`
    gitlab_all_gems
# If there's a separate GitLab (within GDK):
    # Repeat for $GDK_SEP_GL haml-lint:
    if $GDK_SEP_GL; then
      cd $GDK_SEP_GL
      echo `tput setaf 5`"Pulling GitLab (within GDK)..."`tput sgr0`
      gitlab_all_gems
    fi
    # Back to Docs Shell:
    cd $DSHELL
  else
# If GDK is not set, install only haml-lint dependencies
    echo `tput setaf 5`"Installing GitLab's dependencies required for haml-lint..."`tput sgr0`
    cd $GITLAB
    haml_lint_gems
    echo `tput bold`"$ bundle "_"$GLBUN"_" install"`tput sgr0`
    # Bundle from temp Gemfile
    BUNDLE_GEMFILE=.haml-gemfile bundle "_"$GLBUN"_" install
    # Remove temp files
    if [[ -e .haml-gemfile ]]; then
      rm .haml-gemfile
    fi
    if [[ -e .haml-gemfile.lock ]]; then
      rm .haml-gemfile.lock
    fi
    cd $DSHELL

Also, clean up haml-lint-only dependencies check:

haml_lint_gems(){
  # Curl up-to-date Gemfile from GitLab
  curl -s https://gitlab.com/gitlab-org/gitlab/-/raw/master/Gemfile > .gitlab-gemfile
  # Generate temp Gemfile
  echo "source 'https://rubygems.org'" > .haml-gemfile
  grep -w "gem 'rails'" .gitlab-gemfile >> .haml-gemfile
  grep -w "gem 'haml_lint'" .gitlab-gemfile >> .haml-gemfile
  rm .gitlab-gemfile
}
Edited by Marcia Ramos

Merge request reports