Commit 798e3475 authored by Shinya Maeda's avatar Shinya Maeda

Merge branch...

Merge branch '208655-introduce-prepare-keyword-to-environment-action-to-annotate-non-deployment-jobs' into 'master'

Introduce `prepare` keyword to `environment:action:` to annotate non-deployment jobs

Closes #208655

See merge request gitlab-org/gitlab!35642
parents c6eb657f 3d73656b
---
title: Introduce prepare environment action to annotate non-deployment jobs
merge_request: 35642
author:
type: added
...@@ -44,7 +44,7 @@ module Gitlab ...@@ -44,7 +44,7 @@ module Gitlab
validates :action, validates :action,
type: String, type: String,
inclusion: { in: %w[start stop], message: 'should be start or stop' }, inclusion: { in: %w[start stop prepare], message: 'should be start, stop or prepare' },
allow_nil: true allow_nil: true
validates :on_stop, type: String, allow_nil: true validates :on_stop, type: String, allow_nil: true
......
...@@ -102,6 +102,17 @@ RSpec.describe Gitlab::Ci::Config::Entry::Environment do ...@@ -102,6 +102,17 @@ RSpec.describe Gitlab::Ci::Config::Entry::Environment do
end end
end end
context 'when prepare action is used' do
let(:config) do
{ name: 'production',
action: 'prepare' }
end
it 'is valid' do
expect(entry).to be_valid
end
end
context 'when wrong action type is used' do context 'when wrong action type is used' do
let(:config) do let(:config) do
{ name: 'production', { name: 'production',
...@@ -137,7 +148,7 @@ RSpec.describe Gitlab::Ci::Config::Entry::Environment do ...@@ -137,7 +148,7 @@ RSpec.describe Gitlab::Ci::Config::Entry::Environment do
describe '#errors' do describe '#errors' do
it 'contains error about invalid action' do it 'contains error about invalid action' do
expect(entry.errors) expect(entry.errors)
.to include 'environment action should be start or stop' .to include 'environment action should be start, stop or prepare'
end end
end end
end end
......
...@@ -102,6 +102,19 @@ RSpec.describe Gitlab::Ci::Pipeline::Seed::Deployment do ...@@ -102,6 +102,19 @@ RSpec.describe Gitlab::Ci::Pipeline::Seed::Deployment do
end end
end end
context 'when job has environment attribute with prepare action' do
let(:attributes) do
{
environment: 'production',
options: { environment: { name: 'production', action: 'prepare' } }
}
end
it 'returns nothing' do
is_expected.to be_nil
end
end
context 'when job does not have environment attribute' do context 'when job does not have environment attribute' do
let(:attributes) { { name: 'test' } } let(:attributes) { { name: 'test' } }
......
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