Add latest changes from gitlab-org/gitlab@master
|
|
@ -111,5 +111,4 @@ include:
|
|||
- local: .gitlab/ci/dast.gitlab-ci.yml
|
||||
- local: .gitlab/ci/workhorse.gitlab-ci.yml
|
||||
- local: .gitlab/ci/graphql.gitlab-ci.yml
|
||||
- project: 'gitlab-org/frontend/untamper-my-lockfile'
|
||||
file: '.gitlab-ci-template.yml'
|
||||
- local: .gitlab/ci/verify-lockfile.gitlab-ci.yml
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
verify_lockfile:
|
||||
stage: test
|
||||
image: registry.gitlab.com/gitlab-org/gitlab-build-images:ruby-2.7.2-git-2.29-lfs-2.9-node-14.15-yarn-1.22-graphicsmagick-1.3.34
|
||||
needs: []
|
||||
rules:
|
||||
- changes:
|
||||
- yarn.lock
|
||||
script:
|
||||
- npm config set @dappelt:registry https://gitlab.com/api/v4/projects/22564149/packages/npm/
|
||||
- npx lockfile-lint@4.3.7 --path yarn.lock --allowed-hosts yarn --validate-https
|
||||
- npx @dappelt/untamper-my-lockfile --lockfile yarn.lock
|
||||
2
Gemfile
|
|
@ -156,7 +156,7 @@ gem 'wikicloth', '0.8.1'
|
|||
gem 'asciidoctor', '~> 2.0.10'
|
||||
gem 'asciidoctor-include-ext', '~> 0.3.1', require: false
|
||||
gem 'asciidoctor-plantuml', '~> 0.0.12'
|
||||
gem 'asciidoctor-kroki', '~> 0.2.2', require: false
|
||||
gem 'asciidoctor-kroki', '~> 0.3.0', require: false
|
||||
gem 'rouge', '~> 3.26.0'
|
||||
gem 'truncato', '~> 0.7.11'
|
||||
gem 'bootstrap_form', '~> 4.2.0'
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ GEM
|
|||
asciidoctor (2.0.12)
|
||||
asciidoctor-include-ext (0.3.1)
|
||||
asciidoctor (>= 1.5.6, < 3.0.0)
|
||||
asciidoctor-kroki (0.2.2)
|
||||
asciidoctor-kroki (0.3.0)
|
||||
asciidoctor (~> 2.0)
|
||||
asciidoctor-plantuml (0.0.12)
|
||||
asciidoctor (>= 1.5.6, < 3.0.0)
|
||||
|
|
@ -1291,7 +1291,7 @@ DEPENDENCIES
|
|||
asana (~> 0.10.3)
|
||||
asciidoctor (~> 2.0.10)
|
||||
asciidoctor-include-ext (~> 0.3.1)
|
||||
asciidoctor-kroki (~> 0.2.2)
|
||||
asciidoctor-kroki (~> 0.3.0)
|
||||
asciidoctor-plantuml (~> 0.0.12)
|
||||
atlassian-jwt (~> 0.2.0)
|
||||
attr_encrypted (~> 3.1.0)
|
||||
|
|
|
|||
|
|
@ -238,6 +238,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
|
|||
*::ApplicationSettingsHelper.visible_attributes,
|
||||
*::ApplicationSettingsHelper.external_authorization_service_attributes,
|
||||
*ApplicationSetting.repository_storages_weighted_attributes,
|
||||
*ApplicationSetting.kroki_formats_attributes.keys.map { |key| "kroki_formats_#{key}".to_sym },
|
||||
:lets_encrypt_notification_email,
|
||||
:lets_encrypt_terms_of_service_accepted,
|
||||
:domain_denylist_file,
|
||||
|
|
|
|||
|
|
@ -26,6 +26,16 @@ module ApplicationSettingsHelper
|
|||
end
|
||||
end
|
||||
|
||||
def kroki_available_formats
|
||||
ApplicationSetting.kroki_formats_attributes.map do |key, value|
|
||||
{
|
||||
name: "kroki_formats_#{key}",
|
||||
label: value[:label],
|
||||
value: @application_setting.kroki_formats[key] || false
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def storage_weights
|
||||
ApplicationSetting.repository_storages_weighted_attributes.map do |attribute|
|
||||
storage = attribute.to_s.delete_prefix('repository_storages_weighted_')
|
||||
|
|
@ -259,6 +269,7 @@ module ApplicationSettingsHelper
|
|||
:personal_access_token_prefix,
|
||||
:kroki_enabled,
|
||||
:kroki_url,
|
||||
:kroki_formats,
|
||||
:plantuml_enabled,
|
||||
:plantuml_url,
|
||||
:polling_interval_multiplier,
|
||||
|
|
|
|||
|
|
@ -29,6 +29,21 @@ class ApplicationSetting < ApplicationRecord
|
|||
@repository_storages_weighted_atributes ||= Gitlab.config.repositories.storages.keys.map { |k| "repository_storages_weighted_#{k}".to_sym }.freeze
|
||||
end
|
||||
|
||||
def self.kroki_formats_attributes
|
||||
{
|
||||
blockdiag: {
|
||||
label: 'BlockDiag (includes BlockDiag, SeqDiag, ActDiag, NwDiag, PacketDiag and RackDiag)'
|
||||
},
|
||||
bpmn: {
|
||||
label: 'BPMN'
|
||||
},
|
||||
excalidraw: {
|
||||
label: 'Excalidraw'
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
store_accessor :kroki_formats, *ApplicationSetting.kroki_formats_attributes.keys, prefix: true
|
||||
store_accessor :repository_storages_weighted, *Gitlab.config.repositories.storages.keys, prefix: true
|
||||
|
||||
# Include here so it can override methods from
|
||||
|
|
@ -54,6 +69,7 @@ class ApplicationSetting < ApplicationRecord
|
|||
|
||||
default_value_for :id, 1
|
||||
default_value_for :repository_storages_weighted, {}
|
||||
default_value_for :kroki_formats, {}
|
||||
|
||||
chronic_duration_attr_writer :archive_builds_in_human_readable, :archive_builds_in_seconds
|
||||
|
||||
|
|
@ -135,6 +151,8 @@ class ApplicationSetting < ApplicationRecord
|
|||
|
||||
validate :validate_kroki_url, if: :kroki_enabled
|
||||
|
||||
validates :kroki_formats, json_schema: { filename: 'application_setting_kroki_formats' }
|
||||
|
||||
validates :plantuml_url,
|
||||
presence: true,
|
||||
if: :plantuml_enabled
|
||||
|
|
@ -570,6 +588,25 @@ class ApplicationSetting < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
kroki_formats_attributes.keys.each do |key|
|
||||
define_method :"kroki_formats_#{key}=" do |value|
|
||||
super(::Gitlab::Utils.to_boolean(value))
|
||||
end
|
||||
end
|
||||
|
||||
def kroki_format_supported?(diagram_type)
|
||||
case diagram_type
|
||||
when 'excalidraw'
|
||||
return kroki_formats_excalidraw
|
||||
when 'bpmn'
|
||||
return kroki_formats_bpmn
|
||||
end
|
||||
|
||||
return kroki_formats_blockdiag if ::Gitlab::Kroki::BLOCKDIAG_FORMATS.include?(diagram_type)
|
||||
|
||||
::AsciidoctorExtensions::Kroki::SUPPORTED_DIAGRAM_NAMES.include?(diagram_type)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def parsed_grafana_url
|
||||
|
|
|
|||
|
|
@ -176,6 +176,7 @@ module ApplicationSettingImplementation
|
|||
container_registry_expiration_policies_worker_capacity: 0,
|
||||
kroki_enabled: false,
|
||||
kroki_url: nil,
|
||||
kroki_formats: { blockdiag: false, bpmn: false, excalidraw: false },
|
||||
rate_limiting_response_text: nil
|
||||
}
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ module ContainerExpirationPolicies
|
|||
class CleanupService
|
||||
attr_reader :repository
|
||||
|
||||
SERVICE_RESULT_FIELDS = %i[original_size before_truncate_size after_truncate_size before_delete_size].freeze
|
||||
SERVICE_RESULT_FIELDS = %i[original_size before_truncate_size after_truncate_size before_delete_size deleted_size].freeze
|
||||
|
||||
def initialize(repository)
|
||||
@repository = repository
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ module Projects
|
|||
result[:before_truncate_size] = before_truncate_size
|
||||
result[:after_truncate_size] = after_truncate_size
|
||||
result[:before_delete_size] = tags.size
|
||||
result[:deleted_size] = result[:deleted]&.size
|
||||
|
||||
result[:status] = :error if before_truncate_size != after_truncate_size
|
||||
end
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"description": "Kroki formats",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"bpmn": { "type": "boolean" },
|
||||
"excalidraw": { "type": "boolean" },
|
||||
"blockdiag": { "type": "boolean" }
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
|
|
@ -21,5 +21,13 @@
|
|||
= f.text_field :kroki_url, class: 'form-control gl-form-input', placeholder: 'http://your-kroki-instance:8000'
|
||||
.form-text.text-muted
|
||||
= (_('When Kroki is enabled, GitLab sends diagrams to an instance of Kroki to display them as images. You can use the free public cloud instance %{kroki_public_url} or you can %{install_link} on your own infrastructure. Once you\'ve installed Kroki, make sure to update the server URL to point to your instance.') % { kroki_public_url: '<code>https://kroki.io</code>', install_link: link_to('install Kroki', 'https://docs.kroki.io/kroki/setup/install/', target: '_blank') }).html_safe
|
||||
.form-group
|
||||
= f.label :kroki_formats, 'Additional diagram formats', class: 'label-bold'
|
||||
.form-text.text-muted
|
||||
= (_('Using additional formats requires starting the companion containers. Make sure that all %{kroki_images} are running.') % { kroki_images: link_to('required containers', 'https://docs.kroki.io/kroki/setup/install/#_images', target: '_blank') }).html_safe
|
||||
- kroki_available_formats.each do |format|
|
||||
.form-check
|
||||
= f.check_box format[:name], class: 'form-check-input'
|
||||
= f.label format[:name], format[:label], class: 'form-check-label'
|
||||
|
||||
= f.submit _('Save changes'), class: "btn gl-button btn-success"
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ module ContainerExpirationPolicies
|
|||
cleanup_tags_service_before_truncate_size
|
||||
cleanup_tags_service_after_truncate_size
|
||||
cleanup_tags_service_before_delete_size
|
||||
cleanup_tags_service_deleted_size
|
||||
].freeze
|
||||
|
||||
def perform_work
|
||||
|
|
@ -117,6 +118,7 @@ module ContainerExpirationPolicies
|
|||
after_truncate_size &&
|
||||
before_truncate_size != after_truncate_size
|
||||
log_extra_metadata_on_done(:cleanup_tags_service_truncated, !!truncated)
|
||||
log_extra_metadata_on_done(:running_jobs_count, running_jobs_count)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: "Enable/disable additional diagram formats on Kroki"
|
||||
merge_request: 49304
|
||||
author: Guillaume Grossetie
|
||||
type: added
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddKrokiFormatsToApplicationSettingsTable < ActiveRecord::Migration[6.0]
|
||||
DOWNTIME = false
|
||||
|
||||
def change
|
||||
change_table :application_settings do |t|
|
||||
t.jsonb :kroki_formats, null: false, default: {}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1 @@
|
|||
c8f837a5fe7a1959af41f19f93b6dd96d8907a476626f124876ee8b10b120b71
|
||||
|
|
@ -9398,6 +9398,7 @@ CREATE TABLE application_settings (
|
|||
keep_latest_artifact boolean DEFAULT true NOT NULL,
|
||||
notes_create_limit integer DEFAULT 300 NOT NULL,
|
||||
notes_create_limit_allowlist text[] DEFAULT '{}'::text[] NOT NULL,
|
||||
kroki_formats jsonb DEFAULT '{}'::jsonb NOT NULL,
|
||||
CONSTRAINT app_settings_container_reg_cleanup_tags_max_list_size_positive CHECK ((container_registry_cleanup_tags_service_max_list_size >= 0)),
|
||||
CONSTRAINT app_settings_registry_exp_policies_worker_capacity_positive CHECK ((container_registry_expiration_policies_worker_capacity >= 0)),
|
||||
CONSTRAINT check_17d9558205 CHECK ((char_length((kroki_url)::text) <= 1024)),
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 149 KiB After Width: | Height: | Size: 48 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 195 KiB After Width: | Height: | Size: 52 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 8.5 KiB |
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 20 KiB |
|
|
@ -521,35 +521,6 @@ let_it_be_with_refind(:project) { create(:project) }
|
|||
let_it_be(:project, refind: true) { create(:project) }
|
||||
```
|
||||
|
||||
### License stubbing with `let_it_be`
|
||||
|
||||
`let_it_be_with_refind` is also useful when using `stub_licensed_features` in your tests:
|
||||
|
||||
```ruby
|
||||
let_it_be_with_refind(:project) { create(:project) }
|
||||
# Project#licensed_feature_available? is memoized, and so we need to refind
|
||||
# the project for license updates to be applied.
|
||||
# An alternative is `project.clear_memoization(:licensed_feature_available)`.
|
||||
|
||||
subject { project.allows_multiple_assignees? }
|
||||
|
||||
context 'with license multiple_issue_assignees disabled' do
|
||||
before do
|
||||
stub_licensed_features(multiple_issue_assignees: true)
|
||||
end
|
||||
|
||||
it { is_expected.to eq(true) }
|
||||
end
|
||||
|
||||
context 'with license multiple_issue_assignees disabled' do
|
||||
before do
|
||||
stub_licensed_features(multiple_issue_assignees: false)
|
||||
end
|
||||
|
||||
it { is_expected.to eq(false) }
|
||||
end
|
||||
```
|
||||
|
||||
### Time-sensitive tests
|
||||
|
||||
[`ActiveSupport::Testing::TimeHelpers`](https://api.rubyonrails.org/v6.0.3.1/classes/ActiveSupport/Testing/TimeHelpers.html)
|
||||
|
|
|
|||
|
|
@ -1,57 +1,8 @@
|
|||
---
|
||||
stage: none
|
||||
group: unassigned
|
||||
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
|
||||
comments: false
|
||||
type: reference
|
||||
redirect_to: '../../topics/gitlab_flow.md'
|
||||
---
|
||||
|
||||
# What is the GitLab Flow
|
||||
This document was moved to [another location](../../topics/gitlab_flow.md).
|
||||
|
||||
- A simplified branching strategy
|
||||
- All features and fixes first go to master
|
||||
- Allows for 'production' or 'stable' branches
|
||||
- Bug fixes/hot fix patches are cherry-picked from master
|
||||
|
||||
## Feature branches
|
||||
|
||||
- Create a feature/bugfix branch to do all work
|
||||
- Use merge requests to merge to master
|
||||
|
||||

|
||||
|
||||
## Production branch
|
||||
|
||||
- One, long-running production release branch
|
||||
as opposed to individual stable branches
|
||||
- Consider creating a tag for each version that gets deployed
|
||||
|
||||

|
||||
|
||||
## Release branch
|
||||
|
||||
- Useful if you release software to customers
|
||||
- When preparing a new release, create stable branch
|
||||
from master
|
||||
- Consider creating a tag for each version
|
||||
- Cherry-pick critical bug fixes to stable branch for patch release
|
||||
- Never commit bug fixes directly to stable branch
|
||||
|
||||

|
||||
|
||||
## More details
|
||||
|
||||
For more information, read through the [GitLab Flow](../../topics/gitlab_flow.md)
|
||||
documentation.
|
||||
|
||||
<!-- ## Troubleshooting
|
||||
|
||||
Include any troubleshooting steps that you can foresee. If you know beforehand what issues
|
||||
one might have when setting this up, or when something is changed, or on upgrading, it's
|
||||
important to describe those, too. Think of things that may go wrong and include them here.
|
||||
This is important to minimize requests for support, and to avoid doc comments with
|
||||
questions that you know someone might ask.
|
||||
|
||||
Each scenario can be a third-level heading, e.g. `### Getting error message X`.
|
||||
If you have none to add when creating a doc, leave this section in place
|
||||
but commented out to help encourage others to add to it in the future. -->
|
||||
<!-- This redirect file can be deleted after <2021-05-16>. -->
|
||||
<!-- Before deletion, see: https://docs.gitlab.com/ee/development/documentation/#move-or-rename-a-page -->
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 207 KiB After Width: | Height: | Size: 61 KiB |
|
Before Width: | Height: | Size: 157 KiB After Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 183 KiB After Width: | Height: | Size: 68 KiB |
|
Before Width: | Height: | Size: 136 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 8.1 KiB |
|
Before Width: | Height: | Size: 150 KiB After Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 116 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 101 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 91 KiB After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 105 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 405 KiB After Width: | Height: | Size: 111 KiB |
|
Before Width: | Height: | Size: 637 KiB After Width: | Height: | Size: 159 KiB |
|
Before Width: | Height: | Size: 102 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 213 KiB After Width: | Height: | Size: 74 KiB |
|
|
@ -13,9 +13,7 @@ module Gitlab
|
|||
packetdiag
|
||||
rackdiag
|
||||
].freeze
|
||||
# Diagrams that require a companion container are disabled for now
|
||||
DIAGRAMS_FORMATS = ::AsciidoctorExtensions::Kroki::SUPPORTED_DIAGRAM_NAMES
|
||||
.reject { |diagram_type| diagram_type == 'mermaid' || diagram_type == 'bpmn' || BLOCKDIAG_FORMATS.include?(diagram_type) }
|
||||
DIAGRAMS_FORMATS_WO_PLANTUML = DIAGRAMS_FORMATS
|
||||
.reject { |diagram_type| diagram_type == 'plantuml' }
|
||||
|
||||
|
|
@ -28,10 +26,18 @@ module Gitlab
|
|||
|
||||
# If PlantUML is enabled, PlantUML diagrams will be processed by the PlantUML server.
|
||||
# In other words, the PlantUML server has precedence over Kroki since both can process PlantUML diagrams.
|
||||
if current_settings.plantuml_enabled
|
||||
DIAGRAMS_FORMATS_WO_PLANTUML
|
||||
else
|
||||
DIAGRAMS_FORMATS
|
||||
diagram_formats = if current_settings.plantuml_enabled
|
||||
DIAGRAMS_FORMATS_WO_PLANTUML
|
||||
else
|
||||
DIAGRAMS_FORMATS
|
||||
end
|
||||
|
||||
# No additional diagram formats
|
||||
return diagram_formats unless current_settings.kroki_formats.present?
|
||||
|
||||
# Diagrams that require a companion container must be explicitly enabled from the settings
|
||||
diagram_formats.select do |diagram_type|
|
||||
current_settings.kroki_format_supported?(diagram_type)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -32271,6 +32271,9 @@ msgstr ""
|
|||
msgid "Using %{code_start}::%{code_end} denotes a %{link_start}scoped label set%{link_end}"
|
||||
msgstr ""
|
||||
|
||||
msgid "Using additional formats requires starting the companion containers. Make sure that all %{kroki_images} are running."
|
||||
msgstr ""
|
||||
|
||||
msgid "Using required encryption strategy when encrypted field is missing!"
|
||||
msgstr ""
|
||||
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ module QA
|
|||
read_from_project(project, number_of_reads)
|
||||
|
||||
praefect_manager.query_read_distribution.each_with_index do |data, index|
|
||||
diff_found[index] = {} unless diff_found[index]
|
||||
diff_found[index][:diff] = true if data[:value] > praefect_manager.value_for_node(pre_read_data, data[:node])
|
||||
end
|
||||
diff_found.all? { |node| node.key?(:diff) && node[:diff] }
|
||||
|
|
|
|||
|
|
@ -150,6 +150,13 @@ RSpec.describe Admin::ApplicationSettingsController do
|
|||
expect(ApplicationSetting.current.repository_storages_weighted_default).to eq(75)
|
||||
end
|
||||
|
||||
it 'updates kroki_formats setting' do
|
||||
put :update, params: { application_setting: { kroki_formats_excalidraw: '1' } }
|
||||
|
||||
expect(response).to redirect_to(general_admin_application_settings_path)
|
||||
expect(ApplicationSetting.current.kroki_formats_excalidraw).to eq(true)
|
||||
end
|
||||
|
||||
it "updates default_branch_name setting" do
|
||||
put :update, params: { application_setting: { default_branch_name: "example_branch_name" } }
|
||||
|
||||
|
|
|
|||
|
|
@ -194,4 +194,33 @@ RSpec.describe ApplicationSettingsHelper do
|
|||
it { is_expected.to be false }
|
||||
end
|
||||
end
|
||||
|
||||
describe '.kroki_available_formats' do
|
||||
let(:application_setting) { build(:application_setting) }
|
||||
|
||||
before do
|
||||
helper.instance_variable_set(:@application_setting, application_setting)
|
||||
stub_application_setting(kroki_formats: { 'blockdiag' => true, 'bpmn' => false, 'excalidraw' => false })
|
||||
end
|
||||
|
||||
it 'returns available formats correctly' do
|
||||
expect(helper.kroki_available_formats).to eq([
|
||||
{
|
||||
name: 'kroki_formats_blockdiag',
|
||||
label: 'BlockDiag (includes BlockDiag, SeqDiag, ActDiag, NwDiag, PacketDiag and RackDiag)',
|
||||
value: true
|
||||
},
|
||||
{
|
||||
name: 'kroki_formats_bpmn',
|
||||
label: 'BPMN',
|
||||
value: false
|
||||
},
|
||||
{
|
||||
name: 'kroki_formats_excalidraw',
|
||||
label: 'Excalidraw',
|
||||
value: false
|
||||
}
|
||||
])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -510,6 +510,73 @@ module Gitlab
|
|||
|
||||
expect(render(input, context)).to include(output.strip)
|
||||
end
|
||||
|
||||
it 'does not convert a blockdiag diagram to image' do
|
||||
input = <<~ADOC
|
||||
[blockdiag]
|
||||
....
|
||||
blockdiag {
|
||||
Kroki -> generates -> "Block diagrams";
|
||||
Kroki -> is -> "very easy!";
|
||||
|
||||
Kroki [color = "greenyellow"];
|
||||
"Block diagrams" [color = "pink"];
|
||||
"very easy!" [color = "orange"];
|
||||
}
|
||||
....
|
||||
ADOC
|
||||
|
||||
output = <<~HTML
|
||||
<div>
|
||||
<div>
|
||||
<pre>blockdiag {
|
||||
Kroki -> generates -> "Block diagrams";
|
||||
Kroki -> is -> "very easy!";
|
||||
|
||||
Kroki [color = "greenyellow"];
|
||||
"Block diagrams" [color = "pink"];
|
||||
"very easy!" [color = "orange"];
|
||||
}</pre>
|
||||
</div>
|
||||
</div>
|
||||
HTML
|
||||
|
||||
expect(render(input, context)).to include(output.strip)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with Kroki and BlockDiag (additional format) enabled' do
|
||||
before do
|
||||
allow_any_instance_of(ApplicationSetting).to receive(:kroki_enabled).and_return(true)
|
||||
allow_any_instance_of(ApplicationSetting).to receive(:kroki_url).and_return('https://kroki.io')
|
||||
allow_any_instance_of(ApplicationSetting).to receive(:kroki_formats_blockdiag).and_return(true)
|
||||
end
|
||||
|
||||
it 'converts a blockdiag diagram to image' do
|
||||
input = <<~ADOC
|
||||
[blockdiag]
|
||||
....
|
||||
blockdiag {
|
||||
Kroki -> generates -> "Block diagrams";
|
||||
Kroki -> is -> "very easy!";
|
||||
|
||||
Kroki [color = "greenyellow"];
|
||||
"Block diagrams" [color = "pink"];
|
||||
"very easy!" [color = "orange"];
|
||||
}
|
||||
....
|
||||
ADOC
|
||||
|
||||
output = <<~HTML
|
||||
<div>
|
||||
<div>
|
||||
<a class="no-attachment-icon" href="https://kroki.io/blockdiag/svg/eNpdzDEKQjEQhOHeU4zpPYFoYesRxGJ9bwghMSsbUYJ4d10UCZbDfPynolOek0Q8FsDeNCestoisNLmy-Qg7R3Blcm5hPcr0ITdaB6X15fv-_YdJixo2CNHI2lmK3sPRA__RwV5SzV80ZAegJjXSyfMFptc71w==" target="_blank" rel="noopener noreferrer"><img src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" alt="Diagram" class="lazy" data-src="https://kroki.io/blockdiag/svg/eNpdzDEKQjEQhOHeU4zpPYFoYesRxGJ9bwghMSsbUYJ4d10UCZbDfPynolOek0Q8FsDeNCestoisNLmy-Qg7R3Blcm5hPcr0ITdaB6X15fv-_YdJixo2CNHI2lmK3sPRA__RwV5SzV80ZAegJjXSyfMFptc71w=="></a>
|
||||
</div>
|
||||
</div>
|
||||
HTML
|
||||
|
||||
expect(render(input, context)).to include(output.strip)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -964,6 +964,50 @@ RSpec.describe ApplicationSetting do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'kroki_format_supported?' do
|
||||
it 'returns true when Excalidraw is enabled' do
|
||||
subject.kroki_formats_excalidraw = true
|
||||
expect(subject.kroki_format_supported?('excalidraw')).to eq(true)
|
||||
end
|
||||
|
||||
it 'returns true when BlockDiag is enabled' do
|
||||
subject.kroki_formats_blockdiag = true
|
||||
# format "blockdiag" aggregates multiple diagram types: actdiag, blockdiag, nwdiag...
|
||||
expect(subject.kroki_format_supported?('actdiag')).to eq(true)
|
||||
expect(subject.kroki_format_supported?('blockdiag')).to eq(true)
|
||||
end
|
||||
|
||||
it 'returns false when BlockDiag is disabled' do
|
||||
subject.kroki_formats_blockdiag = false
|
||||
# format "blockdiag" aggregates multiple diagram types: actdiag, blockdiag, nwdiag...
|
||||
expect(subject.kroki_format_supported?('actdiag')).to eq(false)
|
||||
expect(subject.kroki_format_supported?('blockdiag')).to eq(false)
|
||||
end
|
||||
|
||||
it 'returns false when the diagram type is optional and not enabled' do
|
||||
expect(subject.kroki_format_supported?('bpmn')).to eq(false)
|
||||
end
|
||||
|
||||
it 'returns true when the diagram type is enabled by default' do
|
||||
expect(subject.kroki_format_supported?('vegalite')).to eq(true)
|
||||
expect(subject.kroki_format_supported?('nomnoml')).to eq(true)
|
||||
expect(subject.kroki_format_supported?('unknown-diagram-type')).to eq(false)
|
||||
end
|
||||
|
||||
it 'returns false when the diagram type is unknown' do
|
||||
expect(subject.kroki_format_supported?('unknown-diagram-type')).to eq(false)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'kroki_formats' do
|
||||
it 'returns the value for kroki_formats' do
|
||||
subject.kroki_formats = { blockdiag: true, bpmn: false, excalidraw: true }
|
||||
expect(subject.kroki_formats_blockdiag).to eq(true)
|
||||
expect(subject.kroki_formats_bpmn).to eq(false)
|
||||
expect(subject.kroki_formats_excalidraw).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
it 'does not allow to set weight for non existing storage' do
|
||||
setting.repository_storages_weighted = { invalid_storage: 100 }
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,8 @@ RSpec.describe ContainerExpirationPolicies::CleanupService do
|
|||
original_size: 1000,
|
||||
before_truncate_size: 800,
|
||||
after_truncate_size: 200,
|
||||
before_delete_size: 100
|
||||
before_delete_size: 100,
|
||||
deleted_size: 100
|
||||
}
|
||||
end
|
||||
|
||||
|
|
@ -77,7 +78,8 @@ RSpec.describe ContainerExpirationPolicies::CleanupService do
|
|||
cleanup_tags_service_original_size: 1000,
|
||||
cleanup_tags_service_before_truncate_size: 800,
|
||||
cleanup_tags_service_after_truncate_size: 200,
|
||||
cleanup_tags_service_before_delete_size: 100
|
||||
cleanup_tags_service_before_delete_size: 100,
|
||||
cleanup_tags_service_deleted_size: 100
|
||||
)
|
||||
expect(ContainerRepository.waiting_for_cleanup.count).to eq(1)
|
||||
expect(repository.reload.cleanup_unfinished?).to be_truthy
|
||||
|
|
|
|||
|
|
@ -284,7 +284,7 @@ RSpec.describe Projects::ContainerRepository::CleanupTagsService do
|
|||
deleted: nil
|
||||
)
|
||||
|
||||
expect(result).to eq(service_response.compact)
|
||||
expect(result).to eq(service_response)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -369,6 +369,6 @@ RSpec.describe Projects::ContainerRepository::CleanupTagsService do
|
|||
before_truncate_size: before_truncate_size,
|
||||
after_truncate_size: after_truncate_size,
|
||||
before_delete_size: before_delete_size
|
||||
}.compact
|
||||
}.compact.merge(deleted_size: deleted&.size)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -62,7 +62,6 @@ Service.available_services_names.each do |service|
|
|||
|
||||
stub_licensed_features(licensed_feature => true)
|
||||
project.clear_memoization(:disabled_services)
|
||||
project.clear_memoization(:licensed_feature_available)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ RSpec.describe ContainerExpirationPolicies::CleanupContainerRepositoryWorker do
|
|||
end
|
||||
end
|
||||
|
||||
def cleanup_service_response(status: :finished, repository:, cleanup_tags_service_original_size: 100, cleanup_tags_service_before_truncate_size: 80, cleanup_tags_service_after_truncate_size: 80, cleanup_tags_service_before_delete_size: 50)
|
||||
def cleanup_service_response(status: :finished, repository:, cleanup_tags_service_original_size: 100, cleanup_tags_service_before_truncate_size: 80, cleanup_tags_service_after_truncate_size: 80, cleanup_tags_service_before_delete_size: 50, cleanup_tags_service_deleted_size: 50)
|
||||
ServiceResponse.success(
|
||||
message: "cleanup #{status}",
|
||||
payload: {
|
||||
|
|
@ -218,11 +218,12 @@ RSpec.describe ContainerExpirationPolicies::CleanupContainerRepositoryWorker do
|
|||
expect(worker).to receive(:log_extra_metadata_on_done).with(:project_id, repository.project.id)
|
||||
expect(worker).to receive(:log_extra_metadata_on_done).with(:cleanup_status, cleanup_status)
|
||||
|
||||
%i[cleanup_tags_service_original_size cleanup_tags_service_before_truncate_size cleanup_tags_service_after_truncate_size cleanup_tags_service_before_delete_size].each do |field|
|
||||
%i[cleanup_tags_service_original_size cleanup_tags_service_before_truncate_size cleanup_tags_service_after_truncate_size cleanup_tags_service_before_delete_size cleanup_tags_service_deleted_size].each do |field|
|
||||
value = service_response.payload[field]
|
||||
expect(worker).to receive(:log_extra_metadata_on_done).with(field, value) unless value.nil?
|
||||
end
|
||||
expect(worker).to receive(:log_extra_metadata_on_done).with(:cleanup_tags_service_truncated, truncated)
|
||||
expect(worker).to receive(:log_extra_metadata_on_done).with(:running_jobs_count, 0)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||