diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 54e444e6ec0..423a62b159b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -113,4 +113,7 @@ include: - local: .gitlab/ci/dast.gitlab-ci.yml - local: .gitlab/ci/workhorse.gitlab-ci.yml - local: .gitlab/ci/graphql.gitlab-ci.yml - - remote: 'https://gitlab.com/gitlab-org/frontend/untamper-my-lockfile/-/raw/main/.gitlab-ci-template.yml' + # switch the remote include to a local include until this is resolved: + # https://gitlab.com/gitlab-org/gitlab/-/issues/327299 + # - remote: 'https://gitlab.com/gitlab-org/frontend/untamper-my-lockfile/-/raw/main/.gitlab-ci-template.yml' + - local: .gitlab/ci/untamper-my-lockfile.yml diff --git a/.gitlab/ci/untamper-my-lockfile.yml b/.gitlab/ci/untamper-my-lockfile.yml new file mode 100644 index 00000000000..54ba160f1bd --- /dev/null +++ b/.gitlab/ci/untamper-my-lockfile.yml @@ -0,0 +1,26 @@ +untamper-my-lockfile: + image: registry.gitlab.com/gitlab-org/frontend/untamper-my-lockfile:main + stage: test + needs: [] + before_script: [] + after_script: [] + cache: {} + retry: 1 + script: + - untamper-my-lockfile --lockfile yarn.lock + rules: + # Create a pipeline if the branch is named 'add-untamper-my-lockfile' in + # order to have an integration check added in the MR that introduces it + - if: $CI_COMMIT_REF_NAME == "add-untamper-my-lockfile" + # Create a pipeline if there are changes in yarn.lock _and_ we are in a + # merge request _or_ branch pipeline. + # + # This ensures that the pipeline isn't run in scheduled jobs for example + # + # Also our best effort to support both branch and MR pipelines. In certain + # projects this might trigger _two_ pipelines. These projects can be fixed + # by adding proper workflow:rules + # https://docs.gitlab.com/ee/ci/yaml/#workflowrules + - if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH + changes: + - yarn.lock diff --git a/.gitlab/merge_request_templates/Quarantine End to End Test.md b/.gitlab/merge_request_templates/Quarantine End to End Test.md index cf0a89284ae..5794a62df96 100644 --- a/.gitlab/merge_request_templates/Quarantine End to End Test.md +++ b/.gitlab/merge_request_templates/Quarantine End to End Test.md @@ -3,7 +3,7 @@ @@ -24,15 +24,15 @@ the noise (due to constantly failing tests, flaky tests, and so on) so that new - [ ] Note if the test should be [quarantined for a specific environment](https://docs.gitlab.com/ee/development/testing_guide/end_to_end/environment_selection.html#quarantining-a-test-for-a-specific-environment). - [ ] Dequarantine test check-list - [ ] Follow the [Dequarantining Tests guide](https://about.gitlab.com/handbook/engineering/quality/guidelines/debugging-qa-test-failures/#dequarantining-tests). - - [ ] Confirm the test consistently passes on the target GitLab environment(s). - - [ ] (Optionally) [Trigger a manual GitLab-QA pipeline](https://about.gitlab.com/handbook/engineering/quality/guidelines/tips-and-tricks/#running-gitlab-qa-pipeline-against-a-specific-gitlab-release) against a specific GitLab environment using the `RELEASE` variable from the `package-and-qa` job of the current Merge Request. -- [ ] To ensure a faster turnaround, ask in the `#quality` Slack channel for someone to review and merge the merge request, rather than assigning it directly. + - [ ] Confirm the test consistently passes on the target GitLab environment(s). + - [ ] (Optionally) [Trigger a manual GitLab-QA pipeline](https://about.gitlab.com/handbook/engineering/quality/guidelines/tips-and-tricks/#running-gitlab-qa-pipeline-against-a-specific-gitlab-release) against a specific GitLab environment using the `RELEASE` variable from the `package-and-qa` job of the current merge request. +- [ ] To ensure a faster turnaround, ask in the `#quality` Slack channel for someone to review and merge the merge request, rather than assigning it directly. -/label ~"Quality" ~"QA" ~"feature" ~"feature::maintenance" +/label ~"Quality" ~"QA" ~"feature" ~"feature::maintenance" -/label ~"Pick into auto-deploy" ~"priority::1" ~"severity::1" +/label ~"Pick into auto-deploy" ~"priority::1" ~"severity::1" + Group + Created with Sketch. + + + + + + + + + + + \ No newline at end of file diff --git a/app/assets/images/learn_gitlab/section_plan.svg b/app/assets/images/learn_gitlab/section_plan.svg new file mode 100644 index 00000000000..2348e837e5f --- /dev/null +++ b/app/assets/images/learn_gitlab/section_plan.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/assets/images/learn_gitlab/section_workspace.svg b/app/assets/images/learn_gitlab/section_workspace.svg new file mode 100644 index 00000000000..5cb7fd36ddd --- /dev/null +++ b/app/assets/images/learn_gitlab/section_workspace.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/assets/javascripts/issuable_show/components/issuable_body.vue b/app/assets/javascripts/issuable_show/components/issuable_body.vue index fe102e942c9..05dc1650379 100644 --- a/app/assets/javascripts/issuable_show/components/issuable_body.vue +++ b/app/assets/javascripts/issuable_show/components/issuable_body.vue @@ -42,6 +42,10 @@ export default { type: Boolean, required: true, }, + enableZenMode: { + type: Boolean, + required: true, + }, enableTaskList: { type: Boolean, required: false, @@ -144,6 +148,7 @@ export default { :issuable="issuable" :enable-autocomplete="enableAutocomplete" :enable-autosave="enableAutosave" + :enable-zen-mode="enableZenMode" :show-field-title="showFieldTitle" :description-preview-path="descriptionPreviewPath" :description-help-path="descriptionHelpPath" diff --git a/app/assets/javascripts/issuable_show/components/issuable_edit_form.vue b/app/assets/javascripts/issuable_show/components/issuable_edit_form.vue index 6d139541524..33dca3e9332 100644 --- a/app/assets/javascripts/issuable_show/components/issuable_edit_form.vue +++ b/app/assets/javascripts/issuable_show/components/issuable_edit_form.vue @@ -4,6 +4,7 @@ import $ from 'jquery'; import Autosave from '~/autosave'; import MarkdownField from '~/vue_shared/components/markdown/field.vue'; +import ZenMode from '~/zen_mode'; import eventHub from '../event_hub'; @@ -27,6 +28,10 @@ export default { type: Boolean, required: true, }, + enableZenMode: { + type: Boolean, + required: true, + }, showFieldTitle: { type: Boolean, required: true, @@ -62,6 +67,9 @@ export default { }, mounted() { if (this.enableAutosave) this.initAutosave(); + + // eslint-disable-next-line no-new + if (this.enableZenMode) new ZenMode(); }, beforeDestroy() { eventHub.$off('update.issuable', this.resetAutosave); diff --git a/app/assets/javascripts/issuable_show/components/issuable_show_root.vue b/app/assets/javascripts/issuable_show/components/issuable_show_root.vue index b514a6b01d8..ca057094868 100644 --- a/app/assets/javascripts/issuable_show/components/issuable_show_root.vue +++ b/app/assets/javascripts/issuable_show/components/issuable_show_root.vue @@ -42,6 +42,11 @@ export default { required: false, default: true, }, + enableZenMode: { + type: Boolean, + required: false, + default: true, + }, enableTaskList: { type: Boolean, required: false, @@ -120,6 +125,7 @@ export default { :enable-edit="enableEdit" :enable-autocomplete="enableAutocomplete" :enable-autosave="enableAutosave" + :enable-zen-mode="enableZenMode" :enable-task-list="enableTaskList" :edit-form-visible="editFormVisible" :show-field-title="showFieldTitle" diff --git a/app/assets/javascripts/pages/projects/learn_gitlab/components/learn_gitlab_a.vue b/app/assets/javascripts/pages/projects/learn_gitlab/components/learn_gitlab_a.vue index 32ca623ca45..ef9e13f7ccf 100644 --- a/app/assets/javascripts/pages/projects/learn_gitlab/components/learn_gitlab_a.vue +++ b/app/assets/javascripts/pages/projects/learn_gitlab/components/learn_gitlab_a.vue @@ -1,11 +1,17 @@ diff --git a/app/assets/javascripts/pages/projects/learn_gitlab/components/learn_gitlab_b.vue b/app/assets/javascripts/pages/projects/learn_gitlab/components/learn_gitlab_b.vue index 230054ff76e..33248082bcd 100644 --- a/app/assets/javascripts/pages/projects/learn_gitlab/components/learn_gitlab_b.vue +++ b/app/assets/javascripts/pages/projects/learn_gitlab/components/learn_gitlab_b.vue @@ -1,5 +1,6 @@ + diff --git a/app/assets/javascripts/pages/projects/learn_gitlab/components/learn_gitlab_section_link.vue b/app/assets/javascripts/pages/projects/learn_gitlab/components/learn_gitlab_section_link.vue new file mode 100644 index 00000000000..6f51c7372fd --- /dev/null +++ b/app/assets/javascripts/pages/projects/learn_gitlab/components/learn_gitlab_section_link.vue @@ -0,0 +1,43 @@ + + diff --git a/app/assets/javascripts/pages/projects/learn_gitlab/constants/index.js b/app/assets/javascripts/pages/projects/learn_gitlab/constants/index.js index 80f04b0cf44..ba456131327 100644 --- a/app/assets/javascripts/pages/projects/learn_gitlab/constants/index.js +++ b/app/assets/javascripts/pages/projects/learn_gitlab/constants/index.js @@ -5,6 +5,8 @@ export const ACTION_LABELS = { title: s__('LearnGitLab|Create or import a repository'), actionLabel: s__('LearnGitLab|Create or import a repository'), description: s__('LearnGitLab|Create or import your first repository into your new project.'), + section: 'workspace', + position: 1, }, userAdded: { title: s__('LearnGitLab|Invite your colleagues'), @@ -12,16 +14,22 @@ export const ACTION_LABELS = { description: s__( 'LearnGitLab|GitLab works best as a team. Invite your colleague to enjoy all features.', ), + section: 'workspace', + position: 0, }, pipelineCreated: { title: s__('LearnGitLab|Set up CI/CD'), actionLabel: s__('LearnGitLab|Set-up CI/CD'), description: s__('LearnGitLab|Save time by automating your integration and deployment tasks.'), + section: 'workspace', + position: 2, }, trialStarted: { title: s__('LearnGitLab|Start a free Ultimate trial'), actionLabel: s__('LearnGitLab|Try GitLab Ultimate for free'), description: s__('LearnGitLab|Try all GitLab features for 30 days, no credit card required.'), + section: 'workspace', + position: 3, }, codeOwnersEnabled: { title: s__('LearnGitLab|Add code owners'), @@ -30,21 +38,50 @@ export const ACTION_LABELS = { 'LearnGitLab|Prevent unexpected changes to important assets by assigning ownership of files and paths.', ), trialRequired: true, + section: 'workspace', + position: 4, }, requiredMrApprovalsEnabled: { title: s__('LearnGitLab|Add merge request approval'), actionLabel: s__('LearnGitLab|Enable require merge approvals'), description: s__('LearnGitLab|Route code reviews to the right reviewers, every time.'), trialRequired: true, + section: 'workspace', + position: 5, }, mergeRequestCreated: { title: s__('LearnGitLab|Submit a merge request'), actionLabel: s__('LearnGitLab|Submit a merge request (MR)'), description: s__('LearnGitLab|Review and edit proposed changes to source code.'), + section: 'plan', + position: 1, }, securityScanEnabled: { - title: s__('LearnGitLab|Run a security scan'), - actionLabel: s__('LearnGitLab|Run a Security scan'), + title: s__('LearnGitLab|Run a Security scan using CI/CD'), + actionLabel: s__('LearnGitLab|Run a Security scan using CI/CD'), description: s__('LearnGitLab|Scan your code to uncover vulnerabilities before deploying.'), + section: 'deploy', + position: 1, + }, +}; + +export const ACTION_SECTIONS = { + workspace: { + title: s__('LearnGitLab|Set up your workspace'), + description: s__( + "LearnGitLab|Complete these tasks first so you can enjoy GitLab's features to their fullest:", + ), + }, + plan: { + title: s__('LearnGitLab|Plan and execute'), + description: s__( + 'LearnGitLab|Create a workflow for your new workspace, and learn how GitLab features work together:', + ), + }, + deploy: { + title: s__('LearnGitLab|Deploy'), + description: s__( + 'LearnGitLab|Use your new GitLab workflow to deploy your application, monitor its health, and keep it secure:', + ), }, }; diff --git a/app/assets/stylesheets/application_dark.scss b/app/assets/stylesheets/application_dark.scss index e55141e15df..90aab7ce342 100644 --- a/app/assets/stylesheets/application_dark.scss +++ b/app/assets/stylesheets/application_dark.scss @@ -1,3 +1,60 @@ @import './themes/dark'; @import './application'; + +@import './themes/theme_helper'; + +body.gl-dark { + @include gitlab-theme( + $gray-900, + $gray-400, + $gray-500, + $gray-800, + $gray-900, + $white + ); + + .logo-text svg { + fill: var(--gl-text-color); + } + + .navbar-gitlab { + background-color: var(--gray-50); + box-shadow: 0 1px 0 0 var(--gray-100); + + .navbar-sub-nav, + .navbar-nav { + li { + > a:hover, + > a:focus, + > button:hover, + > button:focus { + color: var(--gl-text-color); + background-color: var(--gray-200); + } + } + + li.active, + li.dropdown.show { + > a, + > button { + color: var(--gl-text-color); + background-color: var(--gray-200); + } + } + } + + .search { + form { + background-color: var(--gray-100); + box-shadow: inset 0 0 0 1px var(--border-color); + + &:active, + &:hover { + background-color: var(--gray-100); + box-shadow: inset 0 0 0 1px var(--blue-200); + } + } + } + } +} diff --git a/app/assets/stylesheets/framework/header.scss b/app/assets/stylesheets/framework/header.scss index fdb56a128c7..432be7d0b3f 100644 --- a/app/assets/stylesheets/framework/header.scss +++ b/app/assets/stylesheets/framework/header.scss @@ -442,22 +442,22 @@ font-weight: $gl-font-weight-normal; margin-left: -6px; font-size: 11px; - color: $white; + color: var(--gray-950, $white); padding: 0 5px; line-height: 12px; border-radius: 7px; box-shadow: 0 1px 0 rgba($gl-header-color, 0.2); &.green-badge { - background-color: $green-400; + background-color: var(--green-400, $green-400); } &.merge-requests-count { - background-color: $orange-400; + background-color: var(--orange-400, $orange-400); } &.todos-count { - background-color: $blue-400; + background-color: var(--blue-400, $blue-400); } } @@ -511,7 +511,7 @@ .header-user { &.show .dropdown-menu { margin-top: 4px; - color: $gl-text-color; + color: var(--gl-text-color, $gl-text-color); left: auto; max-height: $dropdown-max-height-lg; @@ -580,7 +580,7 @@ .no-emoji-placeholder, .clear-user-status { svg { - fill: $gl-text-color-secondary; + fill: var(--gray-500, $gray-500); } } diff --git a/app/assets/stylesheets/framework/variables.scss b/app/assets/stylesheets/framework/variables.scss index ce747464ec6..4db1a75a21b 100644 --- a/app/assets/stylesheets/framework/variables.scss +++ b/app/assets/stylesheets/framework/variables.scss @@ -590,7 +590,7 @@ $gl-btn-xs-line-height: 13px; /* * Badges */ -$badge-bg: rgba(0, 0, 0, 0.07); +$badge-bg: rgba($black, 0.07); /* * Pagination diff --git a/app/assets/stylesheets/lazy_bundles/select2_overrides.scss b/app/assets/stylesheets/lazy_bundles/select2_overrides.scss index 0d40159f6de..272f94176d0 100644 --- a/app/assets/stylesheets/lazy_bundles/select2_overrides.scss +++ b/app/assets/stylesheets/lazy_bundles/select2_overrides.scss @@ -12,9 +12,9 @@ .select2-container, .select2-container.select2-drop-above { .select2-choice { - background: $white; - color: $gl-text-color; - border-color: $border-color; + background: var(--white, $white); + color: var(--gl-text-color, $gl-text-color); + border-color: var(--border-color, $border-color); height: 34px; padding: $gl-vert-padding $gl-input-padding; font-size: $gl-font-size; @@ -27,6 +27,10 @@ /* stylelint-disable-next-line function-url-quotes */ background: url(asset_path('chevron-down.png')) no-repeat 2px 8px; + .gl-dark & { + filter: invert(0.9); + } + b { display: none; } @@ -37,8 +41,8 @@ } &:hover { - border-color: $gray-darkest; - color: $gl-text-color; + border-color: var(--gray-200, $gray-200); + color: var(--gl-text-color, $gl-text-color); } } @@ -49,8 +53,8 @@ // .select2-focusser element instead. &.select2-container-active:not(.select2-dropdown-open) { .select2-choice { - color: $input-focus-color; - background-color: $input-focus-bg; + color: var(--gray-700, $gray-700); + background-color: var(--white, $white); border-color: $input-focus-border-color; outline: 0; } @@ -85,19 +89,19 @@ .select2-choices, .select2-choice { - border-color: $red-500; + border-color: var(--red-500, $red-500); } } } .select2-drop, .select2-drop.select2-drop-above { - background: $white; + background: var(--white, $white); box-shadow: 0 2px 4px $dropdown-shadow-color; border-radius: $gl-border-radius-base; - border: 1px solid $border-color; + border: 1px solid var(--border-color, $border-color); min-width: 175px; - color: $gl-text-color; + color: var(--gl-text-color, $gl-text-color); z-index: 999; .modal-open & { @@ -114,7 +118,7 @@ } .select2-drop.select2-drop-above.select2-drop-active { - border-top: 1px solid $border-color; + border-top: 1px solid var(--border-color, $border-color); margin-top: -6px; } @@ -128,7 +132,7 @@ .select2-dropdown-open, .select2-dropdown-open.select2-drop-above { .select2-choice { - border-color: $gray-darkest; + border-color: var(--border-color, $border-color); outline: 0; } } @@ -136,7 +140,7 @@ .select2-container-multi { .select2-choices { border-radius: $border-radius-default; - border-color: $border-color; + border-color: var(--border-color, $border-color); background: none; .select2-search-field input { @@ -149,10 +153,10 @@ .select2-search-choice { margin: 5px 0 0 8px; box-shadow: none; - border-color: $border-color; - color: $gl-text-color; + border-color: var(--border-color, $border-color); + color: var(--gl-text-color, $gl-text-color); line-height: 15px; - background-color: $gray-light; + background-color: var(--gray-50, $gray-50); background-image: none; padding: 3px 18px 3px 5px; @@ -163,7 +167,7 @@ } &.select2-search-choice-focus { - border-color: $gl-text-color; + border-color: var(--gl-text-color, $gl-text-color); } } } @@ -188,22 +192,22 @@ input { padding: $grid-size; background: transparent image-url('select2.png'); - color: $gl-text-color; + color: var(--gl-text-color, $gl-text-color); background-clip: content-box; background-origin: content-box; background-repeat: no-repeat; background-position: right 0 bottom 0 !important; - border: 1px solid $border-color; + border: 1px solid var(--border-color, $border-color); border-radius: $border-radius-default; line-height: 16px; transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s; &:focus { - border-color: $blue-300; + border-color: var(--blue-300, $blue-300); } &.select2-active { - background-color: $white; + background-color: var(--white, $white); background-image: image-url('select2-spinner.gif') !important; background-origin: content-box; background-repeat: no-repeat; @@ -236,10 +240,10 @@ .select2-highlighted { background: transparent; - color: $gl-text-color; + color: var(--gl-text-color, $gl-text-color); .select2-result-label { - background: $gray-darker; + background: var(--gray-50, $gray-50); } } @@ -249,14 +253,14 @@ li.select2-result-with-children > .select2-result-label { font-weight: $gl-font-weight-bold; - color: $gl-text-color; + color: var(--gl-text-color, $gl-text-color); } } .select2-highlighted { .group-result { .group-path { - color: $gray-700; + color: var(--gray-700, $gray-700); } } } diff --git a/app/assets/stylesheets/page_bundles/build.scss b/app/assets/stylesheets/page_bundles/build.scss index be709ff9d09..b91850f1775 100644 --- a/app/assets/stylesheets/page_bundles/build.scss +++ b/app/assets/stylesheets/page_bundles/build.scss @@ -8,9 +8,9 @@ .archived-job { top: $header-height; border-radius: 2px 2px 0 0; - color: $orange-600; - background-color: $orange-50; - border: 1px solid $border-gray-normal; + color: var(--orange-600, $orange-600); + background-color: var(--orange-50, $orange-50); + border: 1px solid var(--border-color, $border-color); padding: 3px 12px; margin: auto; align-items: center; @@ -88,19 +88,15 @@ .header-content { a { - color: $gl-text-color; + color: var(--gl-text-color, $gl-text-color); &:hover { - color: $blue-600; + color: var(--blue-600, $blue-600); text-decoration: none; } } } - code { - color: $code-color; - } - .avatar { float: none; margin-right: 2px; @@ -148,12 +144,12 @@ .trigger-build-variable { font-weight: $gl-font-weight-normal; - color: $code-color; + color: var(--gray-950, $gray-950); } .trigger-build-value { padding: 2px 4px; - color: $black; + color: var(--black, $black); } .trigger-variables-table-cell { @@ -173,7 +169,7 @@ cursor: pointer; &:hover { - color: $gl-text-color; + color: var(--gl-text-color, $gl-text-color); } } @@ -211,7 +207,7 @@ } &.retried { - background-color: $gray-lightest; + background-color: var(--gray-10, $gray-10); } &:hover { diff --git a/app/assets/stylesheets/page_bundles/learn_gitlab.scss b/app/assets/stylesheets/page_bundles/learn_gitlab.scss index 189aefb330b..10a4a210d41 100644 --- a/app/assets/stylesheets/page_bundles/learn_gitlab.scss +++ b/app/assets/stylesheets/page_bundles/learn_gitlab.scss @@ -1,3 +1,11 @@ .learn-gitlab-info-card-content { height: 200px; } + +.learn-gitlab-section-card { + height: 400px; +} + +.learn-gitlab-section-card-header { + height: 165px; +} diff --git a/app/assets/stylesheets/themes/theme_light.scss b/app/assets/stylesheets/themes/theme_light.scss index 228bff94f5d..b41377475c5 100644 --- a/app/assets/stylesheets/themes/theme_light.scss +++ b/app/assets/stylesheets/themes/theme_light.scss @@ -81,50 +81,4 @@ body { color: $gray-900; } } - - &.gl-dark { - .logo-text svg { - fill: var(--gl-text-color); - } - - .navbar-gitlab { - background-color: var(--gray-50); - box-shadow: 0 1px 0 0 var(--gray-100); - - .navbar-sub-nav, - .navbar-nav { - li { - > a:hover, - > a:focus, - > button:hover, - > button:focus { - color: var(--gl-text-color); - background-color: var(--gray-200); - } - } - - li.active, - li.dropdown.show { - > a, - > button { - color: var(--gl-text-color); - background-color: var(--gray-200); - } - } - } - - .search { - form { - background-color: var(--gray-100); - box-shadow: inset 0 0 0 1px var(--border-color); - - &:active, - &:hover { - background-color: var(--gray-100); - box-shadow: inset 0 0 0 1px var(--blue-200); - } - } - } - } - } } diff --git a/app/helpers/ci/pipeline_editor_helper.rb b/app/helpers/ci/pipeline_editor_helper.rb index a71b0f4a83a..ceb18d90c92 100644 --- a/app/helpers/ci/pipeline_editor_helper.rb +++ b/app/helpers/ci/pipeline_editor_helper.rb @@ -7,5 +7,23 @@ module Ci def can_view_pipeline_editor?(project) can_collaborate_with_project?(project) end + + def js_pipeline_editor_data(project) + { + "ci-config-path": project.ci_config_path_or_default, + "commit-sha" => project.commit ? project.commit.sha : '', + "default-branch" => project.default_branch, + "empty-state-illustration-path" => image_path('illustrations/empty-state/empty-dag-md.svg'), + "initial-branch-name": params[:branch_name], + "lint-help-page-path" => help_page_path('ci/lint', anchor: 'validate-basic-logic-and-syntax'), + "new-merge-request-path" => namespace_project_new_merge_request_path, + "project-path" => project.path, + "project-full-path" => project.full_path, + "project-namespace" => project.namespace.full_path, + "yml-help-page-path" => help_page_path('ci/yaml/README') + } + end end end + +Ci::PipelineEditorHelper.prepend_if_ee('EE::Ci::PipelineEditorHelper') diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index 0fe29f09140..0e55841f5fa 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -394,26 +394,13 @@ module Ci # given we simply get the latest pipelines for the commits, regardless # of what refs the pipelines belong to. def self.latest_pipeline_per_commit(commits, ref = nil) - p1 = arel_table - p2 = arel_table.alias + sql = select('DISTINCT ON (sha) *') + .where(sha: commits) + .order(:sha, id: :desc) - # This LEFT JOIN will filter out all but the newest row for every - # combination of (project_id, sha) or (project_id, sha, ref) if a ref is - # given. - cond = p1[:sha].eq(p2[:sha]) - .and(p1[:project_id].eq(p2[:project_id])) - .and(p1[:id].lt(p2[:id])) + sql = sql.where(ref: ref) if ref - cond = cond.and(p1[:ref].eq(p2[:ref])) if ref - join = p1.join(p2, Arel::Nodes::OuterJoin).on(cond) - - relation = where(sha: commits) - .where(p2[:id].eq(nil)) - .joins(join.join_sources) - - relation = relation.where(ref: ref) if ref - - relation.each_with_object({}) do |pipeline, hash| + sql.each_with_object({}) do |pipeline, hash| hash[pipeline.sha] = pipeline end end diff --git a/app/services/ci/abort_pipelines_service.rb b/app/services/ci/abort_pipelines_service.rb index dae56577f51..9f427243abd 100644 --- a/app/services/ci/abort_pipelines_service.rb +++ b/app/services/ci/abort_pipelines_service.rb @@ -5,26 +5,29 @@ module Ci # Danger: Cancels in bulk without callbacks # Only for pipeline abandonment scenarios (examples: project delete, user block) def execute(pipelines) - bulk_abort!(pipelines.cancelable, status: :canceled) + @time = Time.current + + bulk_abort!(pipelines.cancelable, { status: :canceled }) ServiceResponse.success(message: 'Pipelines canceled') end private - def bulk_abort!(pipelines, status:) + def bulk_abort!(pipelines, attributes) pipelines.each_batch(of: 100) do |pipeline_batch| - update_status_for(Ci::Stage, pipeline_batch, status) - update_status_for(CommitStatus, pipeline_batch, status) - pipeline_batch.update_all(status: status, finished_at: Time.current) + update_status_for(Ci::Stage, pipeline_batch, attributes) + update_status_for(CommitStatus, pipeline_batch, attributes.merge(finished_at: @time)) + + pipeline_batch.update_all(attributes.merge(finished_at: @time)) end end - def update_status_for(klass, pipelines, status) + def update_status_for(klass, pipelines, attributes) klass.in_pipelines(pipelines) .cancelable .in_batches(of: 150) # rubocop:disable Cop/InBatches - .update_all(status: status) + .update_all(attributes) end end end diff --git a/app/views/admin/application_settings/_registry.html.haml b/app/views/admin/application_settings/_registry.html.haml index fc03a6dd10c..78d4e8c8cc3 100644 --- a/app/views/admin/application_settings/_registry.html.haml +++ b/app/views/admin/application_settings/_registry.html.haml @@ -3,7 +3,7 @@ %fieldset .form-group - = f.label :container_registry_token_expire_delay, 'Authorization token duration (minutes)', class: 'label-bold' + = f.label :container_registry_token_expire_delay, _('Authorization token duration (minutes)'), class: 'label-bold' = f.number_field :container_registry_token_expire_delay, class: 'form-control gl-form-input' .form-group .form-check @@ -31,4 +31,4 @@ .form-text.text-muted = _("The maximum number of tags that a single worker accepts for cleanup. If the number of tags goes above this limit, the list of tags to delete is truncated to this number. To remove this limit, set it to 0.") - = f.submit 'Save changes', class: "gl-button btn btn-confirm" + = f.submit _('Save changes'), class: "gl-button btn btn-confirm" diff --git a/app/views/devise/sessions/_new_ldap.html.haml b/app/views/devise/sessions/_new_ldap.html.haml index 19fcabb1a2e..f599a652b71 100644 --- a/app/views/devise/sessions/_new_ldap.html.haml +++ b/app/views/devise/sessions/_new_ldap.html.haml @@ -5,15 +5,15 @@ = form_tag(omniauth_callback_path(:user, server['provider_name']), id: 'new_ldap_user', class: "gl-show-field-errors") do .form-group = label_tag :username, "#{server['label']} Username" - = text_field_tag :username, nil, { class: "form-control gl-form-input top", title: "This field is required.", autofocus: "autofocus", data: { qa_selector: 'username_field' }, required: true } + = text_field_tag :username, nil, { class: "form-control gl-form-input top", title: _("This field is required."), autofocus: "autofocus", data: { qa_selector: 'username_field' }, required: true } .form-group = label_tag :password - = password_field_tag :password, nil, { class: "form-control gl-form-input bottom", title: "This field is required.", data: { qa_selector: 'password_field' }, required: true } + = password_field_tag :password, nil, { class: "form-control gl-form-input bottom", title: _("This field is required."), data: { qa_selector: 'password_field' }, required: true } - if !hide_remember_me && devise_mapping.rememberable? .remember-me %label{ for: "remember_me" } = check_box_tag :remember_me, '1', false, id: 'remember_me' - %span Remember me + %span= _('Remember me') .submit-container.move-submit-down = submit_tag submit_message, class: "gl-button btn btn-confirm", data: { qa_selector: 'sign_in_button' } diff --git a/app/views/profiles/chat_names/_chat_name.html.haml b/app/views/profiles/chat_names/_chat_name.html.haml index 6805824cebc..ca895972b71 100644 --- a/app/views/profiles/chat_names/_chat_name.html.haml +++ b/app/views/profiles/chat_names/_chat_name.html.haml @@ -6,7 +6,7 @@ - if can?(current_user, :read_project, project) = link_to project.full_name, project_path(project) - else - .light N/A + .light= _('N/A') %td %strong - if can?(current_user, :admin_project, project) diff --git a/app/views/projects/ci/pipeline_editor/show.html.haml b/app/views/projects/ci/pipeline_editor/show.html.haml index 2204d564697..eb588e150f7 100644 --- a/app/views/projects/ci/pipeline_editor/show.html.haml +++ b/app/views/projects/ci/pipeline_editor/show.html.haml @@ -1,15 +1,3 @@ - page_title s_('Pipelines|Pipeline Editor') -#js-pipeline-editor{ data: { "ci-config-path": @project.ci_config_path_or_default, - "commit-sha" => @project.commit ? @project.commit.sha : '', - "default-branch" => @project.default_branch, - "empty-state-illustration-path" => image_path('illustrations/empty-state/empty-dag-md.svg'), - "initial-branch-name": params[:branch_name], - "lint-help-page-path" => help_page_path('ci/lint', anchor: 'validate-basic-logic-and-syntax'), - "new-merge-request-path" => namespace_project_new_merge_request_path, - "project-path" => @project.path, - "project-full-path" => @project.full_path, - "project-namespace" => @project.namespace.full_path, - "yml-help-page-path" => help_page_path('ci/yaml/README'), - "api-fuzzing-configuration-path" => project_security_configuration_api_fuzzing_path(@project), -} } +#js-pipeline-editor{ data: js_pipeline_editor_data(@project) } diff --git a/app/views/projects/triggers/_index.html.haml b/app/views/projects/triggers/_index.html.haml index c7cb051e40d..85ecfe7a982 100644 --- a/app/views/projects/triggers/_index.html.haml +++ b/app/views/projects/triggers/_index.html.haml @@ -2,9 +2,9 @@ .col-lg-12 .card .card-header - = s_("Manage your project's triggers") + = _("Manage your project's triggers") .card-body - = render "projects/triggers/form", btn_text: "Add trigger" + = render 'projects/triggers/form', btn_text: _('Add trigger') %hr - if Feature.enabled?(:ci_pipeline_triggers_settings_vue_ui, @project) #js-ci-pipeline-triggers-list.triggers-list{ data: { triggers: @triggers_json } } @@ -15,32 +15,32 @@ %thead %th %strong - = s_("Token") + = _('Token') %th %strong - = s_("Description") + = _('Description') %th %strong - = s_("Owner") + = _('Owner') %th %strong - = s_("Last used") + = _('Last used') %th = render partial: 'projects/triggers/trigger', collection: @triggers, as: :trigger - else %p.settings-message.text-center.gl-mb-3{ data: { testid: 'no_triggers_content' } } - = s_("No triggers exist yet. Use the form above to create one.") + = _('No triggers exist yet. Use the form above to create one.') .card-footer %p - = s_("These examples show how to trigger this project's pipeline for a branch or tag.") + = _("These examples show how to trigger this project's pipeline for a branch or tag.") %p.light - = s_("Triggers|In each example, replace %{code_start}TOKEN%{code_end} with the trigger token you generated and replace %{code_start}REF_NAME%{code_end} with the branch or tag name.").html_safe % { code_start: "".html_safe, code_end: "".html_safe } + = _('In each example, replace %{code_start}TOKEN%{code_end} with the trigger token you generated and replace %{code_start}REF_NAME%{code_end} with the branch or tag name.').html_safe % { code_start: ''.html_safe, code_end: ''.html_safe } %h5.gl-mt-3 - = s_("Use cURL") + = _('Use cURL') %pre :plain @@ -49,26 +49,26 @@ -F ref=REF_NAME \ #{builds_trigger_url(@project.id)} %h5.gl-mt-3 - = s_("Use .gitlab-ci.yml") + = _('Use .gitlab-ci.yml') %pre :plain script: - "curl -X POST -F token=TOKEN -F ref=REF_NAME #{builds_trigger_url(@project.id)}" %h5.gl-mt-3 - = s_("Use webhook") + = _('Use webhook') %pre :plain #{builds_trigger_url(@project.id, ref: 'REF_NAME')}?token=TOKEN %h5.gl-mt-3 - = s_("Pass job variables") + = _('Pass job variables') %p.light - = s_("Triggers|To pass variables to the triggered pipeline, add %{code_start}variables[VARIABLE]=VALUE%{code_end} to the API request.").html_safe % { code_start: "".html_safe, code_end: "".html_safe } + = _('To pass variables to the triggered pipeline, add %{code_start}variables[VARIABLE]=VALUE%{code_end} to the API request.').html_safe % { code_start: ''.html_safe, code_end: ''.html_safe } %p.light - = s_("cURL:") + = _('cURL:') %pre :plain @@ -78,7 +78,7 @@ -F "variables[RUN_NIGHTLY_BUILD]=true" \ #{builds_trigger_url(@project.id)} %p.light - = s_("Webhook:") + = _('Webhook:') %pre.gl-mb-0 :plain diff --git a/changelogs/unreleased/202423-remove-records-without-group-from-webhooks.yml b/changelogs/unreleased/202423-remove-records-without-group-from-webhooks.yml new file mode 100644 index 00000000000..dff08ca6494 --- /dev/null +++ b/changelogs/unreleased/202423-remove-records-without-group-from-webhooks.yml @@ -0,0 +1,5 @@ +--- +title: Remove records without group from webhooks table +merge_request: 57863 +author: +type: other diff --git a/changelogs/unreleased/324796-update-deprecated-glicon-size-and-remove-use-deprecated-sizes.yml b/changelogs/unreleased/324796-update-deprecated-glicon-size-and-remove-use-deprecated-sizes.yml new file mode 100644 index 00000000000..c46328b6fe7 --- /dev/null +++ b/changelogs/unreleased/324796-update-deprecated-glicon-size-and-remove-use-deprecated-sizes.yml @@ -0,0 +1,5 @@ +--- +title: Update GlIcon size in environments.vue +merge_request: 58208 +author: Md. Pial Ahamed (@root.pial) +type: changed diff --git a/changelogs/unreleased/Externalise-strings-in-_registry-html-haml.yml b/changelogs/unreleased/Externalise-strings-in-_registry-html-haml.yml new file mode 100644 index 00000000000..eff8004de31 --- /dev/null +++ b/changelogs/unreleased/Externalise-strings-in-_registry-html-haml.yml @@ -0,0 +1,5 @@ +--- +title: Externalise strings in _registry.html.haml +merge_request: 58051 +author: nuwe1 +type: other diff --git a/changelogs/unreleased/Externalise-strings-in-chat_names-_chat_name-html-haml.yml b/changelogs/unreleased/Externalise-strings-in-chat_names-_chat_name-html-haml.yml new file mode 100644 index 00000000000..6c75f17563d --- /dev/null +++ b/changelogs/unreleased/Externalise-strings-in-chat_names-_chat_name-html-haml.yml @@ -0,0 +1,5 @@ +--- +title: Externalize strings in chat_names/_chat_name.html.haml +merge_request: 58444 +author: nuwe1 +type: other diff --git a/changelogs/unreleased/Externalize-strings-in-ssessions_new_ldap-html-haml.yml b/changelogs/unreleased/Externalize-strings-in-ssessions_new_ldap-html-haml.yml new file mode 100644 index 00000000000..89bd340d9f1 --- /dev/null +++ b/changelogs/unreleased/Externalize-strings-in-ssessions_new_ldap-html-haml.yml @@ -0,0 +1,5 @@ +--- +title: Externalize strings in sessions/_new_ldap.html.haml +merge_request: 58267 +author: nuwe1 +type: other diff --git a/changelogs/unreleased/fix-commit-status-with-child-pipeline.yml b/changelogs/unreleased/fix-commit-status-with-child-pipeline.yml new file mode 100644 index 00000000000..eacbcd8bc0f --- /dev/null +++ b/changelogs/unreleased/fix-commit-status-with-child-pipeline.yml @@ -0,0 +1,5 @@ +--- +title: Filter out pipelines that were excluded in the relation scope in Ci::Pipeline#latest_pipeline_per_commit +merge_request: 55657 +author: Cong Chen @gentcys +type: fixed diff --git a/changelogs/unreleased/fix-gb-avoid-inflating-memory-when-aborting-pipelines.yml b/changelogs/unreleased/fix-gb-avoid-inflating-memory-when-aborting-pipelines.yml new file mode 100644 index 00000000000..ab723b380c6 --- /dev/null +++ b/changelogs/unreleased/fix-gb-avoid-inflating-memory-when-aborting-pipelines.yml @@ -0,0 +1,5 @@ +--- +title: Avoid inflating Redis memory when aborting pipelines +merge_request: 59018 +author: +type: fixed diff --git a/changelogs/unreleased/id-bump-devise-two-factor.yml b/changelogs/unreleased/id-bump-devise-two-factor.yml new file mode 100644 index 00000000000..6a75991aaa4 --- /dev/null +++ b/changelogs/unreleased/id-bump-devise-two-factor.yml @@ -0,0 +1,5 @@ +--- +title: Bump devise-two-factor version +merge_request: 58929 +author: +type: other diff --git a/changelogs/unreleased/issue-325836-fix-empty-line-after-let-it-be-api-helpers.yml b/changelogs/unreleased/issue-325836-fix-empty-line-after-let-it-be-api-helpers.yml new file mode 100644 index 00000000000..68566e26cc8 --- /dev/null +++ b/changelogs/unreleased/issue-325836-fix-empty-line-after-let-it-be-api-helpers.yml @@ -0,0 +1,5 @@ +--- +title: Fix EmptyLineAfterFinalLetItBe Rubocop offenses for api helpers +merge_request: 58194 +author: Huzaifa Iftikhar @huzaifaiftikhar +type: fixed diff --git a/changelogs/unreleased/issue-325836-fix-empty-line-after-let-it-be-gitlab-github-import.yml b/changelogs/unreleased/issue-325836-fix-empty-line-after-let-it-be-gitlab-github-import.yml new file mode 100644 index 00000000000..fb0ece8309f --- /dev/null +++ b/changelogs/unreleased/issue-325836-fix-empty-line-after-let-it-be-gitlab-github-import.yml @@ -0,0 +1,5 @@ +--- +title: Fix EmptyLineAfterFinalLetItBe offenses spec/lib/gitlab/github_import +merge_request: 58256 +author: Huzaifa Iftikhar @huzaifaiftikhar +type: fixed diff --git a/changelogs/unreleased/issue-325836-fix-empty-line-after-let-it-be-gitlab-imoport-export.yml b/changelogs/unreleased/issue-325836-fix-empty-line-after-let-it-be-gitlab-imoport-export.yml new file mode 100644 index 00000000000..fde96539c7b --- /dev/null +++ b/changelogs/unreleased/issue-325836-fix-empty-line-after-let-it-be-gitlab-imoport-export.yml @@ -0,0 +1,5 @@ +--- +title: Fix EmptyLineAfterFinalLetItBe offenses spec/lib/gitlab/import_export +merge_request: 58264 +author: Huzaifa Iftikhar @huzaifaiftikhar +type: fixed diff --git a/changelogs/unreleased/jonstonchan-fix-triggers-externalization.yml b/changelogs/unreleased/jonstonchan-fix-triggers-externalization.yml new file mode 100644 index 00000000000..56f6127478b --- /dev/null +++ b/changelogs/unreleased/jonstonchan-fix-triggers-externalization.yml @@ -0,0 +1,5 @@ +--- +title: Fix triggers page externalization +merge_request: 57637 +author: Jonston Chan @JonstonChan +type: other diff --git a/changelogs/unreleased/optimize-query-for-cherry-picked-merge-requests.yml b/changelogs/unreleased/optimize-query-for-cherry-picked-merge-requests.yml new file mode 100644 index 00000000000..a9921a886f6 --- /dev/null +++ b/changelogs/unreleased/optimize-query-for-cherry-picked-merge-requests.yml @@ -0,0 +1,5 @@ +--- +title: Optimize query for cherry picked merge requests +merge_request: 58967 +author: +type: performance diff --git a/changelogs/unreleased/psi-dark-build.yml b/changelogs/unreleased/psi-dark-build.yml new file mode 100644 index 00000000000..aece4a82cd8 --- /dev/null +++ b/changelogs/unreleased/psi-dark-build.yml @@ -0,0 +1,5 @@ +--- +title: Fix dark mode colors of retried jobs in job details page +merge_request: 58855 +author: +type: fixed diff --git a/changelogs/unreleased/psi-dark-navbar.yml b/changelogs/unreleased/psi-dark-navbar.yml new file mode 100644 index 00000000000..e20a9d0b818 --- /dev/null +++ b/changelogs/unreleased/psi-dark-navbar.yml @@ -0,0 +1,5 @@ +--- +title: Dark mode nav improvements +merge_request: 58891 +author: +type: fixed diff --git a/changelogs/unreleased/psi-dark-select2.yml b/changelogs/unreleased/psi-dark-select2.yml new file mode 100644 index 00000000000..90f9dc7edbe --- /dev/null +++ b/changelogs/unreleased/psi-dark-select2.yml @@ -0,0 +1,5 @@ +--- +title: Fix select2 dropdowns in dark mode +merge_request: 58862 +author: +type: fixed diff --git a/config/feature_flags/development/async_add_build_failure_todo.yml b/config/feature_flags/development/async_add_build_failure_todo.yml index 6bb1a84ed82..3c1e056a50e 100644 --- a/config/feature_flags/development/async_add_build_failure_todo.yml +++ b/config/feature_flags/development/async_add_build_failure_todo.yml @@ -5,4 +5,4 @@ rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/326726 milestone: '13.11' type: development group: group::continuous integration -default_enabled: false +default_enabled: true diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example index c451ce6b872..da1a15302da 100644 --- a/config/gitlab.yml.example +++ b/config/gitlab.yml.example @@ -6,7 +6,7 @@ # This file should not receive new settings. All configuration options # # * are being moved to ApplicationSetting model! # # If a setting requires an application restart say so in that screen. # -# If you change this file in a Merge Request, please also create # +# If you change this file in a merge request, please also create # # a MR on https://gitlab.com/gitlab-org/omnibus-gitlab/merge_requests. # # For more details see https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/settings/gitlab.yml.md # ######################################################################## diff --git a/config/initializers/smtp_settings.rb.sample b/config/initializers/smtp_settings.rb.sample index bd37080b1c8..babc0a81938 100644 --- a/config/initializers/smtp_settings.rb.sample +++ b/config/initializers/smtp_settings.rb.sample @@ -5,7 +5,7 @@ # # For full list of options and their values see http://api.rubyonrails.org/classes/ActionMailer/Base.html # -# If you change this file in a Merge Request, please also create a Merge Request on https://gitlab.com/gitlab-org/omnibus-gitlab/merge_requests +# If you change this file in a merge request, please also create a merge request on https://gitlab.com/gitlab-org/omnibus-gitlab/merge_requests if Rails.env.production? Rails.application.config.action_mailer.delivery_method = :smtp diff --git a/config/metrics/counts_all/20210216180246_web_ide_merge_requests.yml b/config/metrics/counts_all/20210216180246_web_ide_merge_requests.yml index 2df821ee8ad..d8ab29b3ef5 100644 --- a/config/metrics/counts_all/20210216180246_web_ide_merge_requests.yml +++ b/config/metrics/counts_all/20210216180246_web_ide_merge_requests.yml @@ -1,6 +1,6 @@ --- key_path: counts.web_ide_merge_requests -description: Count of Merge Requests created from Web IDE +description: Count of merge requests created from Web IDE product_section: dev product_stage: create product_group: group::editor diff --git a/config/redis.cache.yml.example b/config/redis.cache.yml.example index fb92c205ce1..44d9f7e8632 100644 --- a/config/redis.cache.yml.example +++ b/config/redis.cache.yml.example @@ -1,5 +1,5 @@ -# If you change this file in a Merge Request, please also create -# a Merge Request on https://gitlab.com/gitlab-org/omnibus-gitlab/merge_requests +# If you change this file in a merge request, please also create +# a merge request on https://gitlab.com/gitlab-org/omnibus-gitlab/merge_requests # development: url: redis://localhost:6379/10 diff --git a/config/redis.queues.yml.example b/config/redis.queues.yml.example index dd6c10e0e06..4194b44cb88 100644 --- a/config/redis.queues.yml.example +++ b/config/redis.queues.yml.example @@ -1,5 +1,5 @@ -# If you change this file in a Merge Request, please also create -# a Merge Request on https://gitlab.com/gitlab-org/omnibus-gitlab/merge_requests +# If you change this file in a merge request, please also create +# a merge request on https://gitlab.com/gitlab-org/omnibus-gitlab/merge_requests # development: url: redis://localhost:6379/11 diff --git a/config/redis.shared_state.yml.example b/config/redis.shared_state.yml.example index 98f6f330bc7..b3e0c7a8fa9 100644 --- a/config/redis.shared_state.yml.example +++ b/config/redis.shared_state.yml.example @@ -1,5 +1,5 @@ -# If you change this file in a Merge Request, please also create -# a Merge Request on https://gitlab.com/gitlab-org/omnibus-gitlab/merge_requests +# If you change this file in a merge request, please also create +# a merge request on https://gitlab.com/gitlab-org/omnibus-gitlab/merge_requests # development: url: redis://localhost:6379/12 diff --git a/config/resque.yml.example b/config/resque.yml.example index 0f629a5229c..656cd57a739 100644 --- a/config/resque.yml.example +++ b/config/resque.yml.example @@ -1,5 +1,5 @@ -# If you change this file in a Merge Request, please also create -# a Merge Request on https://gitlab.com/gitlab-org/omnibus-gitlab/merge_requests +# If you change this file in a merge request, please also create +# a merge request on https://gitlab.com/gitlab-org/omnibus-gitlab/merge_requests # development: url: redis://localhost:6379 diff --git a/config/unicorn.rb.example b/config/unicorn.rb.example index 0e475249868..c930e2ff761 100644 --- a/config/unicorn.rb.example +++ b/config/unicorn.rb.example @@ -8,8 +8,8 @@ # See http://unicorn.bogomips.org/Unicorn/Configurator.html for complete # documentation. -# Note: If you change this file in a Merge Request, please also create a -# Merge Request on https://gitlab.com/gitlab-org/omnibus-gitlab/merge_requests +# Note: If you change this file in a merge request, please also create a +# merge request on https://gitlab.com/gitlab-org/omnibus-gitlab/merge_requests # Relative URL support # WARNING: We recommend using an FQDN to host GitLab in a root path instead diff --git a/db/migrate/20210409084242_create_index_on_notes_for_cherry_picked_merge_requests.rb b/db/migrate/20210409084242_create_index_on_notes_for_cherry_picked_merge_requests.rb new file mode 100644 index 00000000000..2bcdf4c8982 --- /dev/null +++ b/db/migrate/20210409084242_create_index_on_notes_for_cherry_picked_merge_requests.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class CreateIndexOnNotesForCherryPickedMergeRequests < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + NAME = 'index_notes_for_cherry_picked_merge_requests' + + disable_ddl_transaction! + + def up + add_concurrent_index :notes, [:project_id, :commit_id], where: "((noteable_type)::text = 'MergeRequest'::text)", name: NAME + end + + def down + remove_concurrent_index_by_name :notes, name: NAME + end +end diff --git a/db/post_migrate/20210330091751_remove_records_without_group_from_webhooks_table.rb b/db/post_migrate/20210330091751_remove_records_without_group_from_webhooks_table.rb new file mode 100644 index 00000000000..c384aa25ac4 --- /dev/null +++ b/db/post_migrate/20210330091751_remove_records_without_group_from_webhooks_table.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +class RemoveRecordsWithoutGroupFromWebhooksTable < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + class WebHook < ActiveRecord::Base + include EachBatch + + self.table_name = 'web_hooks' + end + + class Group < ActiveRecord::Base + self.inheritance_column = :_type_disabled + self.table_name = 'namespaces' + end + + def up + subquery = Group.select(1).where(Group.arel_table[:id].eq(WebHook.arel_table[:group_id])) + + WebHook.each_batch(of: 500, column: :id) do |relation| + relation.where(type: 'GroupHook').where.not('EXISTS (?)', subquery).delete_all + end + end + + def down + # no-op + end +end diff --git a/db/schema_migrations/20210330091751 b/db/schema_migrations/20210330091751 new file mode 100644 index 00000000000..0536252e980 --- /dev/null +++ b/db/schema_migrations/20210330091751 @@ -0,0 +1 @@ +3a195b9671846409cf6665b13caad9713541d9cdd95c9f246c22b7db225ab02c \ No newline at end of file diff --git a/db/schema_migrations/20210409084242 b/db/schema_migrations/20210409084242 new file mode 100644 index 00000000000..2d932018355 --- /dev/null +++ b/db/schema_migrations/20210409084242 @@ -0,0 +1 @@ +6bd35117ca922fc0d9cb8cbd9b0e6d5d9216457182d5679e705c1f03eef05921 \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index a553b47ff84..94779cafdc3 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -23207,6 +23207,8 @@ CREATE INDEX index_non_requested_project_members_on_source_id_and_type ON member CREATE UNIQUE INDEX index_note_diff_files_on_diff_note_id ON note_diff_files USING btree (diff_note_id); +CREATE INDEX index_notes_for_cherry_picked_merge_requests ON notes USING btree (project_id, commit_id) WHERE ((noteable_type)::text = 'MergeRequest'::text); + CREATE INDEX index_notes_on_author_id_and_created_at_and_id ON notes USING btree (author_id, created_at, id); CREATE INDEX index_notes_on_commit_id ON notes USING btree (commit_id); diff --git a/doc/api/jobs.md b/doc/api/jobs.md index fbcdc3f106c..a19dbecb430 100644 --- a/doc/api/jobs.md +++ b/doc/api/jobs.md @@ -295,7 +295,8 @@ In GitLab 13.3 and later, this endpoint [returns data for any pipeline](pipeline including [child pipelines](../ci/parent_child_pipelines.md). In GitLab 13.5 and later, this endpoint does not return retried jobs in the response -by default. +by default. Additionally, jobs are sorted by ID in ascending order (oldest first). +In earlier GitLab versions, jobs are sorted by ID in descending order (newest first). In GitLab 13.9 and later, this endpoint can include retried jobs in the response with `include_retried` set to `true`. diff --git a/doc/ci/yaml/README.md b/doc/ci/yaml/README.md index 4873385d808..17f52cea50b 100644 --- a/doc/ci/yaml/README.md +++ b/doc/ci/yaml/README.md @@ -250,8 +250,41 @@ workflow: - if: $CI_COMMIT_REF_NAME =~ /feature/ variables: IS_A_FEATURE: "true" # Define a new variable. + - when: always # Run the pipeline in other cases + +job1: + variables: + DEPLOY_VARIABLE: "job1-default-deploy" + rules: + - if: $CI_COMMIT_REF_NAME =~ /master/ + variables: # Override DEPLOY_VARIABLE defined + DEPLOY_VARIABLE: "job1-deploy-production" # at the job level. + - when: on_success # Run the job in other cases + script: + - echo "Run script with $DEPLOY_VARIABLE as an argument" + - echo "Run another script if $IS_A_FEATURE exists" + +job2: + script: + - echo "Run script with $DEPLOY_VARIABLE as an argument" + - echo "Run another script if $IS_A_FEATURE exists" ``` +When the branch is `master`: + +- job1's `DEPLOY_VARIABLE` is `job1-deploy-production`. +- job2's `DEPLOY_VARIABLE` is `deploy-production`. + +When the branch is `feature`: + +- job1's `DEPLOY_VARIABLE` is `job1-default-deploy`, and `IS_A_FEATURE` is `true`. +- job2's `DEPLOY_VARIABLE` is `default-deploy`, and `IS_A_FEATURE` is `true`. + +When the branch is something else: + +- job1's `DEPLOY_VARIABLE` is `job1-default-deploy`. +- job2's `DEPLOY_VARIABLE` is `default-deploy`. + ##### Enable or disable workflow:rules:variables **(CORE ONLY)** rules:variables is under development and not ready for production use. diff --git a/doc/development/merge_request_performance_guidelines.md b/doc/development/merge_request_performance_guidelines.md index 772ce1d6b59..0f696d39092 100644 --- a/doc/development/merge_request_performance_guidelines.md +++ b/doc/development/merge_request_performance_guidelines.md @@ -158,6 +158,27 @@ objects_to_update.update_all(some_field: some_value) This uses ActiveRecord's `update_all` method to update all rows in a single query. This in turn makes it much harder for this code to overload a database. +## Use read replicas when possible + +In a DB cluster we have many read replicas and one primary. A classic use of scaling the DB is to have read-only actions be performed by the replicas. We use [load balancing](../administration/database_load_balancing.md) to distribute this load. This allows for the replicas to grow as the pressure on the DB grows. + +By default, queries use read-only replicas, but due to [primary sticking](../administration/database_load_balancing.md#primary-sticking), GitLab sticks to using the primary for a certain period of time and reverts back to secondaries after they have either caught up or after 30 seconds, which can lead to a considerable amount of unnecessary load on the primary. In this [merge request](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/56849) we introduced the `without_sticky_writes` block to prevent switching to the primary. This [merge request example](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/57328) provides a good use case for when queries can stick to the primary and how to prevent this by using `without_sticky_writes`. + +Internally, our database load balancer classifies the queries based on their main statement (`select`, `update`, `delete`, etc.). When in doubt, it redirects the queries to the primary database. Hence, there are some common cases the load balancer sends the queries to the primary unnecessarily: + +- Custom queries (via `exec_query`, `execute_statement`, `execute`, etc.) +- Read-only transactions +- In-flight connection configuration set +- Sidekiq background jobs + +Worse, after the above queries are executed, GitLab [sticks to the primary](../administration/database_load_balancing.md#primary-sticking). In [this merge request](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/56476), we introduced `use_replica_if_possible` to make the inside queries prefer to use the replicas. That MR is also an example how we redirected a costly, time-consuming query to the replicas. + +## Use CTEs wisely + +Read about [complex queries on the relation object](iterating_tables_in_batches.md#complex-queries-on-the-relation-object) for considerations on how to use CTEs. We have found in some situations that CTEs can become problematic in use (similar to the n+1 problem above). In particular, hierarchical recursive CTE queries such as the CTE in [AuthorizedProjectsWorker](https://gitlab.com/gitlab-org/gitlab/-/issues/325688) are very difficult to optimize and don't scale. We should avoid them when implementing new features that require any kind of hierarchical structure. + +However, in many simpler cases, such as this [example](https://gitlab.com/gitlab-org/gitlab-foss/-/issues/43242#note_61416277), CTEs can be quite effective as an optimization fence. + ## Cached Queries **Summary:** a merge request **should not** execute duplicated cached queries. diff --git a/doc/development/usage_ping/dictionary.md b/doc/development/usage_ping/dictionary.md index 67466a607cf..4709c18fcbe 100644 --- a/doc/development/usage_ping/dictionary.md +++ b/doc/development/usage_ping/dictionary.md @@ -5986,7 +5986,7 @@ Tiers: `free`, `premium`, `ultimate` ### `counts.web_ide_merge_requests` -Count of Merge Requests created from Web IDE +Count of merge requests created from Web IDE [YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_all/20210216180246_web_ide_merge_requests.yml) diff --git a/doc/user/project/settings/import_export.md b/doc/user/project/settings/import_export.md index 7b5a0cbb377..6fa1b0aa368 100644 --- a/doc/user/project/settings/import_export.md +++ b/doc/user/project/settings/import_export.md @@ -39,8 +39,8 @@ Note the following: The Importing GitLab version must be greater than or equal to the Exporting GitLab version. - Imports will fail unless the import and export GitLab instances are compatible as described in the [Version history](#version-history). -- Exports are stored in a temporary [shared directory](../../../development/shared_files.md) - and are deleted every 24 hours by a specific worker. +- Exports are generated in your configured `shared_path`, a temporary [shared directory](../../../development/shared_files.md) + and are moved to your configured `uploads_directory`. Every 24 hours, a specific worker deletes these export files. - Group members are exported as project members, as long as the user has maintainer or administrator access to the group where the exported project lives. - Project members with owner access will be imported as maintainers. diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 2c173ea73a8..aa62ceb14f8 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -2019,6 +2019,9 @@ msgstr "" msgid "Add to tree" msgstr "" +msgid "Add trigger" +msgstr "" + msgid "Add user(s) to the group:" msgstr "" @@ -4480,6 +4483,9 @@ msgstr "" msgid "Authorization required" msgstr "" +msgid "Authorization token duration (minutes)" +msgstr "" + msgid "Authorization was granted by entering your username and password in the application." msgstr "" @@ -16152,6 +16158,9 @@ msgstr "" msgid "In case of pull mirroring, your user will be the author of all events in the activity feed that are the result of an update, like new branches being created or new commits being pushed to existing branches." msgstr "" +msgid "In each example, replace %{code_start}TOKEN%{code_end} with the trigger token you generated and replace %{code_start}REF_NAME%{code_end} with the branch or tag name." +msgstr "" + msgid "In progress" msgstr "" @@ -18424,10 +18433,7 @@ msgstr "" msgid "LearnGitLab|Route code reviews to the right reviewers, every time." msgstr "" -msgid "LearnGitLab|Run a Security scan" -msgstr "" - -msgid "LearnGitLab|Run a security scan" +msgid "LearnGitLab|Run a Security scan using CI/CD" msgstr "" msgid "LearnGitLab|Save time by automating your integration and deployment tasks." @@ -18463,6 +18469,9 @@ msgstr "" msgid "LearnGitLab|Use your new GitLab workflow to deploy your application, monitor its health, and keep it secure:" msgstr "" +msgid "LearnGitlab|Trial only" +msgstr "" + msgid "Leave" msgstr "" @@ -32381,6 +32390,9 @@ msgstr "" msgid "To open Jaeger from GitLab to view tracing from the %{link} page, add a URL to your Jaeger server." msgstr "" +msgid "To pass variables to the triggered pipeline, add %{code_start}variables[VARIABLE]=VALUE%{code_end} to the API request." +msgstr "" + msgid "To personalize your GitLab experience, we'd like to know a bit more about you. We won't share this information with anyone." msgstr "" @@ -32767,12 +32779,6 @@ msgstr "" msgid "Triggerer" msgstr "" -msgid "Triggers|In each example, replace %{code_start}TOKEN%{code_end} with the trigger token you generated and replace %{code_start}REF_NAME%{code_end} with the branch or tag name." -msgstr "" - -msgid "Triggers|To pass variables to the triggered pipeline, add %{code_start}variables[VARIABLE]=VALUE%{code_end} to the API request." -msgstr "" - msgid "Troubleshoot and monitor your application with tracing" msgstr "" diff --git a/spec/frontend/issuable_show/mock_data.js b/spec/frontend/issuable_show/mock_data.js index 9ecff705617..986d32b4982 100644 --- a/spec/frontend/issuable_show/mock_data.js +++ b/spec/frontend/issuable_show/mock_data.js @@ -32,6 +32,7 @@ export const mockIssuableShowProps = { editFormVisible: false, enableAutocomplete: true, enableAutosave: true, + enableZenMode: true, enableTaskList: true, enableEdit: true, showFieldTitle: false, diff --git a/spec/frontend/pages/projects/learn_gitlab/components/__snapshots__/learn_gitlab_a_spec.js.snap b/spec/frontend/pages/projects/learn_gitlab/components/__snapshots__/learn_gitlab_a_spec.js.snap index 1c1327e7a4e..cecaa3fc365 100644 --- a/spec/frontend/pages/projects/learn_gitlab/components/__snapshots__/learn_gitlab_a_spec.js.snap +++ b/spec/frontend/pages/projects/learn_gitlab/components/__snapshots__/learn_gitlab_a_spec.js.snap @@ -1,70 +1,308 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Learn GitLab Design A should render the loading state 1`] = ` - + + +
+
+ + +

+ Deploy +

+ +

+ Use your new GitLab workflow to deploy your application, monitor its health, and keep it secure: +

+
+ +
+ + + Run a Security scan using CI/CD + + + + +
+
+ + + + + + `; diff --git a/spec/frontend/pages/projects/learn_gitlab/components/__snapshots__/learn_gitlab_b_spec.js.snap b/spec/frontend/pages/projects/learn_gitlab/components/__snapshots__/learn_gitlab_b_spec.js.snap index dd899b93302..a78544fb14c 100644 --- a/spec/frontend/pages/projects/learn_gitlab/components/__snapshots__/learn_gitlab_b_spec.js.snap +++ b/spec/frontend/pages/projects/learn_gitlab/components/__snapshots__/learn_gitlab_b_spec.js.snap @@ -491,7 +491,7 @@ exports[`Learn GitLab Design B renders correctly 1`] = ` />
- Run a security scan + Run a Security scan using CI/CD

- Run a Security scan + Run a Security scan using CI/CD diff --git a/spec/frontend/pages/projects/learn_gitlab/components/__snapshots__/learn_gitlab_section_card_spec.js.snap b/spec/frontend/pages/projects/learn_gitlab/components/__snapshots__/learn_gitlab_section_card_spec.js.snap new file mode 100644 index 00000000000..831c027cd66 --- /dev/null +++ b/spec/frontend/pages/projects/learn_gitlab/components/__snapshots__/learn_gitlab_section_card_spec.js.snap @@ -0,0 +1,63 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Learn GitLab Section Card renders correctly 1`] = ` + +

+ + +

+ Set up your workspace +

+ +

+ Complete these tasks first so you can enjoy GitLab's features to their fullest: +

+
+ + + + + + + + + + +`; diff --git a/spec/frontend/pages/projects/learn_gitlab/components/learn_gitlab_a_spec.js b/spec/frontend/pages/projects/learn_gitlab/components/learn_gitlab_a_spec.js index 2154358de51..b226c046627 100644 --- a/spec/frontend/pages/projects/learn_gitlab/components/learn_gitlab_a_spec.js +++ b/spec/frontend/pages/projects/learn_gitlab/components/learn_gitlab_a_spec.js @@ -1,22 +1,38 @@ -import { shallowMount } from '@vue/test-utils'; +import { GlProgressBar } from '@gitlab/ui'; +import { mount } from '@vue/test-utils'; import LearnGitlabA from '~/pages/projects/learn_gitlab/components/learn_gitlab_a.vue'; import { testActions } from './mock_data'; describe('Learn GitLab Design A', () => { let wrapper; + const createWrapper = () => { + wrapper = mount(LearnGitlabA, { propsData: { actions: testActions } }); + }; + + beforeEach(() => { + createWrapper(); + }); + afterEach(() => { wrapper.destroy(); wrapper = null; }); - const createWrapper = () => { - wrapper = shallowMount(LearnGitlabA, { propsData: { actions: testActions } }); - }; - - it('should render the loading state', () => { - createWrapper(); - + it('renders correctly', () => { expect(wrapper.element).toMatchSnapshot(); }); + + it('renders the progress percentage', () => { + const text = wrapper.find('[data-testid="completion-percentage"]').text(); + + expect(text).toEqual('25% completed'); + }); + + it('renders the progress bar with correct values', () => { + const progressBar = wrapper.find(GlProgressBar); + + expect(progressBar.attributes('value')).toBe('2'); + expect(progressBar.attributes('max')).toBe('8'); + }); }); diff --git a/spec/frontend/pages/projects/learn_gitlab/components/learn_gitlab_section_card_spec.js b/spec/frontend/pages/projects/learn_gitlab/components/learn_gitlab_section_card_spec.js new file mode 100644 index 00000000000..de6aca08235 --- /dev/null +++ b/spec/frontend/pages/projects/learn_gitlab/components/learn_gitlab_section_card_spec.js @@ -0,0 +1,26 @@ +import { shallowMount } from '@vue/test-utils'; +import LearnGitlabSectionCard from '~/pages/projects/learn_gitlab/components/learn_gitlab_section_card.vue'; +import { testActions } from './mock_data'; + +const defaultSection = 'workspace'; + +describe('Learn GitLab Section Card', () => { + let wrapper; + + afterEach(() => { + wrapper.destroy(); + wrapper = null; + }); + + const createWrapper = () => { + wrapper = shallowMount(LearnGitlabSectionCard, { + propsData: { section: defaultSection, actions: testActions }, + }); + }; + + it('renders correctly', () => { + createWrapper({ completed: false }); + + expect(wrapper.element).toMatchSnapshot(); + }); +}); diff --git a/spec/frontend/pages/projects/learn_gitlab/components/learn_gitlab_section_link_spec.js b/spec/frontend/pages/projects/learn_gitlab/components/learn_gitlab_section_link_spec.js new file mode 100644 index 00000000000..882d233a239 --- /dev/null +++ b/spec/frontend/pages/projects/learn_gitlab/components/learn_gitlab_section_link_spec.js @@ -0,0 +1,49 @@ +import { shallowMount } from '@vue/test-utils'; +import LearnGitlabSectionLink from '~/pages/projects/learn_gitlab/components/learn_gitlab_section_link.vue'; + +const defaultAction = 'gitWrite'; +const defaultProps = { + title: 'Create Repository', + description: 'Some description', + url: 'https://example.com', + completed: false, +}; + +describe('Learn GitLab Section Link', () => { + let wrapper; + + afterEach(() => { + wrapper.destroy(); + wrapper = null; + }); + + const createWrapper = (action = defaultAction, props = {}) => { + wrapper = shallowMount(LearnGitlabSectionLink, { + propsData: { action, value: { ...defaultProps, ...props } }, + }); + }; + + it('renders no icon when not completed', () => { + createWrapper(undefined, { completed: false }); + + expect(wrapper.find('[data-testid="completed-icon"]').exists()).toBe(false); + }); + + it('renders the completion icon when completed', () => { + createWrapper(undefined, { completed: true }); + + expect(wrapper.find('[data-testid="completed-icon"]').exists()).toBe(true); + }); + + it('renders no trial only when it is not required', () => { + createWrapper(); + + expect(wrapper.find('[data-testid="trial-only"]').exists()).toBe(false); + }); + + it('renders trial only when trial is required', () => { + createWrapper('codeOwnersEnabled'); + + expect(wrapper.find('[data-testid="trial-only"]').exists()).toBe(true); + }); +}); diff --git a/spec/helpers/ci/pipeline_editor_helper_spec.rb b/spec/helpers/ci/pipeline_editor_helper_spec.rb index 7686983eb0f..a08517d0c57 100644 --- a/spec/helpers/ci/pipeline_editor_helper_spec.rb +++ b/spec/helpers/ci/pipeline_editor_helper_spec.rb @@ -20,4 +20,36 @@ RSpec.describe Ci::PipelineEditorHelper do expect(subject).to be false end end + + describe '#js_pipeline_editor_data' do + let(:project) { create(:project, :repository) } + + before do + allow(helper) + .to receive(:namespace_project_new_merge_request_path) + .and_return('/mock/project/-/merge_requests/new') + + allow(helper) + .to receive(:image_path) + .and_return('foo') + end + + subject(:pipeline_editor_data) { helper.js_pipeline_editor_data(project) } + + it 'returns pipeline editor data' do + expect(pipeline_editor_data).to eq({ + "ci-config-path": project.ci_config_path_or_default, + "commit-sha" => project.commit.sha, + "default-branch" => project.default_branch, + "empty-state-illustration-path" => 'foo', + "initial-branch-name": nil, + "lint-help-page-path" => help_page_path('ci/lint', anchor: 'validate-basic-logic-and-syntax'), + "new-merge-request-path" => '/mock/project/-/merge_requests/new', + "project-path" => project.path, + "project-full-path" => project.full_path, + "project-namespace" => project.namespace.full_path, + "yml-help-page-path" => help_page_path('ci/yaml/README') + }) + end + end end diff --git a/spec/helpers/projects/ci/pipeline_editor_helper_spec.rb b/spec/helpers/projects/ci/pipeline_editor_helper_spec.rb new file mode 100644 index 00000000000..882b6548d64 --- /dev/null +++ b/spec/helpers/projects/ci/pipeline_editor_helper_spec.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe ::Ci::PipelineEditorHelper do + let_it_be(:project) { create(:project, :public, :repository) } + + describe '#js_pipeline_editor_data' do + before do + allow(helper).to receive(:namespace_project_new_merge_request_path).and_return('/mock/project/-/merge_requests/new') + end + + subject { helper.js_pipeline_editor_data(project) } + + it { + is_expected.to match({ + "ci-config-path": project.ci_config_path_or_default, + "commit-sha" => project.commit.sha, + "default-branch" => project.default_branch, + "empty-state-illustration-path" => match_asset_path("/assets/illustrations/empty-state/empty-dag-md.svg"), + "initial-branch-name": nil, + "lint-help-page-path" => help_page_path('ci/lint', anchor: 'validate-basic-logic-and-syntax'), + "new-merge-request-path" => '/mock/project/-/merge_requests/new', + "project-path" => project.path, + "project-full-path" => project.full_path, + "project-namespace" => project.namespace.full_path, + "yml-help-page-path" => help_page_path('ci/yaml/README') + }) + } + end +end diff --git a/spec/lib/api/helpers/caching_spec.rb b/spec/lib/api/helpers/caching_spec.rb index 271f25b0de9..a8cd061e123 100644 --- a/spec/lib/api/helpers/caching_spec.rb +++ b/spec/lib/api/helpers/caching_spec.rb @@ -8,6 +8,7 @@ RSpec.describe API::Helpers::Caching do describe "#present_cached" do let_it_be(:project) { create(:project) } let_it_be(:user) { create(:user) } + let(:presenter) { API::Entities::Todo } let(:kwargs) do diff --git a/spec/lib/api/helpers/packages_manager_clients_helpers_spec.rb b/spec/lib/api/helpers/packages_manager_clients_helpers_spec.rb index 3c40859da21..e4c5002aa68 100644 --- a/spec/lib/api/helpers/packages_manager_clients_helpers_spec.rb +++ b/spec/lib/api/helpers/packages_manager_clients_helpers_spec.rb @@ -8,6 +8,7 @@ RSpec.describe API::Helpers::PackagesManagerClientsHelpers do let_it_be(:personal_access_token) { create(:personal_access_token) } let_it_be(:username) { personal_access_token.user.username } let_it_be(:helper) { Class.new.include(described_class).new } + let(:password) { personal_access_token.token } let(:env) do @@ -50,6 +51,7 @@ RSpec.describe API::Helpers::PackagesManagerClientsHelpers do describe '#find_job_from_http_basic_auth' do let_it_be(:user) { personal_access_token.user } + let(:job) { create(:ci_build, user: user, status: :running) } let(:password) { job.token } @@ -74,6 +76,7 @@ RSpec.describe API::Helpers::PackagesManagerClientsHelpers do describe '#find_deploy_token_from_http_basic_auth' do let_it_be(:deploy_token) { create(:deploy_token) } + let(:token) { deploy_token.token } let(:username) { deploy_token.username } let(:password) { token } diff --git a/spec/lib/gitlab/github_import/importer/pull_request_merged_by_importer_spec.rb b/spec/lib/gitlab/github_import/importer/pull_request_merged_by_importer_spec.rb index e42b6d89c30..01d9edf0ba1 100644 --- a/spec/lib/gitlab/github_import/importer/pull_request_merged_by_importer_spec.rb +++ b/spec/lib/gitlab/github_import/importer/pull_request_merged_by_importer_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe Gitlab::GithubImport::Importer::PullRequestMergedByImporter, :clean_gitlab_redis_cache do let_it_be(:merge_request) { create(:merged_merge_request) } + let(:project) { merge_request.project } let(:merged_at) { Time.new(2017, 1, 1, 12, 00).utc } let(:client_double) { double(user: double(id: 999, login: 'merger', email: 'merger@email.com')) } diff --git a/spec/lib/gitlab/github_import/importer/pull_request_review_importer_spec.rb b/spec/lib/gitlab/github_import/importer/pull_request_review_importer_spec.rb index 290f3f51202..5002e0384f3 100644 --- a/spec/lib/gitlab/github_import/importer/pull_request_review_importer_spec.rb +++ b/spec/lib/gitlab/github_import/importer/pull_request_review_importer_spec.rb @@ -6,6 +6,7 @@ RSpec.describe Gitlab::GithubImport::Importer::PullRequestReviewImporter, :clean using RSpec::Parameterized::TableSyntax let_it_be(:merge_request) { create(:merge_request) } + let(:project) { merge_request.project } let(:client_double) { double(user: double(id: 999, login: 'author', email: 'author@email.com')) } let(:submitted_at) { Time.new(2017, 1, 1, 12, 00).utc } diff --git a/spec/lib/gitlab/github_import/milestone_finder_spec.rb b/spec/lib/gitlab/github_import/milestone_finder_spec.rb index 5da45b1897f..fe8652eb5a2 100644 --- a/spec/lib/gitlab/github_import/milestone_finder_spec.rb +++ b/spec/lib/gitlab/github_import/milestone_finder_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' RSpec.describe Gitlab::GithubImport::MilestoneFinder, :clean_gitlab_redis_cache do let_it_be(:project) { create(:project) } let_it_be(:milestone) { create(:milestone, project: project) } + let(:finder) { described_class.new(project) } describe '#id_for' do diff --git a/spec/lib/gitlab/import_export/design_repo_saver_spec.rb b/spec/lib/gitlab/import_export/design_repo_saver_spec.rb index 5501e3dee5a..fd3539ab99c 100644 --- a/spec/lib/gitlab/import_export/design_repo_saver_spec.rb +++ b/spec/lib/gitlab/import_export/design_repo_saver_spec.rb @@ -6,6 +6,7 @@ RSpec.describe Gitlab::ImportExport::DesignRepoSaver do describe 'bundle a design Git repo' do let_it_be(:user) { create(:user) } let_it_be(:design) { create(:design, :with_file, versions_count: 1) } + let!(:project) { create(:project, :design_repo) } let(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" } let(:shared) { project.import_export_shared } diff --git a/spec/lib/gitlab/import_export/fast_hash_serializer_spec.rb b/spec/lib/gitlab/import_export/fast_hash_serializer_spec.rb index d084b9d7f7e..29b192de809 100644 --- a/spec/lib/gitlab/import_export/fast_hash_serializer_spec.rb +++ b/spec/lib/gitlab/import_export/fast_hash_serializer_spec.rb @@ -12,6 +12,7 @@ RSpec.describe Gitlab::ImportExport::FastHashSerializer do let_it_be(:user) { create(:user) } let_it_be(:project) { setup_project } + let(:shared) { project.import_export_shared } let(:reader) { Gitlab::ImportExport::Reader.new(shared: shared) } let(:tree) { reader.project_tree } diff --git a/spec/lib/gitlab/import_export/project/export_task_spec.rb b/spec/lib/gitlab/import_export/project/export_task_spec.rb index 1048379a5d6..7fcd2187a90 100644 --- a/spec/lib/gitlab/import_export/project/export_task_spec.rb +++ b/spec/lib/gitlab/import_export/project/export_task_spec.rb @@ -6,6 +6,7 @@ RSpec.describe Gitlab::ImportExport::Project::ExportTask do let_it_be(:username) { 'root' } let(:namespace_path) { username } let_it_be(:user) { create(:user, username: username) } + let(:measurement_enabled) { false } let(:file_path) { 'spec/fixtures/gitlab/import_export/test_project_export.tar.gz' } let(:project) { create(:project, creator: user, namespace: user.namespace) } diff --git a/spec/lib/gitlab/import_export/project/tree_saver_spec.rb b/spec/lib/gitlab/import_export/project/tree_saver_spec.rb index 50494433c5d..fd6c66a10a7 100644 --- a/spec/lib/gitlab/import_export/project/tree_saver_spec.rb +++ b/spec/lib/gitlab/import_export/project/tree_saver_spec.rb @@ -267,6 +267,7 @@ RSpec.describe Gitlab::ImportExport::Project::TreeSaver do describe '#saves project tree' do let_it_be(:user) { create(:user) } let_it_be(:group) { create(:group) } + let(:project) { setup_project } let(:full_path) do if ndjson_enabled diff --git a/spec/lib/gitlab/import_export/repo_saver_spec.rb b/spec/lib/gitlab/import_export/repo_saver_spec.rb index 52001e778d6..73e0e0a08b9 100644 --- a/spec/lib/gitlab/import_export/repo_saver_spec.rb +++ b/spec/lib/gitlab/import_export/repo_saver_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' RSpec.describe Gitlab::ImportExport::RepoSaver do describe 'bundle a project Git repo' do let_it_be(:user) { create(:user) } + let!(:project) { create(:project, :repository) } let(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" } let(:shared) { project.import_export_shared } diff --git a/spec/lib/gitlab/import_export/snippet_repo_saver_spec.rb b/spec/lib/gitlab/import_export/snippet_repo_saver_spec.rb index 323ed9a746e..9f3e8d2fa86 100644 --- a/spec/lib/gitlab/import_export/snippet_repo_saver_spec.rb +++ b/spec/lib/gitlab/import_export/snippet_repo_saver_spec.rb @@ -7,6 +7,7 @@ RSpec.describe Gitlab::ImportExport::SnippetRepoSaver do let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project, namespace: user.namespace) } let_it_be(:snippet) { create(:project_snippet, :repository, project: project, author: user) } + let(:shared) { project.import_export_shared } let(:bundler) { described_class.new(project: project, shared: shared, repository: snippet.repository) } let(:bundle_path) { ::Gitlab::ImportExport.snippets_repo_bundle_path(shared.export_path) } diff --git a/spec/lib/gitlab/import_export/snippets_repo_saver_spec.rb b/spec/lib/gitlab/import_export/snippets_repo_saver_spec.rb index 8507c46ec83..aa284c60e73 100644 --- a/spec/lib/gitlab/import_export/snippets_repo_saver_spec.rb +++ b/spec/lib/gitlab/import_export/snippets_repo_saver_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' RSpec.describe Gitlab::ImportExport::SnippetsRepoSaver do describe 'bundle a project Git repo' do let_it_be(:user) { create(:user) } + let!(:project) { create(:project) } let(:shared) { project.import_export_shared } let(:bundler) { described_class.new(current_user: user, project: project, shared: shared) } diff --git a/spec/lib/gitlab/import_export/wiki_repo_saver_spec.rb b/spec/lib/gitlab/import_export/wiki_repo_saver_spec.rb index 540f90e7804..c936d2bc27d 100644 --- a/spec/lib/gitlab/import_export/wiki_repo_saver_spec.rb +++ b/spec/lib/gitlab/import_export/wiki_repo_saver_spec.rb @@ -6,6 +6,7 @@ RSpec.describe Gitlab::ImportExport::WikiRepoSaver do describe 'bundle a wiki Git repo' do let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project, :wiki_repo) } + let(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" } let(:shared) { project.import_export_shared } let(:wiki_bundler) { described_class.new(exportable: project, shared: shared) } diff --git a/spec/migrations/remove_records_without_group_from_webhooks_table_spec.rb b/spec/migrations/remove_records_without_group_from_webhooks_table_spec.rb new file mode 100644 index 00000000000..a28ca12a10d --- /dev/null +++ b/spec/migrations/remove_records_without_group_from_webhooks_table_spec.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +require 'spec_helper' + +require_migration! +require Rails.root.join('db', 'migrate', '20210325092215_add_not_valid_foreign_key_to_group_hooks.rb') + +RSpec.describe RemoveRecordsWithoutGroupFromWebhooksTable, schema: 20210330091751 do + let(:web_hooks) { table(:web_hooks) } + let(:groups) { table(:namespaces) } + + before do + group = groups.create!(name: 'gitlab', path: 'gitlab-org') + web_hooks.create!(group_id: group.id, type: 'GroupHook') + web_hooks.create!(group_id: nil) + + AddNotValidForeignKeyToGroupHooks.new.down + web_hooks.create!(group_id: non_existing_record_id, type: 'GroupHook') + AddNotValidForeignKeyToGroupHooks.new.up + end + + it 'removes group hooks where the referenced group does not exist', :aggregate_failures do + expect { RemoveRecordsWithoutGroupFromWebhooksTable.new.up }.to change { web_hooks.count }.by(-1) + expect(web_hooks.where.not(group_id: groups.select(:id)).count).to eq(0) + expect(web_hooks.where.not(group_id: nil).count).to eq(1) + end +end diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index 736b2ad4b99..958fe8d9455 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -2282,6 +2282,35 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do ) end end + + context 'when method is scoped' do + let!(:commit_123_ref_master_parent_pipeline) do + create( + :ci_pipeline, + sha: '123', + ref: 'master', + project: project + ) + end + + let!(:commit_123_ref_master_child_pipeline) do + create( + :ci_pipeline, + sha: '123', + ref: 'master', + project: project, + child_of: commit_123_ref_master_parent_pipeline + ) + end + + it 'returns the latest pipeline after applying the scope' do + result = described_class.ci_sources.latest_pipeline_per_commit(%w[123], 'master') + + expect(result).to match( + '123' => commit_123_ref_master_parent_pipeline + ) + end + end end describe '.latest_successful_ids_per_project' do diff --git a/spec/services/ci/abort_pipelines_service_spec.rb b/spec/services/ci/abort_pipelines_service_spec.rb index 21c95606b51..b0f98e1266d 100644 --- a/spec/services/ci/abort_pipelines_service_spec.rb +++ b/spec/services/ci/abort_pipelines_service_spec.rb @@ -45,6 +45,22 @@ RSpec.describe Ci::AbortPipelinesService do expect { described_class.new.execute(project_pipelines) }.not_to exceed_query_limit(control_count) end + + context 'with live build logs' do + before do + create(:ci_build_trace_chunk, build: cancelable_build) + end + + it 'makes canceled builds with stale trace visible' do + expect(Ci::Build.with_stale_live_trace.count).to eq 0 + + travel_to(2.days.ago) do + described_class.new.execute(project.all_pipelines) + end + + expect(Ci::Build.with_stale_live_trace.count).to eq 1 + end + end end context 'with user pipelines' do