summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2016-11-22 09:20:45 +0000
committerAlejandro Rodríguez <alejorro70@gmail.com>2016-11-22 15:31:00 +0000
commited266d4835558b60fbd131579013aaeda5091680 (patch)
tree102938df1d2aed2143e9bc7ededa3bd304c45f9d
parente155c2b24e297f686f96034aaea2f3f1c95e791d (diff)
downloadgitlab-ce-ed266d4835558b60fbd131579013aaeda5091680.tar.gz
Merge branch 'fix/ci-linter-undefined-error' into 'master'
Fix undefined error in CI linter ## What does this MR do? This MR fixes undefined error in CI linter. ## Does this MR meet the acceptance criteria? - [x] [Changelog entry](https://docs.gitlab.com/ce/development/changelog.html) added - [x] Tests added for this feature/bug ## What are the relevant issue numbers? Closes #24759 See merge request !7650
-rw-r--r--changelogs/unreleased/fix-ci-linter-undefined-error.yml4
-rw-r--r--lib/gitlab/ci/config/entry/job.rb2
-rw-r--r--spec/lib/gitlab/ci/config/entry/global_spec.rb51
3 files changed, 38 insertions, 19 deletions
diff --git a/changelogs/unreleased/fix-ci-linter-undefined-error.yml b/changelogs/unreleased/fix-ci-linter-undefined-error.yml
new file mode 100644
index 00000000000..229970b79c0
--- /dev/null
+++ b/changelogs/unreleased/fix-ci-linter-undefined-error.yml
@@ -0,0 +1,4 @@
+---
+title: Fix undefined error in CI linter
+merge_request: 7650
+author:
diff --git a/lib/gitlab/ci/config/entry/job.rb b/lib/gitlab/ci/config/entry/job.rb
index 20dcc024b4e..a55362f0b6b 100644
--- a/lib/gitlab/ci/config/entry/job.rb
+++ b/lib/gitlab/ci/config/entry/job.rb
@@ -108,7 +108,7 @@ module Gitlab
self.class.nodes.each_key do |key|
global_entry = deps[key]
- job_entry = @entries[key]
+ job_entry = self[key]
if global_entry.specified? && !job_entry.specified?
@entries[key] = global_entry
diff --git a/spec/lib/gitlab/ci/config/entry/global_spec.rb b/spec/lib/gitlab/ci/config/entry/global_spec.rb
index 5e5c5dcc385..e64c8d46bd8 100644
--- a/spec/lib/gitlab/ci/config/entry/global_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/global_spec.rb
@@ -13,7 +13,7 @@ describe Gitlab::Ci::Config::Entry::Global do
end
end
- context 'when hash is valid' do
+ context 'when configuration is valid' do
context 'when some entries defined' do
let(:hash) do
{ before_script: ['ls', 'pwd'],
@@ -225,29 +225,44 @@ describe Gitlab::Ci::Config::Entry::Global do
end
end
- context 'when hash is not valid' do
+ context 'when configuration is not valid' do
before { global.compose! }
- let(:hash) do
- { before_script: 'ls' }
- end
+ context 'when before script is not an array' do
+ let(:hash) do
+ { before_script: 'ls' }
+ end
- describe '#valid?' do
- it 'is not valid' do
- expect(global).not_to be_valid
+ describe '#valid?' do
+ it 'is not valid' do
+ expect(global).not_to be_valid
+ end
end
- end
- describe '#errors' do
- it 'reports errors from child nodes' do
- expect(global.errors)
- .to include 'before_script config should be an array of strings'
+ describe '#errors' do
+ it 'reports errors from child nodes' do
+ expect(global.errors)
+ .to include 'before_script config should be an array of strings'
+ end
+ end
+
+ describe '#before_script_value' do
+ it 'returns nil' do
+ expect(global.before_script_value).to be_nil
+ end
end
end
- describe '#before_script_value' do
- it 'returns nil' do
- expect(global.before_script_value).to be_nil
+ context 'when job does not have commands' do
+ let(:hash) do
+ { before_script: ['echo 123'], rspec: { stage: 'test' } }
+ end
+
+ describe '#errors' do
+ it 'reports errors about missing script' do
+ expect(global.errors)
+ .to include "jobs:rspec script can't be blank"
+ end
end
end
end
@@ -281,7 +296,7 @@ describe Gitlab::Ci::Config::Entry::Global do
{ cache: { key: 'a' }, rspec: { script: 'ls' } }
end
- context 'when node exists' do
+ context 'when entry exists' do
it 'returns correct entry' do
expect(global[:cache])
.to be_an_instance_of Gitlab::Ci::Config::Entry::Cache
@@ -289,7 +304,7 @@ describe Gitlab::Ci::Config::Entry::Global do
end
end
- context 'when node does not exist' do
+ context 'when entry does not exist' do
it 'always return unspecified node' do
expect(global[:some][:unknown][:node])
.not_to be_specified