Commit a6715533 authored by lauraMon's avatar lauraMon

Add deprecation information to type entry

parent 9d9b78d4
...@@ -55,7 +55,8 @@ module Gitlab ...@@ -55,7 +55,8 @@ module Gitlab
entry :type, Entry::Stage, entry :type, Entry::Stage,
description: 'Deprecated: stage this job will be executed into.', description: 'Deprecated: stage this job will be executed into.',
inherit: false inherit: false,
deprecation: { deprecated: '9.0', warning: '14.8', removed: '15.0' }
entry :after_script, Entry::Script, entry :after_script, Entry::Script,
description: 'Commands that will be executed when finishing job.', description: 'Commands that will be executed when finishing job.',
...@@ -134,8 +135,11 @@ module Gitlab ...@@ -134,8 +135,11 @@ module Gitlab
def compose!(deps = nil) def compose!(deps = nil)
super do super do
# The type keyword will be removed in 15.0:
# https://gitlab.com/gitlab-org/gitlab/-/issues/346823
if type_defined? && !stage_defined? if type_defined? && !stage_defined?
@entries[:stage] = @entries[:type] @entries[:stage] = @entries[:type]
log_and_warn_deprecated_entry(@entries[:type])
end end
@entries.delete(:type) @entries.delete(:type)
......
...@@ -60,7 +60,7 @@ module Gitlab ...@@ -60,7 +60,7 @@ module Gitlab
entry :types, Entry::Stages, entry :types, Entry::Stages,
description: 'Deprecated: stages for this pipeline.', description: 'Deprecated: stages for this pipeline.',
reserved: true, reserved: true,
deprecation: { deprecated: '9.0', warning: '14.8', removed: '15.0', documentation: 'https://docs.gitlab.com/ee/ci/yaml/#deprecated-keywords' } deprecation: { deprecated: '9.0', warning: '14.8', removed: '15.0' }
entry :cache, Entry::Caches, entry :cache, Entry::Caches,
description: 'Configure caching between build jobs.', description: 'Configure caching between build jobs.',
...@@ -122,6 +122,8 @@ module Gitlab ...@@ -122,6 +122,8 @@ module Gitlab
## ##
# Deprecated `:types` key workaround - if types are defined and # Deprecated `:types` key workaround - if types are defined and
# stages are not defined we use types definition as stages. # stages are not defined we use types definition as stages.
# This keyword will be removed in 15.0:
# https://gitlab.com/gitlab-org/gitlab/-/issues/346823
# #
if types_defined? if types_defined?
@entries[:stages] = @entries[:types] unless stages_defined? @entries[:stages] = @entries[:types] unless stages_defined?
......
...@@ -55,13 +55,13 @@ RSpec.describe Gitlab::Ci::Config::Entry::Root do ...@@ -55,13 +55,13 @@ RSpec.describe Gitlab::Ci::Config::Entry::Root do
} }
end end
context 'when deprecated types keyword is defined' do context 'when deprecated types/type keywords are defined' do
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:hash) do let(:hash) do
{ types: %w(test deploy), { types: %w(test deploy),
rspec: { script: 'rspec' } } rspec: { script: 'rspec', type: 'test' } }
end end
before do before do
...@@ -69,11 +69,15 @@ RSpec.describe Gitlab::Ci::Config::Entry::Root do ...@@ -69,11 +69,15 @@ RSpec.describe Gitlab::Ci::Config::Entry::Root do
end end
it 'returns array of types as stages with a warning' do it 'returns array of types as stages with a warning' do
expect(root.jobs_value[:rspec][:stage]).to eq 'test'
expect(root.stages_value).to eq %w[test deploy] expect(root.stages_value).to eq %w[test deploy]
expect(root.warnings).to match_array(["root `types` is deprecated in 9.0 and will be removed in 15.0."]) expect(root.warnings).to match_array([
"root `types` is deprecated in 9.0 and will be removed in 15.0.",
"jobs:rspec `type` is deprecated in 9.0 and will be removed in 15.0."
])
end end
it 'logs usage of types keyword' do it 'logs usage of keywords' do
expect(Gitlab::AppJsonLogger).to( expect(Gitlab::AppJsonLogger).to(
receive(:info) receive(:info)
.with(event: 'ci_used_deprecated_keyword', .with(event: 'ci_used_deprecated_keyword',
......
...@@ -225,7 +225,7 @@ RSpec.describe 'Query.ciConfig' do ...@@ -225,7 +225,7 @@ RSpec.describe 'Query.ciConfig' do
context 'when using deprecated keywords' do context 'when using deprecated keywords' do
let_it_be(:content) do let_it_be(:content) do
YAML.dump( YAML.dump(
rspec: { script: 'ls' }, rspec: { script: 'ls', type: 'test' },
types: ['test'] types: ['test']
) )
end end
...@@ -233,7 +233,10 @@ RSpec.describe 'Query.ciConfig' do ...@@ -233,7 +233,10 @@ RSpec.describe 'Query.ciConfig' do
it 'returns a warning' do it 'returns a warning' do
post_graphql_query post_graphql_query
expect(graphql_data['ciConfig']['warnings']).to include('root `types` is deprecated in 9.0 and will be removed in 15.0.') expect(graphql_data['ciConfig']['warnings']).to include(
'root `types` is deprecated in 9.0 and will be removed in 15.0.',
'jobs:rspec `type` is deprecated in 9.0 and will be removed in 15.0.'
)
end end
end end
......
...@@ -154,7 +154,7 @@ RSpec.describe API::Lint do ...@@ -154,7 +154,7 @@ RSpec.describe API::Lint do
end end
context 'with valid .gitlab-ci.yaml using deprecated keywords' do context 'with valid .gitlab-ci.yaml using deprecated keywords' do
let(:yaml_content) { { job: { script: 'ls' }, types: ['test'] }.to_yaml } let(:yaml_content) { { job: { script: 'ls', type: 'test' }, types: ['test'] }.to_yaml }
it 'passes validation but returns warnings' do it 'passes validation but returns warnings' do
post api('/ci/lint', api_user), params: { content: yaml_content } post api('/ci/lint', api_user), params: { content: yaml_content }
......
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