Skip to content

Commit e7d07db

Browse files
author
GitLab Bot
committed
Add latest changes from gitlab-org/gitlab@master
1 parent b3c5dfb commit e7d07db

22 files changed

+136
-92
lines changed

db/docs/batched_background_migrations/backfill_or_drop_ci_pipeline_on_project_id.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/155137
66
milestone: '17.1'
77
queued_migration_version: 20240531202753
88
finalize_after: '2024-06-30'
9-
finalized_by: # version of the migration that finalized this BBM
9+
finalized_by: 20240704155541
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# frozen_string_literal: true
2+
3+
class FinalizeBackfillPipelineProjectId < Gitlab::Database::Migration[2.2]
4+
disable_ddl_transaction!
5+
milestone '17.3'
6+
restrict_gitlab_migration gitlab_schema: :gitlab_ci
7+
8+
MIGRATION = 'BackfillOrDropCiPipelineOnProjectId'
9+
10+
def up
11+
ensure_batched_background_migration_is_finished(
12+
job_class_name: MIGRATION,
13+
table_name: :ci_pipelines,
14+
column_name: :id,
15+
job_arguments: [],
16+
finalize: true
17+
)
18+
end
19+
20+
def down
21+
# no-op
22+
end
23+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# frozen_string_literal: true
2+
3+
class AddNotNullConstraintToCiPipelinesProjectId < Gitlab::Database::Migration[2.2]
4+
disable_ddl_transaction!
5+
milestone '17.3'
6+
7+
def up
8+
add_not_null_constraint :ci_pipelines, :project_id, validate: false
9+
end
10+
11+
def down
12+
remove_not_null_constraint :ci_pipelines, :project_id
13+
end
14+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# frozen_string_literal: true
2+
3+
class PrepareCiPipelinesProjectIdCheckConstraint < Gitlab::Database::Migration[2.2]
4+
milestone '17.3'
5+
6+
CONSTRAINT_NAME = 'check_2ba2a044b9'
7+
8+
def up
9+
prepare_async_check_constraint_validation :ci_pipelines, name: CONSTRAINT_NAME
10+
end
11+
12+
def down
13+
unprepare_async_check_constraint_validation :ci_pipelines, name: CONSTRAINT_NAME
14+
end
15+
end

db/schema_migrations/20240704155541

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
16318b19fa9bb6a51f03009beb7abdb5cc9f0600fa62be32ac4c278ba426567e

db/schema_migrations/20240704155702

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
83f5f6055d7cf41159485fa74e0bc6a0cb2223dc007a348542b5752f91d7fc16

db/schema_migrations/20240705035824

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
d3a7991ca8277600a9e43687ff2686b6ce90d4b3305683842bdde12b543c62d5

db/structure.sql

+3
Original file line numberDiff line numberDiff line change
@@ -22550,6 +22550,9 @@ ALTER TABLE ONLY chat_teams
2255022550
ALTER TABLE workspaces
2255122551
ADD CONSTRAINT check_2a89035b04 CHECK ((personal_access_token_id IS NOT NULL)) NOT VALID;
2255222552

22553+
ALTER TABLE ci_pipelines
22554+
ADD CONSTRAINT check_2ba2a044b9 CHECK ((project_id IS NOT NULL)) NOT VALID;
22555+
2255322556
ALTER TABLE vulnerability_scanners
2255422557
ADD CONSTRAINT check_37608c9db5 CHECK ((char_length(vendor) <= 255)) NOT VALID;
2255522558

doc/development/documentation/testing/markdownlint.md

+18
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,24 @@ To configure markdownlint in your editor, install one of the following as approp
8383
((markdown-mode . ((flycheck-markdown-markdownlint-cli-config . ".markdownlint.yml"))))
8484
```
8585

86+
## Run `markdownlint-cli2` locally
87+
88+
You can run `markdownlint-cli2` from anywhere in your repository. From the root of your repository,
89+
you don't need to specify the location of the configuration file. If you run it from elsewhere
90+
in your repository, you must specify the configuration file's location. In these commands,
91+
replace `doc/**/*.md` with the path to the Markdown files in your repository:
92+
93+
```shell
94+
# From the root directory, you don't need to specify the configuration file
95+
$ markdownlint-cli2 'doc/**/*.md'
96+
97+
# From elsewhere in the repository, specify the configuration file
98+
$ markdownlint-cli2 --config .markdownlint-cli2.yaml 'doc/**/*.md'
99+
```
100+
101+
For a full list of command-line options, see [Command Line](https://github.com/DavidAnson/markdownlint-cli2?tab=readme-ov-file#command-line)
102+
in the `markdownlint-cli2` documentation.
103+
86104
## Disable markdownlint tests
87105

88106
To disable all markdownlint rules, add a `<!-- markdownlint-disable -->` tag before the text, and a

qa/qa/flow/pipeline.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module Pipeline
88
# Acceptable statuses:
99
# Canceled, Created, Failed, Manual, Passed
1010
# Pending, Running, Skipped
11-
def visit_latest_pipeline(status: nil, wait: nil, skip_wait: true)
11+
def visit_latest_pipeline(status: nil, wait: 120, skip_wait: true)
1212
Page::Project::Menu.perform(&:go_to_pipelines)
1313
Page::Project::Pipeline::Index.perform do |index|
1414
index.has_any_pipeline?(wait: wait)
@@ -17,7 +17,7 @@ def visit_latest_pipeline(status: nil, wait: nil, skip_wait: true)
1717
end
1818
end
1919

20-
def wait_for_latest_pipeline(status: nil, wait: nil)
20+
def wait_for_latest_pipeline(status: nil, wait: 120)
2121
Page::Project::Menu.perform(&:go_to_pipelines)
2222
Page::Project::Pipeline::Index.perform do |index|
2323
index.has_any_pipeline?(wait: wait)

spec/features/merge_request/user_sees_pipelines_spec.rb

+4-2
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,12 @@
148148
sign_in(actor)
149149
end
150150

151+
# rubocop:disable Cop/DestroyAll -- cannot delete due to not-null constraint
151152
after do
152-
parent_project.all_pipelines.delete_all
153-
forked_project.all_pipelines.delete_all
153+
parent_project.all_pipelines.destroy_all
154+
forked_project.all_pipelines.destroy_all
154155
end
156+
# rubocop:enable Cop/DestroyAll
155157

156158
context 'when actor is a developer in parent project' do
157159
let(:actor) { developer_in_parent }

spec/lib/gitlab/background_migration/backfill_or_drop_ci_pipeline_on_project_id_spec.rb

+25-42
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
require 'spec_helper'
44

5-
RSpec.describe Gitlab::BackgroundMigration::BackfillOrDropCiPipelineOnProjectId, feature_category: :continuous_integration do
5+
RSpec.describe Gitlab::BackgroundMigration::BackfillOrDropCiPipelineOnProjectId,
6+
feature_category: :continuous_integration,
7+
migration: :gitlab_ci do
68
let(:project_id_with_build) { 137 }
79
let(:project_id_for_merge_request) { 140 }
810
let(:project_id_for_unaffected_pipeline) { 1 }
@@ -24,22 +26,6 @@
2426
table(:p_ci_builds, database: :ci).create!(partition_id: 100, project_id: project_id_with_build, commit_id: 2)
2527
end
2628

27-
let(:namespace) { table(:namespaces).create!(name: 'user', path: 'user') }
28-
let(:project) do
29-
table(:projects)
30-
.create!(id: project_id_for_merge_request, namespace_id: namespace.id, project_namespace_id: namespace.id)
31-
end
32-
33-
let!(:merge_request) do
34-
table(:merge_requests).create!(
35-
id: 1,
36-
target_branch: 'main',
37-
source_branch: 'feature',
38-
target_project_id: project.id,
39-
source_project_id: project.id
40-
)
41-
end
42-
4329
subject(:migration) do
4430
described_class.new(
4531
start_id: 1,
@@ -53,49 +39,46 @@
5339
end
5440

5541
describe '#perform' do
42+
before do
43+
allow(Gitlab::BackgroundMigration::BackfillOrDropCiPipelineOnProjectId::MergeRequest)
44+
.to receive_message_chain(:where, :select)
45+
.and_return([])
46+
end
47+
5648
it 'backfills if applicable otherwise deletes' do
5749
migration.perform
5850

5951
expect { pipeline_with_nothing.reload }.to raise_error(ActiveRecord::RecordNotFound)
6052
expect { trigger_request.reload }.to raise_error(ActiveRecord::RecordNotFound)
6153
expect(pipeline_with_builds.reload.project_id).to eq(project_id_with_build)
62-
expect(pipeline_with_merge_request.reload.project_id).to eq(project_id_for_merge_request)
6354
expect(untouched_pipeline.reload.project_id).to eq(project_id_for_unaffected_pipeline)
6455
end
6556

66-
context 'when associations are invalid as well' do
67-
let!(:pipeline_with_bad_build) { table(:ci_pipelines, database: :ci).create!(id: 5, partition_id: 100) }
68-
let!(:bad_build) { table(:p_ci_builds, database: :ci).create!(partition_id: 100, commit_id: 5) }
57+
context 'for migrations with merge_request' do
58+
before do
59+
merge_request = double('merge_request') # rubocop:disable RSpec/VerifiedDoubles -- merge_request is a already a stub of applicationRecord
60+
allow(merge_request).to receive(:target_project_id) { project_id_for_merge_request }
6961

70-
it 'deletes pipeline if associations do not have project_id' do
71-
migration.perform
72-
73-
expect { pipeline_with_bad_build.reload }.to raise_error(ActiveRecord::RecordNotFound)
62+
allow(Gitlab::BackgroundMigration::BackfillOrDropCiPipelineOnProjectId::MergeRequest)
63+
.to receive_message_chain(:where, :select)
64+
.and_return([merge_request])
7465
end
75-
end
7666

77-
context 'when the merge request is from a fork project' do
78-
let(:another_namespace) { table(:namespaces).create!(name: 'user2', path: 'user2') }
67+
it 'backfills from merge_request' do
68+
migration.perform
7969

80-
let(:another_project) do
81-
table(:projects)
82-
.create!(id: 141, namespace_id: another_namespace.id, project_namespace_id: another_namespace.id)
70+
expect(pipeline_with_merge_request.reload.project_id).to eq(project_id_for_merge_request)
8371
end
72+
end
8473

85-
let!(:merge_request) do
86-
table(:merge_requests).create!(
87-
id: 1,
88-
target_branch: 'main',
89-
source_branch: 'feature',
90-
target_project_id: project.id,
91-
source_project_id: another_project.id
92-
)
93-
end
74+
context 'when associations are invalid as well' do
75+
let!(:pipeline_with_bad_build) { table(:ci_pipelines, database: :ci).create!(id: 5, partition_id: 100) }
76+
let!(:bad_build) { table(:p_ci_builds, database: :ci).create!(partition_id: 100, commit_id: 5) }
9477

95-
it 'deletes the pipeline as association is not definite' do
78+
it 'deletes pipeline if associations do not have project_id' do
9679
migration.perform
9780

98-
expect { pipeline_with_merge_request.reload }.to raise_error(ActiveRecord::RecordNotFound)
81+
expect { pipeline_with_bad_build.reload }.to raise_error(ActiveRecord::RecordNotFound)
9982
end
10083
end
10184
end

spec/lib/gitlab/background_migration/backfill_partition_id_ci_daily_build_group_report_result_spec.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
RSpec.describe Gitlab::BackgroundMigration::BackfillPartitionIdCiDailyBuildGroupReportResult, feature_category: :ci_scaling do
66
let(:ci_pipelines_table) { table(:ci_pipelines, database: :ci) }
77
let(:ci_daily_build_group_report_results_table) { table(:ci_daily_build_group_report_results, database: :ci) }
8-
let!(:pipeline_1) { ci_pipelines_table.create!(id: 1, partition_id: 100) }
9-
let!(:pipeline_2) { ci_pipelines_table.create!(id: 2, partition_id: 101) }
10-
let!(:pipeline_3) { ci_pipelines_table.create!(id: 3, partition_id: 100) }
8+
let!(:pipeline_1) { ci_pipelines_table.create!(id: 1, partition_id: 100, project_id: 1) }
9+
let!(:pipeline_2) { ci_pipelines_table.create!(id: 2, partition_id: 101, project_id: 1) }
10+
let!(:pipeline_3) { ci_pipelines_table.create!(id: 3, partition_id: 100, project_id: 1) }
1111
let!(:ci_daily_build_group_report_results_100) do
1212
ci_daily_build_group_report_results_table.create!(
13-
date: Date.yesterday,
13+
date: 1.day.ago,
1414
project_id: 1,
1515
ref_path: 'master',
1616
group_name: 'rspec',
@@ -23,7 +23,7 @@
2323

2424
let!(:ci_daily_build_group_report_results_101) do
2525
ci_daily_build_group_report_results_table.create!(
26-
date: Date.today,
26+
date: Time.current,
2727
project_id: 1,
2828
ref_path: 'master',
2929
group_name: 'rspec',
@@ -36,7 +36,7 @@
3636

3737
let!(:invalid_ci_daily_build_group_report_results) do
3838
ci_daily_build_group_report_results_table.create!(
39-
date: Date.tomorrow,
39+
date: 1.day.from_now,
4040
project_id: 1,
4141
ref_path: 'master',
4242
group_name: 'rspec',

spec/lib/gitlab/background_migration/backfill_partition_id_ci_pipeline_artifact_spec.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
feature_category: :continuous_integration do
77
let(:ci_pipelines_table) { table(:ci_pipelines, database: :ci) }
88
let(:ci_pipeline_artifacts_table) { table(:ci_pipeline_artifacts, database: :ci) }
9-
let!(:pipeline_100) { ci_pipelines_table.create!(id: 1, partition_id: 100) }
10-
let!(:pipeline_101) { ci_pipelines_table.create!(id: 2, partition_id: 101) }
11-
let!(:pipeline_102) { ci_pipelines_table.create!(id: 3, partition_id: 100) }
9+
let!(:pipeline_100) { ci_pipelines_table.create!(id: 1, partition_id: 100, project_id: 1) }
10+
let!(:pipeline_101) { ci_pipelines_table.create!(id: 2, partition_id: 101, project_id: 1) }
11+
let!(:pipeline_102) { ci_pipelines_table.create!(id: 3, partition_id: 100, project_id: 1) }
1212
let!(:ci_pipeline_artifact_100) do
1313
ci_pipeline_artifacts_table.create!(
1414
id: 1,

spec/lib/gitlab/background_migration/backfill_partition_id_ci_pipeline_chat_data_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
feature_category: :continuous_integration do
77
let(:ci_pipelines_table) { table(:ci_pipelines, database: :ci) }
88
let(:ci_pipeline_chat_data_table) { table(:ci_pipeline_chat_data, database: :ci) }
9-
let!(:pipeline1) { ci_pipelines_table.create!(id: 1, partition_id: 100) }
10-
let!(:pipeline2) { ci_pipelines_table.create!(id: 2, partition_id: 101) }
9+
let!(:pipeline1) { ci_pipelines_table.create!(id: 1, partition_id: 100, project_id: 1) }
10+
let!(:pipeline2) { ci_pipelines_table.create!(id: 2, partition_id: 101, project_id: 1) }
1111
let!(:invalid_ci_pipeline_chat_data) do
1212
ci_pipeline_chat_data_table.create!(
1313
id: 1,

spec/lib/gitlab/background_migration/backfill_partition_id_ci_pipeline_config_spec.rb

+4-5
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
require 'spec_helper'
44

5-
RSpec.describe Gitlab::BackgroundMigration::BackfillPartitionIdCiPipelineConfig,
6-
feature_category: :continuous_integration do
5+
RSpec.describe Gitlab::BackgroundMigration::BackfillPartitionIdCiPipelineConfig, feature_category: :continuous_integration do
76
let(:ci_pipelines_table) { table(:ci_pipelines, database: :ci) }
87
let(:ci_pipeline_config_table) { table(:ci_pipelines_config, database: :ci) }
9-
let!(:pipeline_1) { ci_pipelines_table.create!(id: 1, partition_id: 100) }
10-
let!(:pipeline_2) { ci_pipelines_table.create!(id: 2, partition_id: 101) }
11-
let!(:pipeline_3) { ci_pipelines_table.create!(id: 3, partition_id: 100) }
8+
let!(:pipeline_1) { ci_pipelines_table.create!(id: 1, partition_id: 100, project_id: 1) }
9+
let!(:pipeline_2) { ci_pipelines_table.create!(id: 2, partition_id: 101, project_id: 1) }
10+
let!(:pipeline_3) { ci_pipelines_table.create!(id: 3, partition_id: 100, project_id: 1) }
1211
let!(:ci_pipeline_config_100) do
1312
ci_pipeline_config_table.create!(
1413
pipeline_id: pipeline_1.id,

spec/lib/gitlab/background_migration/backfill_partition_id_ci_pipeline_message_spec.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
RSpec.describe Gitlab::BackgroundMigration::BackfillPartitionIdCiPipelineMessage, feature_category: :ci_scaling do
66
let(:ci_pipelines_table) { table(:ci_pipelines, database: :ci) }
77
let(:ci_pipeline_messages_table) { table(:ci_pipeline_messages, database: :ci) }
8-
let!(:pipeline_1) { ci_pipelines_table.create!(id: 1, partition_id: 100) }
9-
let!(:pipeline_2) { ci_pipelines_table.create!(id: 2, partition_id: 101) }
10-
let!(:pipeline_3) { ci_pipelines_table.create!(id: 3, partition_id: 100) }
8+
let!(:pipeline_1) { ci_pipelines_table.create!(id: 1, partition_id: 100, project_id: 1) }
9+
let!(:pipeline_2) { ci_pipelines_table.create!(id: 2, partition_id: 101, project_id: 1) }
10+
let!(:pipeline_3) { ci_pipelines_table.create!(id: 3, partition_id: 100, project_id: 1) }
1111
let!(:ci_pipeline_messages_100) do
1212
ci_pipeline_messages_table.create!(
1313
content: 'content',

spec/lib/gitlab/background_migration/backfill_partition_id_ci_pipeline_metadata_spec.rb

+4-5
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
require 'spec_helper'
44

5-
RSpec.describe Gitlab::BackgroundMigration::BackfillPartitionIdCiPipelineMetadata,
6-
feature_category: :continuous_integration do
5+
RSpec.describe Gitlab::BackgroundMigration::BackfillPartitionIdCiPipelineMetadata, feature_category: :continuous_integration do
76
let(:ci_pipelines_table) { table(:ci_pipelines, database: :ci) }
87
let(:ci_pipeline_metadata_table) { table(:ci_pipeline_metadata, database: :ci) }
9-
let!(:pipeline_100) { ci_pipelines_table.create!(id: 1, partition_id: 100) }
10-
let!(:pipeline_101) { ci_pipelines_table.create!(id: 2, partition_id: 101) }
11-
let!(:pipeline_102) { ci_pipelines_table.create!(id: 3, partition_id: 100) }
8+
let!(:pipeline_100) { ci_pipelines_table.create!(id: 1, partition_id: 100, project_id: 1) }
9+
let!(:pipeline_101) { ci_pipelines_table.create!(id: 2, partition_id: 101, project_id: 1) }
10+
let!(:pipeline_102) { ci_pipelines_table.create!(id: 3, partition_id: 100, project_id: 1) }
1211
let!(:ci_pipeline_metadata_100) do
1312
ci_pipeline_metadata_table.create!(
1413
pipeline_id: pipeline_100.id,

spec/lib/gitlab/background_migration/queue_backfill_autocancel_partition_id_on_ci_pipelines_spec.rb

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
require 'spec_helper'
44

5-
RSpec.describe Gitlab::BackgroundMigration::QueueBackfillAutocancelPartitionIdOnCiPipelines, feature_category: :ci_scaling do
5+
RSpec.describe Gitlab::BackgroundMigration::QueueBackfillAutocancelPartitionIdOnCiPipelines,
6+
feature_category: :ci_scaling,
7+
migration: :gitlab_ci,
8+
schema: 20240704155541 do
69
let(:ci_pipelines_table) { table(:ci_pipelines, database: :ci) }
710

811
let!(:pipeline_1) { ci_pipelines_table.create!(partition_id: 100) }

spec/lib/gitlab/background_migration/update_ci_pipeline_artifacts_unknown_locked_status_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
let(:locked) { 1 }
2727
let(:unknown) { 2 }
2828

29-
let(:unlocked_pipeline) { pipelines.create!(locked: unlocked, partition_id: 100) }
30-
let(:locked_pipeline) { pipelines.create!(locked: locked, partition_id: 100) }
29+
let(:unlocked_pipeline) { pipelines.create!(locked: unlocked, partition_id: 100, project_id: project.id) }
30+
let(:locked_pipeline) { pipelines.create!(locked: locked, partition_id: 100, project_id: project.id) }
3131

3232
# rubocop:disable Layout/LineLength
3333
let!(:locked_artifact) { pipeline_artifacts.create!(project_id: project.id, pipeline_id: locked_pipeline.id, size: 1024, file_type: 0, file_format: 'gzip', file: 'a.gz', locked: unknown, partition_id: 100) }

spec/lib/gitlab/ci/variables/builder_spec.rb

-8
Original file line numberDiff line numberDiff line change
@@ -576,14 +576,6 @@ def var(name, value)
576576
describe '#config_variables' do
577577
subject(:config_variables) { builder.config_variables }
578578

579-
context 'without project' do
580-
before do
581-
pipeline.update!(project_id: nil)
582-
end
583-
584-
it { expect(config_variables.size).to eq(0) }
585-
end
586-
587579
context 'without repository' do
588580
let(:project) { create(:project) }
589581
let(:pipeline) { build(:ci_pipeline, ref: nil, sha: nil, project: project) }

0 commit comments

Comments
 (0)