Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2022-01-25 09:12:18 +00:00
parent 52790571c1
commit d2bb55891e
22 changed files with 144 additions and 39 deletions

View file

@ -159,7 +159,7 @@ add-jh-folder:
script:
- JH_BRANCH=$(./scripts/setup/find-jh-branch.rb)
- 'echo "JH_BRANCH: ${JH_BRANCH}"'
- curl --location -o "jh-folder.tar.gz" "https://gitlab.com/gitlab-jh/gitlab/-/archive/${JH_BRANCH}/gitlab-${JH_BRANCH}.tar.gz?path=jh"
- curl --location -o "jh-folder.tar.gz" "https://gitlab.com/gitlab-org/gitlab-jh/gitlab/-/archive/${JH_BRANCH}/gitlab-${JH_BRANCH}.tar.gz?path=jh"
- tar -xf "jh-folder.tar.gz"
- mv "gitlab-${JH_BRANCH}-jh/jh/" ./
- cp Gemfile.lock jh/

View file

@ -31,6 +31,9 @@ export default {
this.action === 'userAdded' && isExperimentVariant('invite_for_help_continuous_onboarding')
);
},
openInNewTab() {
return ACTION_LABELS[this.action]?.openInNewTab === true;
},
},
methods: {
openModal() {
@ -61,8 +64,9 @@ export default {
</gl-link>
<gl-link
v-else
target="_blank"
:target="openInNewTab ? '_blank' : '_self'"
:href="value.url"
data-testid="uncompleted-learn-gitlab-link"
data-track-action="click_link"
:data-track-label="$options.i18n.ACTION_LABELS[action].title"
data-track-property="Growth::Conversion::Experiment::LearnGitLab"

View file

@ -62,6 +62,7 @@ export const ACTION_LABELS = {
description: s__('LearnGitLab|Scan your code to uncover vulnerabilities before deploying.'),
section: 'deploy',
position: 1,
openInNewTab: true,
},
issueCreated: {
title: s__('LearnGitLab|Create an issue'),

View file

@ -179,6 +179,8 @@ module Ci
scope :order_contacted_at_desc, -> { order(contacted_at: :desc) }
scope :order_created_at_asc, -> { order(created_at: :asc) }
scope :order_created_at_desc, -> { order(created_at: :desc) }
scope :order_token_expires_at_asc, -> { order(token_expires_at: :asc) }
scope :order_token_expires_at_desc, -> { order(token_expires_at: :desc) }
scope :with_tags, -> { preload(:tags) }
validate :tag_constraints
@ -247,6 +249,10 @@ module Ci
order_contacted_at_desc
when 'created_at_asc'
order_created_at_asc
when 'token_expires_at_asc'
order_token_expires_at_asc
when 'token_expires_at_desc'
order_token_expires_at_desc
else
order_created_at_desc
end

View file

@ -28,7 +28,7 @@ end
unless Gitlab.jh?
Gitlab::Database::Partitioning.register_tables([
# This should be synchronized with the following model:
# https://gitlab.com/gitlab-jh/gitlab/-/blob/main-jh/jh/app/models/phone/verification_code.rb
# https://jihulab.com/gitlab-cn/gitlab/-/blob/main-jh/jh/app/models/phone/verification_code.rb
{
table_name: 'verification_codes',
partitioned_column: :created_at, strategy: :monthly

View file

@ -0,0 +1,20 @@
# frozen_string_literal: true
class ScheduleFixIncorrectMaxSeatsUsed < Gitlab::Database::Migration[1.0]
DOWNTIME = false
TMP_IDX_NAME = 'tmp_gitlab_subscriptions_max_seats_used_migration'
disable_ddl_transaction!
def up
add_concurrent_index :gitlab_subscriptions, :id, where: "start_date >= '2021-08-02' AND start_date <= '2021-11-20' AND max_seats_used != 0 AND max_seats_used > seats_in_use AND max_seats_used > seats", name: TMP_IDX_NAME
return unless Gitlab.com?
migrate_in(1.hour, 'FixIncorrectMaxSeatsUsed')
end
def down
remove_concurrent_index_by_name :gitlab_subscriptions, TMP_IDX_NAME
end
end

View file

@ -0,0 +1 @@
faf899c1aa99e596eb386935ee6ff17a51b7942ee4f6d4cbd1ad2283dd0d40c0

View file

@ -28157,6 +28157,8 @@ CREATE UNIQUE INDEX taggings_idx ON taggings USING btree (tag_id, taggable_id, t
CREATE UNIQUE INDEX term_agreements_unique_index ON term_agreements USING btree (user_id, term_id);
CREATE INDEX tmp_gitlab_subscriptions_max_seats_used_migration ON gitlab_subscriptions USING btree (id) WHERE ((start_date >= '2021-08-02'::date) AND (start_date <= '2021-11-20'::date) AND (max_seats_used <> 0) AND (max_seats_used > seats_in_use) AND (max_seats_used > seats));
CREATE INDEX tmp_idx_deduplicate_vulnerability_occurrences ON vulnerability_occurrences USING btree (project_id, report_type, location_fingerprint, primary_identifier_id, id);
CREATE INDEX tmp_idx_vulnerability_occurrences_on_id_where_report_type_7_99 ON vulnerability_occurrences USING btree (id) WHERE (report_type = ANY (ARRAY[7, 99]));

View file

@ -1,7 +1,7 @@
---
stage: none
group: unassigned
info: https://gitlab.com/gitlab-jh/gitlab
info: https://jihulab.com/gitlab-cn/gitlab
---
# Guidelines for reviewing JiHu (JH) Edition related merge requests
@ -21,13 +21,13 @@ We have two kinds of changes related to JH:
- We will generalize this so both EE and JH can share the same mechanism,
then we wouldn't have to treat them differently.
If needed, review the corresponding JH merge request located at [JH repository](https://gitlab.com/gitlab-jh/gitlab)
If needed, review the corresponding JH merge request located at [JH repository](https://jihulab.com/gitlab-cn/gitlab)
## When to merge files to the GitLab Inc. repository
Files that are added to the `gitlab-jh` repository outside of `jh/` must be mirrored in the GitLab Inc. repository.
Files that are added to the GitLab JH repository outside of `jh/` must be mirrored in the GitLab Inc. repository.
If code that is added to the GitLab Inc. repository references (for example, `render_if_exists`) any `gitlab-jh` file that does not
If code that is added to the GitLab Inc. repository references (for example, `render_if_exists`) any GitLab JH file that does not
exist in the GitLab Inc. codebase, add a comment with a link to the JiHu merge request or file. This is to prevent
the reference from being misidentified as a missing partial and subsequently deleted in the `gitlab` codebase.
@ -49,7 +49,7 @@ This page is the single source of truth for JiHu-related processes.
## CI pipelines in a JH context
EE repository does not have `jh/` directory therefore there is no way to run
JH pipelines in the EE repository. All JH tests should go to [JH repository](https://gitlab.com/gitlab-jh/gitlab).
JH pipelines in the EE repository. All JH tests should go to [JH repository](https://jihulab.com/gitlab-cn/gitlab).
The top-level JH CI configuration is located at `jh/.gitlab-ci.yml` (which
does not exist in EE repository) and it'll include EE CI configurations
@ -89,7 +89,7 @@ Do not use methods such as `prepend`, `extend`, and `include`. Instead, use
the relevant EE and JH modules by the name of the receiver module.
If reviewing the corresponding JH file is needed, it should be found at
[JH repository](https://gitlab.com/gitlab-jh/gitlab).
[JH repository](https://jihulab.com/gitlab-cn/gitlab).
### General guidance for writing JH extensions

View file

@ -194,7 +194,7 @@ If you want to force a Review App to be deployed regardless of your changes, you
## As-if-FOSS jobs
The `* as-if-foss` jobs run the GitLab test suite "as if FOSS", meaning as if the jobs would run in the context
of the `gitlab-org/gitlab-foss` project. These jobs are only created in the following cases:
of `gitlab-org/gitlab-foss`. These jobs are only created in the following cases:
- when the `pipeline:run-as-if-foss` label is set on the merge request
- when the merge request is created in the `gitlab-org/security/gitlab` project
@ -203,13 +203,12 @@ of the `gitlab-org/gitlab-foss` project. These jobs are only created in the foll
The `* as-if-foss` jobs are run in addition to the regular EE-context jobs. They have the `FOSS_ONLY='1'` variable
set and get the `ee/` folder removed before the tests start running.
The intent is to ensure that a change doesn't introduce a failure after the `gitlab-org/gitlab` project is synced to
the `gitlab-org/gitlab-foss` project.
The intent is to ensure that a change doesn't introduce a failure after `gitlab-org/gitlab` is synced to `gitlab-org/gitlab-foss`.
## As-if-JH jobs
The `* as-if-jh` jobs run the GitLab test suite "as if JiHu", meaning as if the jobs would run in the context
of [the `gitlab-jh/gitlab` project](jh_features_review.md). These jobs are only created in the following cases:
of [GitLab JH](jh_features_review.md). These jobs are only created in the following cases:
- when the `pipeline:run-as-if-jh` label is set on the merge request
- when the `pipeline:run-all-rspec` label is set on the merge request
@ -218,16 +217,18 @@ of [the `gitlab-jh/gitlab` project](jh_features_review.md). These jobs are only
The `* as-if-jh` jobs are run in addition to the regular EE-context jobs. The `jh/` folder is added before the tests start running.
The intent is to ensure that a change doesn't introduce a failure after the `gitlab-org/gitlab` project is synced to
the `gitlab-jh/gitlab` project.
The intent is to ensure that a change doesn't introduce a failure after the `gitlab-org/gitlab` is synced to [GitLab JH](https://jihulab.com/gitlab-cn/gitlab).
### Corresponding JH branch
You can create a corresponding JH branch on the `gitlab-jh/gitlab` project by
You can create a corresponding JH branch on [GitLab JH](https://jihulab.com/gitlab-cn/gitlab) by
appending `-jh` to the branch name. If a corresponding JH branch is found,
`* as-if-jh` jobs grab the `jh` folder from the respective branch,
rather than from the default branch.
NOTE:
For now, CI will try to fetch the branch on the [GitLab JH mirror](https://gitlab.com/gitlab-org/gitlab-jh/gitlab), so it might take some time for the new JH branch to propagate to the mirror.
## `undercover` RSpec test
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/74859) in GitLab 14.6.

View file

@ -0,0 +1,13 @@
# frozen_string_literal: true
module Gitlab
module BackgroundMigration
# rubocop: disable Style/Documentation
class FixIncorrectMaxSeatsUsed
def perform
end
end
end
end
Gitlab::BackgroundMigration::FixIncorrectMaxSeatsUsed.prepend_mod_with('Gitlab::BackgroundMigration::FixIncorrectMaxSeatsUsed')

View file

@ -78,7 +78,11 @@ module Gitlab
# All tables from `information_schema.` are `:gitlab_shared`
return :gitlab_shared if schema_name == 'information_schema'
# All tables that start with `_test_` are shared and ignored
return :gitlab_main if table_name.start_with?('_test_gitlab_main_')
return :gitlab_ci if table_name.start_with?('_test_gitlab_ci_')
# All tables that start with `_test_` without a following schema are shared and ignored
return :gitlab_shared if table_name.start_with?('_test_')
# All `pg_` tables are marked as `shared`

View file

@ -15878,6 +15878,9 @@ msgstr ""
msgid "Geo|Offline"
msgstr ""
msgid "Geo|Open replications"
msgstr ""
msgid "Geo|Pending synchronization"
msgstr ""
@ -15935,9 +15938,6 @@ msgstr ""
msgid "Geo|Replication Details"
msgstr ""
msgid "Geo|Replication details"
msgstr ""
msgid "Geo|Replication slot WAL"
msgstr ""

View file

@ -44,9 +44,9 @@ module QA
open_invite_members_modal
within_element(:invite_members_modal_content) do
fill_element :members_token_select_input, username
fill_element(:members_token_select_input, username)
Support::WaitForRequests.wait_for_requests
click_button username
click_button(username, match: :prefer_exact)
set_access_level(access_level)
end

View file

@ -8,7 +8,7 @@ require_relative '../api/default_options'
class FindJhBranch
JH_DEFAULT_BRANCH = 'main-jh'
JH_PROJECT_PATH = 'gitlab-jh/gitlab'
JH_PROJECT_PATH = 'gitlab-org/gitlab-jh/gitlab'
BranchNotFound = Class.new(RuntimeError)
def run

View file

@ -135,13 +135,13 @@ exports[`Learn GitLab renders correctly 1`] = `
>
<a
class="gl-link"
data-testid="uncompleted-learn-gitlab-link"
data-track-action="click_link"
data-track-experiment="change_continuous_onboarding_link_urls"
data-track-label="Set up CI/CD"
data-track-property="Growth::Conversion::Experiment::LearnGitLab"
href="http://example.com/"
rel="noopener noreferrer"
target="_blank"
target="_self"
>
Set up CI/CD
@ -155,13 +155,13 @@ exports[`Learn GitLab renders correctly 1`] = `
>
<a
class="gl-link"
data-testid="uncompleted-learn-gitlab-link"
data-track-action="click_link"
data-track-experiment="change_continuous_onboarding_link_urls"
data-track-label="Start a free Ultimate trial"
data-track-property="Growth::Conversion::Experiment::LearnGitLab"
href="http://example.com/"
rel="noopener noreferrer"
target="_blank"
target="_self"
>
Start a free Ultimate trial
@ -175,13 +175,13 @@ exports[`Learn GitLab renders correctly 1`] = `
>
<a
class="gl-link"
data-testid="uncompleted-learn-gitlab-link"
data-track-action="click_link"
data-track-experiment="change_continuous_onboarding_link_urls"
data-track-label="Add code owners"
data-track-property="Growth::Conversion::Experiment::LearnGitLab"
href="http://example.com/"
rel="noopener noreferrer"
target="_blank"
target="_self"
>
Add code owners
@ -202,13 +202,13 @@ exports[`Learn GitLab renders correctly 1`] = `
>
<a
class="gl-link"
data-testid="uncompleted-learn-gitlab-link"
data-track-action="click_link"
data-track-experiment="change_continuous_onboarding_link_urls"
data-track-label="Add merge request approval"
data-track-property="Growth::Conversion::Experiment::LearnGitLab"
href="http://example.com/"
rel="noopener noreferrer"
target="_blank"
target="_self"
>
Add merge request approval
@ -265,13 +265,13 @@ exports[`Learn GitLab renders correctly 1`] = `
>
<a
class="gl-link"
data-testid="uncompleted-learn-gitlab-link"
data-track-action="click_link"
data-track-experiment="change_continuous_onboarding_link_urls"
data-track-label="Create an issue"
data-track-property="Growth::Conversion::Experiment::LearnGitLab"
href="http://example.com/"
rel="noopener noreferrer"
target="_blank"
target="_self"
>
Create an issue
@ -285,13 +285,13 @@ exports[`Learn GitLab renders correctly 1`] = `
>
<a
class="gl-link"
data-testid="uncompleted-learn-gitlab-link"
data-track-action="click_link"
data-track-experiment="change_continuous_onboarding_link_urls"
data-track-label="Submit a merge request"
data-track-property="Growth::Conversion::Experiment::LearnGitLab"
href="http://example.com/"
rel="noopener noreferrer"
target="_blank"
target="_self"
>
Submit a merge request
@ -341,11 +341,12 @@ exports[`Learn GitLab renders correctly 1`] = `
>
<a
class="gl-link"
data-testid="uncompleted-learn-gitlab-link"
data-track-action="click_link"
data-track-experiment="change_continuous_onboarding_link_urls"
data-track-label="Run a Security scan using CI/CD"
data-track-property="Growth::Conversion::Experiment::LearnGitLab"
href="http://example.com/"
href="https://docs.gitlab.com/ee/foobar/"
rel="noopener noreferrer"
target="_blank"
>

View file

@ -12,6 +12,10 @@ const defaultProps = {
completed: false,
};
const docLinkProps = {
url: 'https://docs.gitlab.com/ee/user/application_security/security_dashboard/',
};
describe('Learn GitLab Section Link', () => {
let wrapper;
@ -53,6 +57,14 @@ describe('Learn GitLab Section Link', () => {
expect(wrapper.find('[data-testid="trial-only"]').exists()).toBe(true);
});
it('renders doc links with blank target', () => {
createWrapper('securityScanEnabled', docLinkProps);
const linkElement = wrapper.find('[data-testid="uncompleted-learn-gitlab-link"]');
expect(linkElement.exists()).toBe(true);
expect(linkElement.attributes('target')).toEqual('_blank');
});
describe('rendering a link to open the invite_members modal instead of a regular link', () => {
it.each`
action | experimentVariant | showModal

View file

@ -35,7 +35,7 @@ export const testActions = {
svg: 'http://example.com/images/illustration.svg',
},
securityScanEnabled: {
url: 'http://example.com/',
url: 'https://docs.gitlab.com/ee/foobar/',
completed: false,
svg: 'http://example.com/images/illustration.svg',
},

View file

@ -44,6 +44,8 @@ RSpec.describe Gitlab::Database::GitlabSchema do
'my_schema.ci_builds' | :gitlab_ci
'information_schema.columns' | :gitlab_shared
'audit_events_part_5fc467ac26' | :gitlab_main
'_test_gitlab_main_table' | :gitlab_main
'_test_gitlab_ci_table' | :gitlab_ci
'_test_my_table' | :gitlab_shared
'pg_attribute' | :gitlab_shared
'my_other_table' | :undefined_my_other_table

View file

@ -0,0 +1,26 @@
# frozen_string_literal: true
require 'spec_helper'
require_migration!
RSpec.describe ScheduleFixIncorrectMaxSeatsUsed, :migration do
let(:migration) { described_class.new }
describe '#up' do
it 'schedules a job on Gitlab.com' do
allow(Gitlab).to receive(:com?).and_return(true)
expect(migration).to receive(:migrate_in).with(1.hour, 'FixIncorrectMaxSeatsUsed')
migration.up
end
it 'does not schedule any jobs when not Gitlab.com' do
allow(Gitlab::CurrentSettings).to receive(:com?).and_return(false)
expect(migration).not_to receive(:migrate_in)
migration.up
end
end
end

View file

@ -1303,6 +1303,18 @@ RSpec.describe Ci::Runner do
expect(runners).to eq([runner2, runner1])
end
it 'supports ordering by the token expiration' do
runner1 = create(:ci_runner, token_expires_at: 1.year.from_now)
runner2 = create(:ci_runner)
runner3 = create(:ci_runner, token_expires_at: 1.month.from_now)
runners = described_class.order_by('token_expires_at_asc')
expect(runners).to eq([runner3, runner1, runner2])
runners = described_class.order_by('token_expires_at_desc')
expect(runners).to eq([runner2, runner1, runner3])
end
end
describe '.runner_matchers' do

View file

@ -75,7 +75,7 @@ RSpec.describe AfterCommitQueue do
skip_if_multiple_databases_not_setup
table_sql = <<~SQL
CREATE TABLE _test_ci_after_commit_queue (
CREATE TABLE _test_gitlab_ci_after_commit_queue (
id serial NOT NULL PRIMARY KEY);
SQL
@ -84,7 +84,7 @@ RSpec.describe AfterCommitQueue do
let(:ci_klass) do
Class.new(Ci::ApplicationRecord) do
self.table_name = '_test_ci_after_commit_queue'
self.table_name = '_test_gitlab_ci_after_commit_queue'
include AfterCommitQueue