Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2022-03-22 09:07:15 +00:00
parent 07bb2516a0
commit 4c7e34071e
24 changed files with 203 additions and 61 deletions

View file

@ -1 +1 @@
442277b91f5aa2822d52b810fd462a41c6cf5a0a
f21e9469e94600f50ecb01b98d46f54dd7b33b5c

View file

@ -57,9 +57,9 @@ export default {
text: s__('ProjectTemplates|Pages/Hexo'),
icon: '.template-option .icon-hexo',
},
sse_middleman: {
text: s__('ProjectTemplates|Static Site Editor/Middleman'),
icon: '.template-option .icon-sse_middleman',
middleman: {
text: s__('ProjectTemplates|Pages/Middleman'),
icon: '.template-option .icon-middleman',
},
gitpod_spring_petclinic: {
text: s__('ProjectTemplates|Gitpod/Spring Petclinic'),

View file

@ -271,7 +271,8 @@ module Ci
runner_unsupported: -> (build, params) { !build.supported_runner?(params.dig(:info, :features)) },
archived_failure: -> (build, _) { build.archived? },
project_deleted: -> (build, _) { build.project.pending_delete? },
builds_disabled: -> (build, _) { !build.project.builds_enabled? }
builds_disabled: -> (build, _) { !build.project.builds_enabled? },
user_blocked: -> (build, _) { build.user&.blocked? }
}
end
end

View file

@ -36,7 +36,7 @@ class WebHookService
def initialize(hook, data, hook_name, uniqueness_token = nil, force: false)
@hook = hook
@data = data
@data = data.to_h
@hook_name = hook_name.to_s
@uniqueness_token = uniqueness_token
@force = force
@ -70,9 +70,6 @@ class WebHookService
end
log_execution(
trigger: hook_name,
url: hook.url,
request_data: data,
response: response,
execution_duration: Gitlab::Metrics::System.monotonic_time - start_time
)
@ -86,9 +83,6 @@ class WebHookService
Gitlab::Json::LimitedEncoder::LimitExceeded, URI::InvalidURIError => e
execution_duration = Gitlab::Metrics::System.monotonic_time - start_time
log_execution(
trigger: hook_name,
url: hook.url,
request_data: data,
response: InternalErrorResponse.new,
execution_duration: execution_duration,
error_message: e.to_s
@ -139,14 +133,14 @@ class WebHookService
make_request(post_url, basic_auth)
end
def log_execution(trigger:, url:, request_data:, response:, execution_duration:, error_message: nil)
def log_execution(response:, execution_duration:, error_message: nil)
category = response_category(response)
log_data = {
trigger: trigger,
url: url,
trigger: hook_name,
url: hook.url,
execution_duration: execution_duration,
request_headers: build_headers,
request_data: request_data,
request_data: data,
response_headers: format_response_headers(response),
response_body: safe_response_body(response),
response_status: response.code,

View file

@ -10,14 +10,12 @@
%hr
- if hook_log.internal_error_message.present?
.gl-alert-container
.gl-alert.gl-alert-danger
.gl-alert-container
= sprite_icon('error', size: 16, css_class: 'gl-icon gl-alert-icon gl-alert-icon-no-title')
.gl-alert-content
%h4.gl-alert-title= _('Internal error occurred while delivering this webhook.')
.gl-alert-body
= _('Error: %{error}') % { error: hook_log.internal_error_message }
= render 'shared/global_alert',
title: _('Internal error occurred while delivering this webhook.'),
variant: :danger,
dismissible: false do
.gl-alert-body
= _('Error: %{error}') % { error: hook_log.internal_error_message }
%h4= _('Response')
= render partial: 'shared/hook_logs/status_label', locals: { hook_log: hook_log }

View file

@ -1,20 +1,18 @@
.gl-alert.gl-alert-info.gl-my-5
= sprite_icon('information-o', css_class: 'gl-alert-icon')
- if runner.instance_type?
%h4.gl-alert-title
= s_('Runners|This runner is available to all groups and projects in your GitLab instance.')
.gl-alert-body
= s_('Runners|Shared runners are available to every project in a GitLab instance. If you want a runner to build only specific projects, restrict the project in the table below. After you restrict a runner to a project, you cannot change it back to a shared runner.')
= link_to _('Learn more.'), help_page_path('ci/runners/runners_scope', anchor: 'shared-runners'), target: '_blank', rel: 'noopener noreferrer'
- elsif runner.group_type?
%h4.gl-alert-title
= s_('Runners|This runner is available to all projects and subgroups in a group.')
- alert_class = 'gl-mb-5'
- if runner.group_type?
= render 'shared/global_alert',
alert_class: alert_class,
title: s_('Runners|This runner is available to all projects and subgroups in a group.'),
dismissible: false do
.gl-alert-body
= s_('Runners|Use Group runners when you want all projects in a group to have access to a set of runners.')
= link_to _('Learn more.'), help_page_path('ci/runners/runners_scope', anchor: 'group-runners'), target: '_blank', rel: 'noopener noreferrer'
- else
%h4.gl-alert-title
= s_('Runners|This runner is associated with specific projects.')
- else
= render 'shared/global_alert',
alert_class: alert_class,
title: s_('Runners|This runner is associated with specific projects.'),
dismissible: false do
.gl-alert-body
= s_('Runners|You can set up a specific runner to be used by multiple projects but you cannot make this a shared runner.')
= link_to _('Learn more.'), help_page_path('ci/runners/runners_scope', anchor: 'specific-runners'), target: '_blank', rel: 'noopener noreferrer'

View file

@ -136,3 +136,23 @@ Example response:
"url": "https://*****:*****@gitlab.com/gitlab-org/security/gitlab.git"
}
```
## Delete a remote mirror
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/82778) in GitLab 14.10.
Delete a remote mirror.
```plaintext
DELETE /projects/:id/remote_mirrors/:mirror_id
```
| Attribute | Type | Required | Description |
| :---------- | :----- | :--------- |:------------------|
| `mirror_id` | Integer | yes | Remote mirror ID. |
Example request:
```shell
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/42/remote_mirrors/101486"
```

View file

@ -22,9 +22,9 @@ want to configure.
## Integrations listing
Click on the service links to see further configuration instructions and details.
Click on the integration links to see further configuration instructions and details.
| Service | Description | Service hooks |
| Integration | Description | Integration hooks |
| --------------------------------------------------------- | -------------------------------------------------------------------------------------------- | ---------------------- |
| [Asana](asana.md) | Add commit messages as comments to Asana tasks. | **{dotted-circle}** No |
| Assembla | Manage projects. | **{dotted-circle}** No |
@ -69,7 +69,7 @@ Click on the service links to see further configuration instructions and details
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/17874) in GitLab 12.4.
If a single push includes changes to more than three branches or tags, services
If a single push includes changes to more than three branches or tags, integrations
supported by `push_hooks` and `tag_push_hooks` events aren't executed.
The number of branches or tags supported can be changed via
@ -94,7 +94,7 @@ and some integrations.
## Troubleshooting integrations
Some integrations use service hooks for integration with external applications. To confirm which ones use service hooks, see the [integrations listing](#integrations-listing) above. Learn more about [troubleshooting service hooks](webhooks.md#troubleshoot-webhooks).
Some integrations use hooks for integration with external applications. To confirm which ones use integration hooks, see the [integrations listing](#integrations-listing) above. Learn more about [troubleshooting integration hooks](webhooks.md#troubleshoot-webhooks).
### Uninitialized repositories

View file

@ -73,6 +73,29 @@ module API
render_api_error!(result[:message], result[:http_status])
end
end
desc 'Delete a single remote mirror' do
detail 'This feature was introduced in GitLab 14.10'
end
params do
requires :mirror_id, type: String, desc: 'The ID of a remote mirror'
end
delete ':id/remote_mirrors/:mirror_id' do
mirror = user_project.remote_mirrors.find(params[:mirror_id])
destroy_conditionally!(mirror) do
mirror_params = declared_params(include_missing: false).merge(_destroy: 1)
mirror_params[:id] = mirror_params.delete(:mirror_id)
update_params = { remote_mirrors_attributes: mirror_params }
# Note: We are using the update service to be consistent with how the controller handles deletion
result = ::Projects::UpdateService.new(user_project, current_user, update_params).execute
if result[:status] != :success
render_api_error!(result[:message], 400)
end
end
end
end
end
end

View file

@ -57,7 +57,7 @@ module Gitlab
ProjectTemplate.new('plainhtml', 'Pages/Plain HTML', _('Everything you need to create a GitLab Pages site using plain HTML'), 'https://gitlab.com/pages/plain-html'),
ProjectTemplate.new('gitbook', 'Pages/GitBook', _('Everything you need to create a GitLab Pages site using GitBook'), 'https://gitlab.com/pages/gitbook', 'illustrations/logos/gitbook.svg'),
ProjectTemplate.new('hexo', 'Pages/Hexo', _('Everything you need to create a GitLab Pages site using Hexo'), 'https://gitlab.com/pages/hexo', 'illustrations/logos/hexo.svg'),
ProjectTemplate.new('sse_middleman', 'Static Site Editor/Middleman', _('Middleman project with Static Site Editor support'), 'https://gitlab.com/gitlab-org/project-templates/static-site-editor-middleman', 'illustrations/logos/middleman.svg'),
ProjectTemplate.new('middleman', 'Pages/Middleman', _('Everything you need to create a GitLab Pages site using Middleman'), 'https://gitlab.com/gitlab-org/project-templates/middleman', 'illustrations/logos/middleman.svg'),
ProjectTemplate.new('gitpod_spring_petclinic', 'Gitpod/Spring Petclinic', _('A Gitpod configured Webapplication in Spring and Java'), 'https://gitlab.com/gitlab-org/project-templates/gitpod-spring-petclinic', 'illustrations/logos/gitpod.svg'),
ProjectTemplate.new('nfhugo', 'Netlify/Hugo', _('A Hugo site that uses Netlify for CI/CD instead of GitLab, but still with all the other great GitLab features'), 'https://gitlab.com/pages/nfhugo', 'illustrations/logos/netlify.svg'),
ProjectTemplate.new('nfjekyll', 'Netlify/Jekyll', _('A Jekyll site that uses Netlify for CI/CD instead of GitLab, but still with all the other great GitLab features'), 'https://gitlab.com/pages/nfjekyll', 'illustrations/logos/netlify.svg'),

View file

@ -14918,6 +14918,9 @@ msgstr ""
msgid "Everything you need to create a GitLab Pages site using Jekyll"
msgstr ""
msgid "Everything you need to create a GitLab Pages site using Middleman"
msgstr ""
msgid "Everything you need to create a GitLab Pages site using plain HTML"
msgstr ""
@ -23915,9 +23918,6 @@ msgstr ""
msgid "Mi"
msgstr ""
msgid "Middleman project with Static Site Editor support"
msgstr ""
msgid "Migrated %{success_count}/%{total_count} files."
msgstr ""
@ -29491,6 +29491,9 @@ msgstr ""
msgid "ProjectTemplates|Pages/Jekyll"
msgstr ""
msgid "ProjectTemplates|Pages/Middleman"
msgstr ""
msgid "ProjectTemplates|Pages/Plain HTML"
msgstr ""
@ -29509,9 +29512,6 @@ msgstr ""
msgid "ProjectTemplates|Spring"
msgstr ""
msgid "ProjectTemplates|Static Site Editor/Middleman"
msgstr ""
msgid "ProjectTemplates|Tencent Serverless Framework/NextjsSSR"
msgstr ""
@ -32195,9 +32195,6 @@ msgstr ""
msgid "Runners|Select your preferred option here. In the next step, you can choose the capacity for your runner in the AWS CloudFormation console."
msgstr ""
msgid "Runners|Shared runners are available to every project in a GitLab instance. If you want a runner to build only specific projects, restrict the project in the table below. After you restrict a runner to a project, you cannot change it back to a shared runner."
msgstr ""
msgid "Runners|Show runner installation and registration instructions"
msgstr ""
@ -32240,9 +32237,6 @@ msgstr ""
msgid "Runners|This runner is associated with specific projects."
msgstr ""
msgid "Runners|This runner is available to all groups and projects in your GitLab instance."
msgstr ""
msgid "Runners|This runner is available to all projects and subgroups in a group."
msgstr ""

View file

@ -204,6 +204,7 @@
"@gitlab/stylelint-config": "4.0.0",
"@graphql-eslint/eslint-plugin": "3.0.0",
"@testing-library/dom": "^7.16.2",
"@types/jest": "^26.0.24",
"@vue/test-utils": "1.3.0",
"acorn": "^6.3.0",
"axios-mock-adapter": "^1.15.0",

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true
module QA
RSpec.describe 'Create' do
RSpec.describe 'Create', :reliable do
describe 'Merge request custom templates' do
let(:template_name) { 'custom_merge_request_template'}
let(:template_content) { 'This is a custom merge request template test' }

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true
module QA
RSpec.describe 'Create' do
RSpec.describe 'Create', :reliable do
describe 'Reverting a commit' do
let(:file_name) { "secret_file.md" }

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true
module QA
RSpec.describe 'Create' do
RSpec.describe 'Create', :reliable do
context 'File management' do
file_name = 'QA Test - File name'
file_content = 'QA Test - File content'

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true
module QA
RSpec.describe 'Create' do
RSpec.describe 'Create', :reliable do
context 'File management' do
let(:file) { Resource::File.fabricate_via_api! }

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true
module QA
RSpec.describe 'Create' do
RSpec.describe 'Create', :reliable do
describe 'Multiple file snippet' do
let(:snippet) do
Resource::ProjectSnippet.fabricate_via_browser_ui! do |snippet|

View file

@ -8,7 +8,7 @@ RSpec.describe Gitlab::ProjectTemplate do
expected = %w[
rails spring express iosswift dotnetcore android
gomicro gatsby hugo jekyll plainhtml gitbook
hexo sse_middleman gitpod_spring_petclinic nfhugo
hexo middleman gitpod_spring_petclinic nfhugo
nfjekyll nfplainhtml nfgitbook nfhexo salesforcedx
serverless_framework tencent_serverless_framework
jsonnet cluster_management kotlin_native_linux

View file

@ -99,4 +99,44 @@ RSpec.describe API::RemoteMirrors do
expect(json_response['keep_divergent_refs']).to eq(true)
end
end
describe 'DELETE /projects/:id/remote_mirrors/:mirror_id' do
let(:route) { ->(id) { "/projects/#{project.id}/remote_mirrors/#{id}" } }
let(:mirror) { project.remote_mirrors.first }
it 'requires `admin_remote_mirror` permission' do
expect { delete api(route[mirror.id], developer) }.not_to change { project.remote_mirrors.count }
expect(response).to have_gitlab_http_status(:unauthorized)
end
context 'when the user is a maintainer' do
before do
project.add_maintainer(user)
end
it 'returns 404 for non existing id' do
delete api(route[non_existing_record_id], user)
expect(response).to have_gitlab_http_status(:not_found)
end
it 'returns bad request if the update service fails' do
expect_next_instance_of(Projects::UpdateService) do |service|
expect(service).to receive(:execute).and_return(status: :error, message: 'message')
end
expect { delete api(route[mirror.id], user) }.not_to change { project.remote_mirrors.count }
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response).to eq({ 'message' => 'message' })
end
it 'deletes a remote mirror' do
expect { delete api(route[mirror.id], user) }.to change { project.remote_mirrors.count }.from(1).to(0)
expect(response).to have_gitlab_http_status(:no_content)
end
end
end
end

View file

@ -103,6 +103,20 @@ module Ci
pending_job.create_queuing_entry!
end
context 'when build owner has been blocked' do
let(:user) { create(:user, :blocked) }
before do
pending_job.update!(user: user)
end
it 'does not pick the build and drops the build' do
expect(execute(shared_runner)).to be_falsey
expect(pending_job.reload).to be_user_blocked
end
end
context 'for multiple builds' do
let!(:project2) { create :project, shared_runners_enabled: true }
let!(:pipeline2) { create :ci_pipeline, project: project2 }

View file

@ -107,6 +107,21 @@ RSpec.describe WebHookService, :request_store, :clean_gitlab_redis_shared_state
).once
end
context 'when the data is a Gitlab::DataBuilder::Pipeline' do
let(:pipeline) { create(:ci_pipeline, project: project) }
let(:data) { ::Gitlab::DataBuilder::Pipeline.new(pipeline) }
it 'can log the request payload' do
stub_full_request(project_hook.url, method: :post)
# we call this with force to ensure that the logs are written inline,
# which tests that we can serialize the data to the DB correctly.
service = described_class.new(project_hook, data, :push_hooks, force: true)
expect { service.execute }.to change(::WebHookLog, :count).by(1)
end
end
context 'when auth credentials are present' do
let_it_be(:url) {'https://example.org'}
let_it_be(:project_hook) { create(:project_hook, url: 'https://demo:demo@example.org/') }

Binary file not shown.

Binary file not shown.

View file

@ -1379,6 +1379,17 @@
"@types/yargs" "^15.0.0"
chalk "^4.0.0"
"@jest/types@^26.6.2":
version "26.6.2"
resolved "https://registry.yarnpkg.com/@jest/types/-/types-26.6.2.tgz#bef5a532030e1d88a2f5a6d933f84e97226ed48e"
integrity sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ==
dependencies:
"@types/istanbul-lib-coverage" "^2.0.0"
"@types/istanbul-reports" "^3.0.0"
"@types/node" "*"
"@types/yargs" "^15.0.0"
chalk "^4.0.0"
"@miragejs/pretender-node-polyfill@^0.1.0":
version "0.1.2"
resolved "https://registry.yarnpkg.com/@miragejs/pretender-node-polyfill/-/pretender-node-polyfill-0.1.2.tgz#d26b6b7483fb70cd62189d05c95d2f67153e43f2"
@ -1929,6 +1940,14 @@
dependencies:
"@types/istanbul-lib-report" "*"
"@types/jest@^26.0.24":
version "26.0.24"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.24.tgz#943d11976b16739185913a1936e0de0c4a7d595a"
integrity sha512-E/X5Vib8BWqZNRlDxj9vYXhsDwPYbPINqKF9BsnSoon4RQ0D9moEuLD8txgyypFLH7J4+Lho9Nr/c8H0Fi+17w==
dependencies:
jest-diff "^26.0.0"
pretty-format "^26.0.0"
"@types/json-schema@^7.0.3", "@types/json-schema@^7.0.5", "@types/json-schema@^7.0.8", "@types/json-schema@^7.0.9":
version "7.0.9"
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.9.tgz#97edc9037ea0c38585320b28964dde3b39e4660d"
@ -4841,6 +4860,11 @@ diff-sequences@^26.5.0:
resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-26.5.0.tgz#ef766cf09d43ed40406611f11c6d8d9dd8b2fefd"
integrity sha512-ZXx86srb/iYy6jG71k++wBN9P9J05UNQ5hQHQd9MtMPvcqXPx/vKU69jfHV637D00Q2gSgPk2D+jSx3l1lDW/Q==
diff-sequences@^26.6.2:
version "26.6.2"
resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-26.6.2.tgz#48ba99157de1923412eed41db6b6d4aa9ca7c0b1"
integrity sha512-Mv/TDa3nZ9sbc5soK+OoA74BsS3mL37yixCvUAQkiuA4Wz6YtwP/K47n2rv2ovzHZvoiQeA5FTQOschKkEwB0Q==
diff-sequences@^27.4.0:
version "27.4.0"
resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-27.4.0.tgz#d783920ad8d06ec718a060d00196dfef25b132a5"
@ -7201,6 +7225,16 @@ jest-config@^26.5.2:
micromatch "^4.0.2"
pretty-format "^26.5.2"
jest-diff@^26.0.0:
version "26.6.2"
resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-26.6.2.tgz#1aa7468b52c3a68d7d5c5fdcdfcd5e49bd164394"
integrity sha512-6m+9Z3Gv9wN0WFVasqjCL/06+EFCMTqDEUl/b87HYK2rAPTyfz4ZIuSlPhY51PIQRWx5TaxeF1qmXKe9gfN3sA==
dependencies:
chalk "^4.0.0"
diff-sequences "^26.6.2"
jest-get-type "^26.3.0"
pretty-format "^26.6.2"
jest-diff@^26.5.2:
version "26.5.2"
resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-26.5.2.tgz#8e26cb32dc598e8b8a1b9deff55316f8313c8053"
@ -9530,6 +9564,16 @@ prettier@^1.18.2:
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.18.2.tgz#6823e7c5900017b4bd3acf46fe9ac4b4d7bda9ea"
integrity sha512-OeHeMc0JhFE9idD4ZdtNibzY0+TPHSpSSb9h8FqtP+YnoZZ1sl8Vc9b1sasjfymH3SonAF4QcA2+mzHPhMvIiw==
pretty-format@^26.0.0, pretty-format@^26.6.2:
version "26.6.2"
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-26.6.2.tgz#e35c2705f14cb7fe2fe94fa078345b444120fc93"
integrity sha512-7AeGuCYNGmycyQbCqd/3PWH4eOoX/OiCa0uphp57NVTeAGdJGaAliecxwBDHYQCIvrW7aDBZCYeNTP/WX69mkg==
dependencies:
"@jest/types" "^26.6.2"
ansi-regex "^5.0.0"
ansi-styles "^4.0.0"
react-is "^17.0.1"
pretty-format@^26.4.2, pretty-format@^26.5.2:
version "26.5.2"
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-26.5.2.tgz#5d896acfdaa09210683d34b6dc0e6e21423cd3e1"