Commit 60dcd06f authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'lm-type-deprecation-pt2' into 'master'

Add deprecation information to type entry

See merge request gitlab-org/gitlab!78585
parents 0e267d93 a6715533
......@@ -55,7 +55,8 @@ module Gitlab
entry :type, Entry::Stage,
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,
description: 'Commands that will be executed when finishing job.',
......@@ -134,8 +135,11 @@ module Gitlab
def compose!(deps = nil)
super do
# The type keyword will be removed in 15.0:
# https://gitlab.com/gitlab-org/gitlab/-/issues/346823
if type_defined? && !stage_defined?
@entries[:stage] = @entries[:type]
log_and_warn_deprecated_entry(@entries[:type])
end
@entries.delete(:type)
......
......@@ -60,7 +60,7 @@ module Gitlab
entry :types, Entry::Stages,
description: 'Deprecated: stages for this pipeline.',
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,
description: 'Configure caching between build jobs.',
......@@ -122,6 +122,8 @@ module Gitlab
##
# Deprecated `:types` key workaround - if types are defined and
# 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?
@entries[:stages] = @entries[:types] unless stages_defined?
......
......@@ -55,13 +55,13 @@ RSpec.describe Gitlab::Ci::Config::Entry::Root do
}
end
context 'when deprecated types keyword is defined' do
context 'when deprecated types/type keywords are defined' do
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:hash) do
{ types: %w(test deploy),
rspec: { script: 'rspec' } }
rspec: { script: 'rspec', type: 'test' } }
end
before do
......@@ -69,11 +69,15 @@ RSpec.describe Gitlab::Ci::Config::Entry::Root do
end
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.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
it 'logs usage of types keyword' do
it 'logs usage of keywords' do
expect(Gitlab::AppJsonLogger).to(
receive(:info)
.with(event: 'ci_used_deprecated_keyword',
......
......@@ -225,7 +225,7 @@ RSpec.describe 'Query.ciConfig' do
context 'when using deprecated keywords' do
let_it_be(:content) do
YAML.dump(
rspec: { script: 'ls' },
rspec: { script: 'ls', type: 'test' },
types: ['test']
)
end
......@@ -233,7 +233,10 @@ RSpec.describe 'Query.ciConfig' do
it 'returns a warning' do
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
......
......@@ -154,7 +154,7 @@ RSpec.describe API::Lint do
end
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
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