Commit e9a42f3c authored by Oswaldo Ferreira's avatar Oswaldo Ferreira

Merge branch '199250-expose-release-yaml-as-steps-via-api-2' into 'master'

Convert `:release` yaml to `release-cli` commands

See merge request gitlab-org/gitlab!34261
parents c4af765b 9030dc1f
---
title: Convert `:release` yaml to `release-cli` commands
merge_request: 34261
author:
type: added
# frozen_string_literal: true
module Gitlab
module Ci
module Build
class Releaser
BASE_COMMAND = 'release-cli create'
attr_reader :config
def initialize(config:)
@config = config
end
def script
command = BASE_COMMAND.dup
config.each { |k, v| command.concat(" --#{k.to_s.dasherize} \"#{v}\"") }
command
end
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
describe Gitlab::Ci::Build::Releaser do
subject { described_class.new(config: config[:release]).script }
describe '#script' do
context 'all nodes' do
let(:config) do
{
release: {
name: 'Release $CI_COMMIT_SHA',
description: 'Created using the release-cli $EXTRA_DESCRIPTION',
tag_name: 'release-$CI_COMMIT_SHA',
ref: '$CI_COMMIT_SHA'
}
}
end
it 'generates the script' do
expect(subject).to eq('release-cli create --name "Release $CI_COMMIT_SHA" --description "Created using the release-cli $EXTRA_DESCRIPTION" --tag-name "release-$CI_COMMIT_SHA" --ref "$CI_COMMIT_SHA"')
end
end
context 'individual nodes' do
using RSpec::Parameterized::TableSyntax
where(:node_name, :node_value, :result) do
'name' | 'Release $CI_COMMIT_SHA' | 'release-cli create --name "Release $CI_COMMIT_SHA"'
'description' | 'Release-cli $EXTRA_DESCRIPTION' | 'release-cli create --description "Release-cli $EXTRA_DESCRIPTION"'
'tag_name' | 'release-$CI_COMMIT_SHA' | 'release-cli create --tag-name "release-$CI_COMMIT_SHA"'
'ref' | '$CI_COMMIT_SHA' | 'release-cli create --ref "$CI_COMMIT_SHA"'
end
with_them do
let(:config) do
{
release: {
node_name => node_value
}
}
end
it 'generates the script' do
expect(subject).to eq(result)
end
end
end
end
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