Commit f7c80e9f authored by Grzegorz Bizon's avatar Grzegorz Bizon

Revert references to global node in CI job entry

parent 56ae9f6b
......@@ -80,7 +80,7 @@ module Ci
{
stage_idx: @stages.index(job[:stage]),
stage: job[:stage],
commands: job[:commands],
commands: [job[:before_script] || @before_script, job[:script]].flatten.compact.join("\n"),
tag_list: job[:tags] || [],
name: name,
only: job[:only],
......@@ -112,12 +112,8 @@ module Ci
end
def validate_job_keys!(name, job)
##
# TODO, remove refactoring keys
#
refactoring_keys = [:commands]
job.keys.each do |key|
unless (ALLOWED_JOB_KEYS + refactoring_keys).include? key
unless ALLOWED_JOB_KEYS.include? key
raise ValidationError, "#{name} job: unknown parameter #{key}"
end
end
......
......@@ -43,25 +43,13 @@ module Gitlab
@config.merge(to_hash.compact)
end
def before_script
if before_script_defined?
before_script_value
else
@global.before_script
end
end
def commands
[before_script, script].compact.join("\n")
end
private
def to_hash
{ script: script,
stage: stage,
commands: commands,
after_script: after_script }
{ before_script: before_script_value,
script: script_value,
stage: stage_value,
after_script: after_script_value }
end
def compose!
......
......@@ -130,11 +130,9 @@ describe Gitlab::Ci::Config::Node::Global do
it 'returns jobs configuration' do
expect(global.jobs)
.to eq(rspec: { script: %w[rspec ls],
stage: 'test',
commands: "ls\npwd\nrspec\nls" },
stage: 'test' },
spinach: { script: %w[spinach],
stage: 'test',
commands: "ls\npwd\nspinach" })
stage: 'test' })
end
end
end
......
......@@ -66,131 +66,15 @@ describe Gitlab::Ci::Config::Node::Job do
expect(entry.value)
.to eq(before_script: %w[ls pwd],
script: %w[rspec],
commands: "ls\npwd\nrspec",
stage: 'test',
after_script: %w[cleanup])
end
end
end
describe '#before_script' do
context 'when global entry has before script' do
before do
allow(global).to receive(:before_script)
.and_return(%w[ls pwd])
end
context 'when before script is overridden' do
let(:config) do
{ before_script: %w[whoami],
script: 'rspec' }
end
it 'returns correct script' do
expect(entry.before_script).to eq %w[whoami]
end
end
context 'when before script is not overriden' do
let(:config) do
{ script: %w[spinach] }
end
it 'returns correct script' do
expect(entry.before_script).to eq %w[ls pwd]
end
end
end
context 'when global entry does not have before script' do
before do
allow(global).to receive(:before_script)
.and_return(nil)
end
context 'when job has before script' do
let(:config) do
{ before_script: %w[whoami],
script: 'rspec' }
end
it 'returns correct script' do
expect(entry.before_script).to eq %w[whoami]
end
end
context 'when job does not have before script' do
let(:config) do
{ script: %w[ls test] }
end
it 'returns correct script' do
expect(entry.before_script).to be_nil
end
end
end
end
describe '#relevant?' do
it 'is a relevant entry' do
expect(entry).to be_relevant
end
end
describe '#commands' do
context 'when global entry has before script' do
before do
allow(global).to receive(:before_script)
.and_return(%w[ls pwd])
end
context 'when before script is overridden' do
let(:config) do
{ before_script: %w[whoami],
script: 'rspec' }
end
it 'returns correct commands' do
expect(entry.commands).to eq "whoami\nrspec"
end
end
context 'when before script is not overriden' do
let(:config) do
{ script: %w[rspec spinach] }
end
it 'returns correct commands' do
expect(entry.commands).to eq "ls\npwd\nrspec\nspinach"
end
end
end
context 'when global entry does not have before script' do
before do
allow(global).to receive(:before_script)
.and_return(nil)
end
context 'when job has before script' do
let(:config) do
{ before_script: %w[whoami],
script: 'rspec' }
end
it 'returns correct commands' do
expect(entry.commands).to eq "whoami\nrspec"
end
end
context 'when job does not have before script' do
let(:config) do
{ script: %w[ls test] }
end
it 'returns correct commands' do
expect(entry.commands).to eq "ls\ntest"
end
end
end
end
end
......@@ -64,10 +64,8 @@ describe Gitlab::Ci::Config::Node::Jobs do
it 'returns key value' do
expect(entry.value)
.to eq(rspec: { script: %w[rspec],
commands: 'rspec',
stage: 'test' },
spinach: { script: %w[spinach],
commands: 'spinach',
stage: 'test' })
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