Skip to content

Commit a0af74e

Browse files
Robert Marshallbalasankarc
andcommitted
Merge branch '8259-ruby-3.1-feature-branch-builds' into 'master'
Switch feature branch builds to Ruby 3.1.4 Closes #8259 See merge request https://gitlab.com/gitlab-org/omnibus-gitlab/-/merge_requests/7254 Merged-by: Robert Marshall <[email protected]> Approved-by: Hossein Pursultani <[email protected]> Co-authored-by: Balasankar "Balu" C <[email protected]>
2 parents 34fdcdd + 20ec639 commit a0af74e

File tree

5 files changed

+47
-7
lines changed

5 files changed

+47
-7
lines changed

.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ variables:
6464
BUNDLER_VERSION: "2.4.13"
6565
# NOTE: When `NEXT_RUBY_VERSION` is updated, flip
6666
# `USE_NEXT_RUBY_VERSION_IN_*` variables to false to avoid surprises.
67-
NEXT_RUBY_VERSION: "3.0.6"
67+
NEXT_RUBY_VERSION: "3.1.4"
6868
GET_GEO_TAG: "0.7.3"
6969
CANONICAL_PROJECT_PATH: 'gitlab-org/omnibus-gitlab'
7070
SECURITY_PROJECT_PATH: 'gitlab-org/security/omnibus-gitlab'

lib/gitlab/build/info/ci.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Info
77
class CI
88
class << self
99
def branch_name
10-
Gitlab::Util.get_env('CI_COMMIT_BRANCH')
10+
Gitlab::Util.get_env('CI_COMMIT_BRANCH') || Gitlab::Util.get_env('CI_MERGE_REQUEST_SOURCE_BRANCH_NAME')
1111
end
1212

1313
def tag_name

spec/lib/gitlab/build/check_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,16 @@
269269
end
270270
end
271271

272+
context 'when on a feature branch MR pipeline' do
273+
before do
274+
stub_mr_branch('my-feature-branch')
275+
end
276+
277+
it 'returns true' do
278+
expect(described_class.on_regular_branch?).to be_truthy
279+
end
280+
end
281+
272282
context 'when on a stable branch' do
273283
before do
274284
stub_branch('15-6-stable')

spec/lib/gitlab/build/info/git_spec.rb

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
context 'not in CI' do
2727
before do
2828
stub_env_var('CI_COMMIT_BRANCH', '')
29+
stub_env_var('CI_MERGE_REQUEST_SOURCE_BRANCH_NAME', '')
2930
allow(Gitlab::Util).to receive(:shellout_stdout).with('git rev-parse --abbrev-ref HEAD').and_return('HEAD')
3031
end
3132

@@ -37,19 +38,34 @@
3738

3839
context 'in branches' do
3940
context 'in CI' do
40-
before do
41-
stub_env_var('CI_COMMIT_BRANCH', 'my-feature-branch')
41+
context 'in MR pipelines' do
42+
before do
43+
stub_env_var('CI_COMMIT_BRANCH', '')
44+
stub_env_var('CI_MERGE_REQUEST_SOURCE_BRANCH_NAME', 'my-feature-branch')
45+
end
46+
47+
it 'returns branch name from CI variable' do
48+
expect(described_class.branch_name).to eq('my-feature-branch')
49+
end
4250
end
4351

44-
it 'returns branch name from CI variable' do
45-
expect(described_class.branch_name).to eq('my-feature-branch')
52+
context 'in regular branch pipelines' do
53+
before do
54+
stub_env_var('CI_COMMIT_BRANCH', 'my-feature-branch')
55+
stub_env_var('CI_MERGE_REQUEST_SOURCE_BRANCH_NAME', '')
56+
end
57+
58+
it 'returns branch name from CI variable' do
59+
expect(described_class.branch_name).to eq('my-feature-branch')
60+
end
4661
end
4762
end
4863

4964
context 'not in CI' do
5065
before do
5166
stub_env_var('CI_COMMIT_BRANCH', '')
5267
stub_env_var('CI_COMMIT_TAG', '')
68+
stub_env_var('CI_MERGE_REQUEST_SOURCE_BRANCH_NAME', '')
5369
allow(Gitlab::Util).to receive(:shellout_stdout).with('git rev-parse --abbrev-ref HEAD').and_return('my-feature-branch')
5470
end
5571

spec/support/macros.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,23 @@ def stub_env_var(var, value)
5252
end
5353

5454
def stub_branch(branch)
55+
stub_env_var('CI_MERGE_REQUEST_SOURCE_BRANCH_NAME', '')
56+
5557
stub_env_var('CI_COMMIT_BRANCH', branch)
5658
allow(Gitlab::Util).to receive(:shellout_stdout).with('git rev-parse --abbrev-ref HEAD').and_return(branch)
5759

5860
stub_env_var('CI_COMMIT_TAG', '')
59-
allow(Gitlab::Util).to receive(:shellout_stdout).with('git describe --tags --exact-match').and_raise(Gitlab::Util::ShellOutExecutionError.new("git describe --tags --exact-match", 128, "", "fatal: no tag exactly matches 'foobar'"))
61+
allow(Gitlab::Util).to receive(:shellout_stdout).with('git describe --tags --exact-match').and_raise(Gitlab::Util::ShellOutExecutionError.new("git describe --tags --exact-match", 128, "", "fatal: no tag exactly matches '#{branch}'"))
62+
end
63+
64+
def stub_mr_branch(branch)
65+
stub_env_var('CI_MERGE_REQUEST_SOURCE_BRANCH_NAME', branch)
66+
67+
stub_env_var('CI_COMMIT_BRANCH', '')
68+
allow(Gitlab::Util).to receive(:shellout_stdout).with('git rev-parse --abbrev-ref HEAD').and_return('HEAD')
69+
70+
stub_env_var('CI_COMMIT_TAG', '')
71+
allow(Gitlab::Util).to receive(:shellout_stdout).with('git describe --tags --exact-match').and_raise(Gitlab::Util::ShellOutExecutionError.new("git describe --tags --exact-match", 128, "", "fatal: no tag exactly matches '#{branch}'"))
6072
end
6173

6274
def stub_tag(tag)
@@ -65,6 +77,8 @@ def stub_tag(tag)
6577

6678
stub_env_var('CI_COMMIT_BRANCH', '')
6779
allow(Gitlab::Util).to receive(:shellout_stdout).with('git rev-parse --abbrev-ref HEAD').and_return('HEAD')
80+
81+
stub_env_var('CI_MERGE_REQUEST_SOURCE_BRANCH_NAME', '')
6882
end
6983

7084
def stub_is_package_version(package, value = nil)

0 commit comments

Comments
 (0)