blob: 0d8756fc9a3b46dfefebdf43f93c972c6496e40b (
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
|
# frozen_string_literal: true
module QA
RSpec.describe 'Verify' do
describe 'Multi-project pipelines' do
let(:downstream_job_name) { 'downstream_job' }
let(:executor) { "qa-runner-#{SecureRandom.hex(4)}" }
let!(:group) { Resource::Group.fabricate_via_api! }
let(:upstream_project) do
Resource::Project.fabricate_via_api! do |project|
project.group = group
project.name = 'upstream-project'
end
end
let(:downstream_project) do
Resource::Project.fabricate_via_api! do |project|
project.group = group
project.name = 'downstream-project'
end
end
let!(:runner) do
Resource::Runner.fabricate_via_api! do |runner|
runner.token = group.reload!.runners_token
runner.name = executor
runner.tags = [executor]
end
end
before do
add_ci_file(downstream_project, downstream_ci_file)
add_ci_file(upstream_project, upstream_ci_file)
Flow::Login.sign_in
upstream_project.visit!
Flow::Pipeline.visit_latest_pipeline(status: 'passed')
end
after do
runner.remove_via_api!
[upstream_project, downstream_project].each(&:remove_via_api!)
end
it(
'creates a multi-project pipeline',
testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/358064'
) do
Page::Project::Pipeline::Show.perform do |show|
expect(show).to have_passed
expect(show).not_to have_job(downstream_job_name)
show.expand_linked_pipeline
expect(show).to have_job(downstream_job_name)
end
end
private
def add_ci_file(project, file)
Resource::Repository::Commit.fabricate_via_api! do |commit|
commit.project = project
commit.commit_message = 'Add CI config file'
commit.add_files([file])
end
end
def upstream_ci_file
{
file_path: '.gitlab-ci.yml',
content: <<~YAML
stages:
- test
- deploy
job1:
stage: test
tags: ["#{executor}"]
script: echo 'done'
staging:
stage: deploy
trigger:
project: #{downstream_project.path_with_namespace}
strategy: depend
YAML
}
end
def downstream_ci_file
{
file_path: '.gitlab-ci.yml',
content: <<~YAML
"#{downstream_job_name}":
stage: test
tags: ["#{executor}"]
script: echo 'done'
YAML
}
end
end
end
end
|