blob: cedc2db2a1a2bb002650224fe7104cbd8938f013 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
# frozen_string_literal: true
require 'faker'
module QA
RSpec.describe 'Verify', :runner, :requires_admin, :skip_live_env do
describe "Include multiple files from a project" do
let(:feature_flag) { :ci_include_multiple_files_from_project }
let(:executor) { "qa-runner-#{Faker::Alphanumeric.alphanumeric(8)}" }
let(:expected_text) { Faker::Lorem.sentence }
let(:unexpected_text) { Faker::Lorem.sentence }
let(:project) do
Resource::Project.fabricate_via_api! do |project|
project.name = 'project-with-pipeline-1'
end
end
let(:other_project) do
Resource::Project.fabricate_via_api! do |project|
project.name = 'project-with-pipeline-2'
end
end
let!(:runner) do
Resource::Runner.fabricate! do |runner|
runner.project = project
runner.name = executor
runner.tags = [executor]
end
end
before do
Runtime::Feature.enable(feature_flag)
Flow::Login.sign_in
add_included_files
add_main_ci_file
project.visit!
view_the_last_pipeline
end
after do
Runtime::Feature.disable(feature_flag)
runner.remove_via_api!
end
it 'runs the pipeline with composed config', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1082' do
Page::Project::Pipeline::Show.perform do |pipeline|
aggregate_failures 'pipeline has all expected jobs' do
expect(pipeline).to have_job('build')
expect(pipeline).to have_job('test')
expect(pipeline).to have_job('deploy')
end
pipeline.click_job('test')
end
Page::Project::Job::Show.perform do |job|
aggregate_failures 'main CI is not overridden' do
expect(job.output).to have_no_content("#{unexpected_text}")
expect(job.output).to have_content("#{expected_text}")
end
end
end
private
def add_main_ci_file
Resource::Repository::Commit.fabricate_via_api! do |commit|
commit.project = project
commit.commit_message = 'Add config file'
commit.add_files([main_ci_file])
end
end
def add_included_files
Resource::Repository::Commit.fabricate_via_api! do |commit|
commit.project = other_project
commit.commit_message = 'Add files'
commit.add_files([included_file_1, included_file_2])
end
end
def view_the_last_pipeline
Page::Project::Menu.perform(&:click_ci_cd_pipelines)
Page::Project::Pipeline::Index.perform(&:wait_for_latest_pipeline_success)
Page::Project::Pipeline::Index.perform(&:click_on_latest_pipeline)
end
def main_ci_file
{
file_path: '.gitlab-ci.yml',
content: <<~YAML
include:
- project: #{other_project.full_path}
file:
- file1.yml
- file2.yml
build:
stage: build
tags: ["#{executor}"]
script: echo 'build'
test:
stage: test
tags: ["#{executor}"]
script: echo "#{expected_text}"
YAML
}
end
def included_file_1
{
file_path: 'file1.yml',
content: <<~YAML
test:
stage: test
tags: ["#{executor}"]
script: echo "#{unexpected_text}"
YAML
}
end
def included_file_2
{
file_path: 'file2.yml',
content: <<~YAML
deploy:
stage: deploy
tags: ["#{executor}"]
script: echo 'deploy'
YAML
}
end
end
end
end
|