|
30 | 30 | allow(ENV).to receive(:[]).and_call_original
|
31 | 31 | end
|
32 | 32 |
|
33 |
| - it 'pulls in correct image' do |
34 |
| - allow(ENV).to receive(:[]).with('CI_REGISTRY_IMAGE').and_return('dev.gitlab.org:5005/gitlab/omnibus-gitlab') |
35 |
| - allow(Build::Info::Package).to receive(:name).and_return('gitlab-ce') |
36 |
| - allow(Build::Info::Docker).to receive(:tag).and_return('9.0.0') |
37 |
| - allow(DockerOperations).to receive(:authenticate).and_return(true) |
| 33 | + context 'when USE_SKOPEO_FOR_DOCKER_RELEASE is set' do |
| 34 | + before do |
| 35 | + stub_env_var('USE_SKOPEO_FOR_DOCKER_RELEASE', 'true') |
| 36 | + end |
| 37 | + |
| 38 | + it 'does not pull image' do |
| 39 | + expect(Docker::Image).not_to receive(:create).with('fromImage' => 'dev.gitlab.org:5005/gitlab/omnibus-gitlab/gitlab-ce:9.0.0') |
| 40 | + Rake::Task['docker:pull:staging'].invoke |
| 41 | + end |
| 42 | + end |
38 | 43 |
|
39 |
| - expect(Docker::Image).to receive(:create).with('fromImage' => 'dev.gitlab.org:5005/gitlab/omnibus-gitlab/gitlab-ce:9.0.0') |
40 |
| - Rake::Task['docker:pull:staging'].invoke |
| 44 | + context 'when USE_SKOPEO_FOR_DOCKER_RELEASE is not set' do |
| 45 | + before do |
| 46 | + stub_env_var('USE_SKOPEO_FOR_DOCKER_RELEASE', 'false') |
| 47 | + end |
| 48 | + |
| 49 | + it 'pulls in correct image' do |
| 50 | + allow(ENV).to receive(:[]).with('CI_REGISTRY_IMAGE').and_return('dev.gitlab.org:5005/gitlab/omnibus-gitlab') |
| 51 | + allow(Build::Info::Package).to receive(:name).and_return('gitlab-ce') |
| 52 | + allow(Build::Info::Docker).to receive(:tag).and_return('9.0.0') |
| 53 | + allow(DockerOperations).to receive(:authenticate).and_return(true) |
| 54 | + allow(SkopeoHelper).to receive(:login).and_return(true) |
| 55 | + |
| 56 | + expect(Docker::Image).to receive(:create).with('fromImage' => 'dev.gitlab.org:5005/gitlab/omnibus-gitlab/gitlab-ce:9.0.0') |
| 57 | + Rake::Task['docker:pull:staging'].invoke |
| 58 | + end |
41 | 59 | end
|
42 | 60 | end
|
43 | 61 |
|
|
46 | 64 | let(:dummy_creds) { { username: "test", password: "test" } }
|
47 | 65 |
|
48 | 66 | before do
|
49 |
| - Rake::Task['docker:push:staging'].reenable |
50 | 67 | Rake::Task['docker:push:stable'].reenable
|
51 |
| - Rake::Task['docker:push:nightly'].reenable |
52 |
| - Rake::Task['docker:push:rc'].reenable |
53 |
| - Rake::Task['docker:push:latest'].reenable |
54 | 68 |
|
55 | 69 | allow(ENV).to receive(:[]).and_call_original
|
56 | 70 | allow(ENV).to receive(:[]).with('CI_REGISTRY_IMAGE').and_return('dev.gitlab.org:5005/gitlab/omnibus-gitlab')
|
|
61 | 75 | allow(Docker::Image).to receive(:get).and_return(dummy_image)
|
62 | 76 | allow(Docker).to receive(:creds).and_return(dummy_creds)
|
63 | 77 | allow(dummy_image).to receive(:tag).and_return(true)
|
| 78 | + allow(SkopeoHelper).to receive(:login).and_return(true) |
| 79 | + allow(SkopeoHelper).to receive(:copy_image).and_return(true) |
64 | 80 | end
|
65 | 81 |
|
66 |
| - it 'pushes to staging correctly' do |
67 |
| - expect(dummy_image).to receive(:push).with(dummy_creds, repo_tag: 'dev.gitlab.org:5005/gitlab/omnibus-gitlab/gitlab-ce:9.0.0') |
68 |
| - expect(dummy_image).to receive(:push).with(dummy_creds, repo_tag: 'dev.gitlab.org:5005/gitlab/omnibus-gitlab/gitlab-ce:foo-bar') |
69 |
| - Rake::Task['docker:push:staging'].invoke |
70 |
| - end |
| 82 | + describe 'docker:push:staging' do |
| 83 | + before do |
| 84 | + Rake::Task['docker:push:staging'].reenable |
| 85 | + end |
71 | 86 |
|
72 |
| - it 'pushes nightly images correctly' do |
73 |
| - allow(Build::Check).to receive(:is_nightly?).and_return(true) |
74 |
| - |
75 |
| - expect(dummy_image).to receive(:push).with(dummy_creds, repo_tag: 'gitlab/gitlab-ce:nightly') |
76 |
| - Rake::Task['docker:push:nightly'].invoke |
| 87 | + it 'pushes to staging correctly' do |
| 88 | + expect(dummy_image).to receive(:push).with(dummy_creds, repo_tag: 'dev.gitlab.org:5005/gitlab/omnibus-gitlab/gitlab-ce:9.0.0') |
| 89 | + expect(dummy_image).to receive(:push).with(dummy_creds, repo_tag: 'dev.gitlab.org:5005/gitlab/omnibus-gitlab/gitlab-ce:foo-bar') |
| 90 | + Rake::Task['docker:push:staging'].invoke |
| 91 | + end |
77 | 92 | end
|
78 | 93 |
|
79 |
| - it 'pushes latest images correctly' do |
80 |
| - allow(Build::Check).to receive(:is_latest_stable_tag?).and_return(true) |
81 |
| - |
82 |
| - expect(dummy_image).to receive(:push).with(dummy_creds, repo_tag: 'gitlab/gitlab-ce:latest') |
83 |
| - Rake::Task['docker:push:latest'].invoke |
| 94 | + describe 'docker:push:nightly' do |
| 95 | + before do |
| 96 | + Rake::Task['docker:push:nightly'].reenable |
| 97 | + allow(Build::Check).to receive(:is_nightly?).and_return(true) |
| 98 | + end |
| 99 | + |
| 100 | + context 'when USE_SKOPEO_FOR_DOCKER_RELEASE is set' do |
| 101 | + before do |
| 102 | + stub_env_var('USE_SKOPEO_FOR_DOCKER_RELEASE', 'true') |
| 103 | + end |
| 104 | + |
| 105 | + it 'copies nightly images correctly' do |
| 106 | + expect(SkopeoHelper).to receive(:copy_image).with('dev.gitlab.org:5005/gitlab/omnibus-gitlab/gitlab-ce:9.0.0', 'gitlab/gitlab-ce:nightly') |
| 107 | + Rake::Task['docker:push:nightly'].invoke |
| 108 | + end |
| 109 | + end |
| 110 | + |
| 111 | + context 'when USE_SKOPEO_FOR_DOCKER_RELEASE is not set' do |
| 112 | + before do |
| 113 | + stub_env_var('USE_SKOPEO_FOR_DOCKER_RELEASE', 'false') |
| 114 | + end |
| 115 | + |
| 116 | + it 'pushes nightly images correctly' do |
| 117 | + expect(dummy_image).to receive(:push).with(dummy_creds, repo_tag: 'gitlab/gitlab-ce:nightly') |
| 118 | + Rake::Task['docker:push:nightly'].invoke |
| 119 | + end |
| 120 | + end |
84 | 121 | end
|
85 | 122 |
|
86 |
| - it 'pushes rc images correctly' do |
87 |
| - allow(Build::Check).to receive(:is_latest_tag?).and_return(true) |
88 |
| - |
89 |
| - expect(dummy_image).to receive(:push).with(dummy_creds, repo_tag: 'gitlab/gitlab-ce:rc') |
90 |
| - Rake::Task['docker:push:rc'].invoke |
| 123 | + describe 'docker:push:latest' do |
| 124 | + before do |
| 125 | + Rake::Task['docker:push:latest'].reenable |
| 126 | + allow(Build::Check).to receive(:is_latest_stable_tag?).and_return(true) |
| 127 | + end |
| 128 | + |
| 129 | + context 'when USE_SKOPEO_FOR_DOCKER_RELEASE is set' do |
| 130 | + before do |
| 131 | + stub_env_var('USE_SKOPEO_FOR_DOCKER_RELEASE', 'true') |
| 132 | + end |
| 133 | + |
| 134 | + it 'copies latest images correctly' do |
| 135 | + expect(SkopeoHelper).to receive(:copy_image).with('dev.gitlab.org:5005/gitlab/omnibus-gitlab/gitlab-ce:9.0.0', 'gitlab/gitlab-ce:latest') |
| 136 | + Rake::Task['docker:push:latest'].invoke |
| 137 | + end |
| 138 | + end |
| 139 | + |
| 140 | + context 'when USE_SKOPEO_FOR_DOCKER_RELEASE is not set' do |
| 141 | + before do |
| 142 | + stub_env_var('USE_SKOPEO_FOR_DOCKER_RELEASE', 'false') |
| 143 | + end |
| 144 | + |
| 145 | + it 'pushes latest images correctly' do |
| 146 | + expect(dummy_image).to receive(:push).with(dummy_creds, repo_tag: 'gitlab/gitlab-ce:latest') |
| 147 | + Rake::Task['docker:push:latest'].invoke |
| 148 | + end |
| 149 | + end |
91 | 150 | end
|
92 | 151 |
|
93 |
| - it 'pushes triggered images correctly' do |
94 |
| - allow(ENV).to receive(:[]).with('CI_COMMIT_REF_SLUG').and_return('foo-bar') |
95 |
| - allow(ENV).to receive(:[]).with('CI_REGISTRY_IMAGE').and_return('registry.gitlab.com/gitlab-org/omnibus-gitlab') |
96 |
| - allow(ENV).to receive(:[]).with("IMAGE_TAG").and_return("omnibus-12345") |
97 |
| - allow(Build::Info::Docker).to receive(:tag).and_call_original |
| 152 | + describe 'docker:push:rc' do |
| 153 | + before do |
| 154 | + Rake::Task['docker:push:rc'].reenable |
| 155 | + allow(Build::Check).to receive(:is_latest_tag?).and_return(true) |
| 156 | + end |
| 157 | + |
| 158 | + context 'when USE_SKOPEO_FOR_DOCKER_RELEASE is set' do |
| 159 | + before do |
| 160 | + stub_env_var('USE_SKOPEO_FOR_DOCKER_RELEASE', 'true') |
| 161 | + end |
| 162 | + |
| 163 | + it 'copies rc images correctly' do |
| 164 | + expect(SkopeoHelper).to receive(:copy_image).with('dev.gitlab.org:5005/gitlab/omnibus-gitlab/gitlab-ce:9.0.0', 'gitlab/gitlab-ce:rc') |
| 165 | + Rake::Task['docker:push:rc'].invoke |
| 166 | + end |
| 167 | + end |
| 168 | + |
| 169 | + context 'when USE_SKOPEO_FOR_DOCKER_RELEASE is not set' do |
| 170 | + before do |
| 171 | + stub_env_var('USE_SKOPEO_FOR_DOCKER_RELEASE', 'false') |
| 172 | + end |
| 173 | + |
| 174 | + it 'pushes rc images correctly' do |
| 175 | + expect(dummy_image).to receive(:push).with(dummy_creds, repo_tag: 'gitlab/gitlab-ce:rc') |
| 176 | + Rake::Task['docker:push:rc'].invoke |
| 177 | + end |
| 178 | + end |
| 179 | + end |
98 | 180 |
|
99 |
| - expect(dummy_image).to receive(:push).with(dummy_creds, repo_tag: 'registry.gitlab.com/gitlab-org/omnibus-gitlab/gitlab-ce:omnibus-12345') |
100 |
| - expect(dummy_image).to receive(:push).with(dummy_creds, repo_tag: 'registry.gitlab.com/gitlab-org/omnibus-gitlab/gitlab-ce:foo-bar') |
101 |
| - Rake::Task['docker:push:triggered'].invoke |
| 181 | + describe 'docker:push:triggered' do |
| 182 | + before do |
| 183 | + Rake::Task['docker:push:triggered'].reenable |
| 184 | + allow(ENV).to receive(:[]).with('CI_COMMIT_REF_SLUG').and_return('foo-bar') |
| 185 | + allow(ENV).to receive(:[]).with('CI_REGISTRY_IMAGE').and_return('registry.gitlab.com/gitlab-org/omnibus-gitlab') |
| 186 | + allow(ENV).to receive(:[]).with("IMAGE_TAG").and_return("omnibus-12345") |
| 187 | + allow(Build::Info::Docker).to receive(:tag).and_call_original |
| 188 | + end |
| 189 | + |
| 190 | + it 'pushes triggered images correctly' do |
| 191 | + expect(dummy_image).to receive(:push).with(dummy_creds, repo_tag: 'registry.gitlab.com/gitlab-org/omnibus-gitlab/gitlab-ce:omnibus-12345') |
| 192 | + expect(dummy_image).to receive(:push).with(dummy_creds, repo_tag: 'registry.gitlab.com/gitlab-org/omnibus-gitlab/gitlab-ce:foo-bar') |
| 193 | + Rake::Task['docker:push:triggered'].invoke |
| 194 | + end |
102 | 195 | end
|
103 | 196 | end
|
104 | 197 | end
|
|
0 commit comments