Multi document YAML doesn't work with leading and trailing delimiters
Description
In #388836 (comment 1316000941) we got user report about their CI configuration not working on GitLab. We disabled ci_multi_doc_yaml
feature flag yesterday to resolve the customer issue.
It appears that our new mechanism does not support following config:
---
test:
script: echo "ok"
---
This should be a valid syntax, but the following spec is failing:
diff --git a/spec/lib/gitlab/config/loader/multi_doc_yaml_spec.rb b/spec/lib/gitlab/config/loader/multi_doc_yaml_spec.rb
index f63aacecce6a..71252cd3c852 100644
--- a/spec/lib/gitlab/config/loader/multi_doc_yaml_spec.rb
+++ b/spec/lib/gitlab/config/loader/multi_doc_yaml_spec.rb
@@ -6,6 +6,26 @@
let(:loader) { described_class.new(yml, max_documents: 2) }
describe '#load!' do
+ context 'when a single document with leading and trailing delimiter is used' do
+ let(:yml) do
+ <<~YAML
+ ---
+ test:
+ script: echo "ok"
+ ---
+ YAML
+ end
+
+ it 'returns a single document' do
+ docs = loader.load!
+
+ expect(docs.size).to eq 1
+ expect(docs).to contain_exactly(
+ { test: { script: 'echo "ok"' } }
+ )
+ end
+ end
+
context 'when a simple single delimiter is being used' do
let(:yml) do
<<~YAML
Edited by Grzegorz Bizon