Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-02-24 09:09:47 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-02-24 09:09:47 +0300
commite3dc4fc8f5df44ccd33739908bd4df2494cc27cc (patch)
tree2dd6f21b20665e5533bf527cd15d0650c0ea61e8
parent201a883bdfaf5dcb73142139cec70c10134f5b2c (diff)
Add latest changes from gitlab-org/gitlab@master
-rw-r--r--lib/gitlab/ci/templates/Jobs/Build.gitlab-ci.yml2
-rw-r--r--lib/gitlab/ci/templates/Jobs/Build.latest.gitlab-ci.yml2
-rw-r--r--lib/gitlab/optimistic_locking.rb5
-rw-r--r--lib/tasks/gitlab/db.rake2
-rw-r--r--locale/gitlab.pot6
-rw-r--r--spec/lib/gitlab/optimistic_locking_spec.rb13
-rw-r--r--spec/tasks/gitlab/db_rake_spec.rb52
-rw-r--r--tooling/danger/stable_branch.rb9
8 files changed, 75 insertions, 16 deletions
diff --git a/lib/gitlab/ci/templates/Jobs/Build.gitlab-ci.yml b/lib/gitlab/ci/templates/Jobs/Build.gitlab-ci.yml
index 40f5109851b..f19a4b4f802 100644
--- a/lib/gitlab/ci/templates/Jobs/Build.gitlab-ci.yml
+++ b/lib/gitlab/ci/templates/Jobs/Build.gitlab-ci.yml
@@ -1,5 +1,5 @@
variables:
- AUTO_BUILD_IMAGE_VERSION: 'v1.28.0'
+ AUTO_BUILD_IMAGE_VERSION: 'v1.29.0'
build:
stage: build
diff --git a/lib/gitlab/ci/templates/Jobs/Build.latest.gitlab-ci.yml b/lib/gitlab/ci/templates/Jobs/Build.latest.gitlab-ci.yml
index 40f5109851b..f19a4b4f802 100644
--- a/lib/gitlab/ci/templates/Jobs/Build.latest.gitlab-ci.yml
+++ b/lib/gitlab/ci/templates/Jobs/Build.latest.gitlab-ci.yml
@@ -1,5 +1,5 @@
variables:
- AUTO_BUILD_IMAGE_VERSION: 'v1.28.0'
+ AUTO_BUILD_IMAGE_VERSION: 'v1.29.0'
build:
stage: build
diff --git a/lib/gitlab/optimistic_locking.rb b/lib/gitlab/optimistic_locking.rb
index 9f39b5f122f..3c8ac55f70b 100644
--- a/lib/gitlab/optimistic_locking.rb
+++ b/lib/gitlab/optimistic_locking.rb
@@ -10,8 +10,11 @@ module Gitlab
start_time = Gitlab::Metrics::System.monotonic_time
retry_attempts = 0
+ # prevent scope override, see https://gitlab.com/gitlab-org/gitlab/-/issues/391186
+ klass = subject.is_a?(ActiveRecord::Relation) ? subject.klass : subject.class
+
begin
- subject.transaction do
+ klass.transaction do
yield(subject)
end
rescue ActiveRecord::StaleObjectError
diff --git a/lib/tasks/gitlab/db.rake b/lib/tasks/gitlab/db.rake
index bd9f0252285..14d66816551 100644
--- a/lib/tasks/gitlab/db.rake
+++ b/lib/tasks/gitlab/db.rake
@@ -505,7 +505,7 @@ namespace :gitlab do
end
if existing_metadata['classes'] && existing_metadata['classes'].sort != table_metadata['classes'].sort
- existing_metadata['classes'] = table_metadata['classes']
+ existing_metadata['classes'] = (existing_metadata['classes'] + table_metadata['classes']).uniq.sort
outdated = true
end
diff --git a/locale/gitlab.pot b/locale/gitlab.pot
index f43047edb67..47ccbb6e0f2 100644
--- a/locale/gitlab.pot
+++ b/locale/gitlab.pot
@@ -37770,6 +37770,12 @@ msgstr ""
msgid "ScanExecutionPolicy|A pipeline is run"
msgstr ""
+msgid "ScanExecutionPolicy|Add condition"
+msgstr ""
+
+msgid "ScanExecutionPolicy|Conditions"
+msgstr ""
+
msgid "ScanExecutionPolicy|Ex, tag-name-1, tag-name-2"
msgstr ""
diff --git a/spec/lib/gitlab/optimistic_locking_spec.rb b/spec/lib/gitlab/optimistic_locking_spec.rb
index 1d669573b74..34f197b5ddb 100644
--- a/spec/lib/gitlab/optimistic_locking_spec.rb
+++ b/spec/lib/gitlab/optimistic_locking_spec.rb
@@ -16,6 +16,19 @@ RSpec.describe Gitlab::OptimisticLocking do
describe '#retry_lock' do
let(:name) { 'optimistic_locking_spec' }
+ it 'does not change current_scope', :aggregate_failures do
+ instance = Class.new { include Gitlab::OptimisticLocking }.new
+ relation = pipeline.cancelable_statuses
+
+ expected_scope = Ci::Build.current_scope&.to_sql
+
+ instance.send(:retry_lock, relation, name: :test) do
+ expect(Ci::Build.current_scope&.to_sql).to eq(expected_scope)
+ end
+
+ expect(Ci::Build.current_scope&.to_sql).to eq(expected_scope)
+ end
+
context 'when state changed successfully without retries' do
subject do
described_class.retry_lock(pipeline, name: name) do |lock_subject|
diff --git a/spec/tasks/gitlab/db_rake_spec.rb b/spec/tasks/gitlab/db_rake_spec.rb
index e506144ea3e..ddfdf50a31b 100644
--- a/spec/tasks/gitlab/db_rake_spec.rb
+++ b/spec/tasks/gitlab/db_rake_spec.rb
@@ -395,7 +395,7 @@ RSpec.describe 'gitlab:db namespace rake task', :silence_stdout, feature_categor
end
end
- context 'when the dictionary files already exist' do
+ context 'when a new model class is added to the codebase' do
let(:table_class) do
Class.new(ApplicationRecord) do
self.table_name = 'table1'
@@ -410,7 +410,7 @@ RSpec.describe 'gitlab:db namespace rake task', :silence_stdout, feature_categor
table_metadata = {
'table_name' => 'table1',
- 'classes' => [],
+ 'classes' => ['TableClass'],
'feature_categories' => [],
'description' => nil,
'introduced_by_url' => nil,
@@ -418,7 +418,7 @@ RSpec.describe 'gitlab:db namespace rake task', :silence_stdout, feature_categor
}
view_metadata = {
'view_name' => 'view1',
- 'classes' => [],
+ 'classes' => ['ViewClass'],
'feature_categories' => [],
'description' => nil,
'introduced_by_url' => nil,
@@ -426,8 +426,8 @@ RSpec.describe 'gitlab:db namespace rake task', :silence_stdout, feature_categor
}
before do
- stub_const('TableClass', table_class)
- stub_const('ViewClass', view_class)
+ stub_const('TableClass1', table_class)
+ stub_const('ViewClass1', view_class)
File.write(table_file_path, table_metadata.to_yaml)
File.write(view_file_path, view_metadata.to_yaml)
@@ -435,14 +435,50 @@ RSpec.describe 'gitlab:db namespace rake task', :silence_stdout, feature_categor
allow(model).to receive(:descendants).and_return([table_class, view_class])
end
- it 'update the dictionary content' do
+ it 'appends new classes to the dictionary' do
run_rake_task('gitlab:db:dictionary:generate')
table_metadata = YAML.safe_load(File.read(table_file_path))
- expect(table_metadata['classes']).to match_array(['TableClass'])
+ expect(table_metadata['classes']).to match_array(%w[TableClass TableClass1])
view_metadata = YAML.safe_load(File.read(view_file_path))
- expect(view_metadata['classes']).to match_array(['ViewClass'])
+ expect(view_metadata['classes']).to match_array(%w[ViewClass ViewClass1])
+ end
+ end
+
+ context 'when a model class is removed from the codebase' do
+ table_metadata = {
+ 'table_name' => 'table1',
+ 'classes' => ['TableClass'],
+ 'feature_categories' => [],
+ 'description' => nil,
+ 'introduced_by_url' => nil,
+ 'milestone' => 14.3
+ }
+ view_metadata = {
+ 'view_name' => 'view1',
+ 'classes' => ['ViewClass'],
+ 'feature_categories' => [],
+ 'description' => nil,
+ 'introduced_by_url' => nil,
+ 'milestone' => 14.3
+ }
+
+ before do
+ File.write(table_file_path, table_metadata.to_yaml)
+ File.write(view_file_path, view_metadata.to_yaml)
+
+ allow(model).to receive(:descendants).and_return([])
+ end
+
+ it 'keeps the dictionary classes' do
+ run_rake_task('gitlab:db:dictionary:generate')
+
+ table_metadata = YAML.safe_load(File.read(table_file_path))
+ expect(table_metadata['classes']).to match_array(%w[TableClass])
+
+ view_metadata = YAML.safe_load(File.read(view_file_path))
+ expect(view_metadata['classes']).to match_array(%w[ViewClass])
end
end
end
diff --git a/tooling/danger/stable_branch.rb b/tooling/danger/stable_branch.rb
index 8fac1cc5fbf..fe3ea835bbc 100644
--- a/tooling/danger/stable_branch.rb
+++ b/tooling/danger/stable_branch.rb
@@ -46,13 +46,14 @@ module Tooling
MSG
NEEDS_PACKAGE_AND_TEST_MESSAGE = <<~MSG
- The `e2e:package-and-test` job is not present or needs to be triggered manually. Please start the `e2e:package-and-test`
- job and re-run `danger-review`.
+ The `e2e:package-and-test` job is not present or needs to be automatically triggered.
+ Please ensure the job is present in the latest pipeline, if necessary, retry the `danger-review` job.
+ Read the "QA e2e:package-and-test" section for more details.
MSG
WARN_PACKAGE_AND_TEST_MESSAGE = <<~MSG
- The `e2e:package-and-test` job needs to succeed or have approval from a Software Engineer in Test. See the section below
- for more details.
+ **The `e2e:package-and-test` job needs to succeed or have approval from a Software Engineer in Test.**
+ Read the "QA e2e:package-and-test" section for more details.
MSG
# rubocop:disable Style/SignalException