BigW Consortium Gitlab

gitaly.rake 1.72 KB
Newer Older
1 2 3
namespace :gitlab do
  namespace :gitaly do
    desc "GitLab | Install or upgrade gitaly"
4
    task :install, [:dir, :repo] => :gitlab_environment do |t, args|
Ken committed
5
      require 'toml-rb'
6

7
      warn_user_is_not_gitlab
8

9 10 11
      unless args.dir.present?
        abort %(Please specify the directory where you want to install gitaly:\n  rake "gitlab:gitaly:install[/home/git/gitaly]")
      end
12

13
      args.with_defaults(repo: 'https://gitlab.com/gitlab-org/gitaly.git')
14

15
      version = Gitlab::GitalyClient.expected_server_version
16

17
      checkout_or_clone_version(version: version, repo: args.repo, target_dir: args.dir)
18

19 20
      command = %w[/usr/bin/env -u RUBYOPT -u BUNDLE_GEMFILE]

21
      _, status = Gitlab::Popen.popen(%w[which gmake])
22
      command << (status.zero? ? 'gmake' : 'make')
23

24 25 26 27 28
      if Rails.env.test?
        command.push(
          'BUNDLE_FLAGS=--no-deployment',
          "BUNDLE_PATH=#{Bundler.bundle_path}")
      end
29

30
      Gitlab::SetupHelper.create_gitaly_configuration(args.dir)
31
      Dir.chdir(args.dir) do
32 33
        # In CI we run scripts/gitaly-test-build instead of this command
        unless ENV['CI'].present?
34
          Bundler.with_original_env { run_command!(command) }
35
        end
36 37
      end
    end
38 39 40

    desc "GitLab | Print storage configuration in TOML format"
    task storage_config: :environment do
Ken committed
41
      require 'toml-rb'
42 43 44 45

      puts "# Gitaly storage configuration generated from #{Gitlab.config.source} on #{Time.current.to_s(:long)}"
      puts "# This is in TOML format suitable for use in Gitaly's config.toml file."

46 47
      # Exclude gitaly-ruby configuration because that depends on the gitaly
      # installation directory.
48
      puts Gitlab::SetupHelper.gitaly_configuration_toml('', gitaly_ruby: false)
49
    end
50 51
  end
end