Commit dd8fd8ff authored by Marin Jankovski's avatar Marin Jankovski

Merge branch '271-helm-release-update' into 'master'

Modify Charts release codebase to make release happen in dev.gitlab.org

Closes charts/gitlab#1198 and #271

See merge request !551
parents d242662f dbc0af39
......@@ -68,6 +68,7 @@ require 'release_tools/pipeline'
require 'release_tools/pick_into_label'
require 'release_tools/preparation_merge_request'
require 'release_tools/project/base_project'
require 'release_tools/project/cng_image'
require 'release_tools/project/deployer'
require 'release_tools/project/gitlab_ce'
require 'release_tools/project/gitlab_ee'
......@@ -91,6 +92,7 @@ require 'release_tools/qa/username_extractor'
require 'release_tools/qa/issue_closer'
require 'release_tools/release'
require 'release_tools/release/base_release'
require 'release_tools/release/cng_image_release'
require 'release_tools/release/gitlab_ce_release'
require 'release_tools/release/gitlab_ee_release'
require 'release_tools/release/helm_gitlab_release'
......
# frozen_string_literal: true
module ReleaseTools
module Project
class CNGImage < BaseProject
REMOTES = {
dev: 'git@dev.gitlab.org:gitlab/charts/components/images.git',
gitlab: 'git@gitlab.com:gitlab-org/build/CNG.git'
}.freeze
end
end
end
......@@ -4,6 +4,7 @@ module ReleaseTools
module Project
class HelmGitlab < BaseProject
REMOTES = {
dev: 'git@dev.gitlab.org:gitlab/charts/gitlab.git',
gitlab: 'git@gitlab.com:charts/gitlab.git'
}.freeze
end
......
# frozen_string_literal: true
module ReleaseTools
module Release
class CNGImageRelease < BaseRelease
class VersionFileDoesNotExistError < StandardError; end
def remotes
Project::CNGImage.remotes
end
private
def bump_versions
target_file = File.join(repository.path, 'ci_files/variables.yml')
yaml_contents = YAML.load_file(target_file)
yaml_contents['variables'].merge!(
'GITLAB_VERSION' => version_string(version),
'GITALY_VERSION' => version_string_from_file('GITALY_SERVER_VERSION'),
'GITLAB_SHELL_VERSION' => version_string_from_file('GITLAB_SHELL_VERSION'),
'GITLAB_WORKHORSE_VERSION' => version_string_from_file('GITLAB_WORKHORSE_VERSION'),
'GITLAB_REF_SLUG' => version_string(version),
'GITLAB_ASSETS_TAG' => version_string(version)
)
File.open(target_file, 'w') do |f|
f.write(YAML.dump(yaml_contents))
end
repository.commit(target_file, message: "Update #{target_file} for #{version}")
end
def version_string(version)
"v#{version}"
end
def read_file_from_gitlab_repo(file_name)
gitlab_file_path = File.join(options[:gitlab_repo_path], file_name)
unless File.exist?(gitlab_file_path)
raise VersionFileDoesNotExistError.new(gitlab_file_path)
end
File.read(gitlab_file_path).strip
end
def version_string_from_file(file_name)
version_string(read_file_from_gitlab_repo(file_name))
end
end
end
end
......@@ -20,6 +20,14 @@ module ReleaseTools
version.to_omnibus(ee: version.ee?),
options.merge(gitlab_repo_path: repository.path)
).execute
begin
Release::CNGImageRelease.new(version, options.merge(gitlab_repo_path: repository.path)).execute
rescue StandardError => ex
$stderr.puts "Exception raised during CNG image release."
$stderr.puts ex.message
$stderr.puts ex.backtrace
end
end
def after_release
......
......@@ -79,6 +79,7 @@ module ReleaseTools
args = ['--include-subcharts']
args << "--chart-version #{chart_version}"
args << "--app-version=#{app_version}" if app_version && app_version.valid?
args << "--gitlab-repo=#{Project::GitlabEe.dev_path}"
message = ["Update Chart Version to #{chart_version}"]
message << "Update Gitlab Version to #{app_version}" if app_version && app_version.valid?
......
......@@ -15,18 +15,22 @@ describe ReleaseTools::Release::GitlabCeRelease, :silence_stdout do
# gets checked out to `/tmp/release`.
let(:repo_path) { File.join('/tmp', ReleaseFixture.repository_name) }
let(:ob_repo_path) { File.join('/tmp', OmnibusReleaseFixture.repository_name) }
let(:cng_repo_path) { File.join('/tmp', CNGImageReleaseFixture.repository_name) }
# These two Rugged repositories are used for _verifying the result_ of the
# release run. Not to be confused with the fixture repositories.
let(:repository) { Rugged::Repository.new(repo_path) }
let(:ob_repository) { Rugged::Repository.new(ob_repo_path) }
let(:cng_repository) { Rugged::Repository.new(cng_repo_path) }
before do
fixture = ReleaseFixture.new
ob_fixture = OmnibusReleaseFixture.new
cng_fixture = CNGImageReleaseFixture.new
fixture.rebuild_fixture!
ob_fixture.rebuild_fixture!
cng_fixture.rebuild_fixture!
# Disable cleanup so that we can see what's the state of the temp Git repos
allow_any_instance_of(ReleaseTools::RemoteRepository)
......@@ -39,12 +43,16 @@ describe ReleaseTools::Release::GitlabCeRelease, :silence_stdout do
allow_any_instance_of(ReleaseTools::Release::OmnibusGitlabRelease).to receive(:remotes)
.and_return({ gitlab: "file://#{ob_fixture.fixture_path}" })
allow_any_instance_of(ReleaseTools::Release::CNGImageRelease).to receive(:remotes)
.and_return({ gitlab: "file://#{cng_fixture.fixture_path}" })
end
after do
# Manually perform the cleanup we disabled in the `before` block
FileUtils.rm_rf(repo_path, secure: true) if File.exist?(repo_path)
FileUtils.rm_rf(ob_repo_path, secure: true) if File.exist?(ob_repo_path)
FileUtils.rm_rf(cng_repo_path, secure: true) if File.exist?(cng_repo_path)
end
def execute(version, branch)
......
......@@ -93,6 +93,44 @@ class OmnibusReleaseFixture
end
end
class CNGImageReleaseFixture
include RepositoryFixture
def self.repository_name
'cng-image-release'
end
def build_fixture(options = {})
variables_file = <<~MSG
variables:
GITLAB_VERSION: "master"
GITLAB_REF_SLUG: "master"
GITLAB_ASSETS_TAG: "master"
GITLAB_SHELL_VERSION: "master"
GITLAB_WORKHORSE_VERSION: "master"
GITALY_VERSION: "master"
GIT_VERSION: "2.18.1"
GO_VERSION: "1.9.6"
KUBECTL_VERSION: "v1.9.3"
PG_VERSION: "9.6.8"
MAILROOM_VERSION: "0.9.0"
ALPINE_VERSION: "3.8"
CFSSL_VERSION: "1.2"
DOCKER_DRIVER: overlay2
DOCKER_HOST: tcp://docker:2375
ASSETS_IMAGE_PREFIX: "gitlab-assets"
ASSETS_IMAGE_REGISTRY_PREFIX: "registry.gitlab.com/gitlab-org"
COMPILE_ASSETS: "false"
S3CMD_VERSION: "2.0.1"
PYTHON_VERSION: "3.4.9"
MSG
commit_blob(path: 'ci_files/variables.yml', content: variables_file, message: 'Add variables file')
commit_blob(path: 'README.md', content: '', message: 'Add empty README.md')
repository.branches.create('9-1-stable', 'HEAD')
repository.branches.create('9-1-stable-ee', 'HEAD')
end
end
class HelmReleaseFixture
include RepositoryFixture
......
......@@ -40,6 +40,7 @@ module RepositoryFixture
index = repository.index
files.each do |path, content|
FileUtils.mkdir_p(File.dirname(path))
oid = repository.write(content, :blob)
index.add(path: path, oid: oid, mode: 0o100644)
end
......
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