diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-03 12:08:27 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-03 12:08:27 +0000 |
commit | 077b0a79d52753d020280ed8d58f97f8207b42de (patch) | |
tree | 79c6a7d3bbc41915acfff72e4620e7c4490528bf /scripts | |
parent | 10d4625ed3b73f73bc67bf7d35347dcd1912cf7b (diff) | |
download | gitlab-ce-077b0a79d52753d020280ed8d58f97f8207b42de.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/lib/glfm/render_static_html.rb | 5 | ||||
-rw-r--r-- | scripts/lib/glfm/update_example_snapshots.rb | 51 | ||||
-rwxr-xr-x | scripts/review_apps/review-apps.sh | 8 |
3 files changed, 53 insertions, 11 deletions
diff --git a/scripts/lib/glfm/render_static_html.rb b/scripts/lib/glfm/render_static_html.rb index 8d72aec7c3b..949eab72537 100644 --- a/scripts/lib/glfm/render_static_html.rb +++ b/scripts/lib/glfm/render_static_html.rb @@ -34,7 +34,7 @@ RSpec.describe 'Render Static HTML', :api, type: :request do # rubocop:disable R it 'can create a project dependency graph using factories' do markdown_hash = YAML.safe_load(File.open(ENV.fetch('INPUT_MARKDOWN_YML_PATH')), symbolize_names: true) - metadata_hash = YAML.safe_load(File.open(ENV.fetch('INPUT_METADATA_YML_PATH')), symbolize_names: true) + metadata_hash = YAML.safe_load(File.open(ENV.fetch('INPUT_METADATA_YML_PATH')), symbolize_names: true) || {} # NOTE: We cannot parallelize this loop like the Javascript WYSIWYG example generation does, # because the rspec `post` API cannot be parallized (it is not thread-safe, it can't find @@ -66,8 +66,7 @@ RSpec.describe 'Render Static HTML', :api, type: :request do # rubocop:disable R private def write_output_file(static_html_hash) - tmpfile = File.open(ENV.fetch('OUTPUT_STATIC_HTML_TEMPFILE_PATH'), 'w') yaml_string = dump_yaml_with_formatting(static_html_hash) - write_file(tmpfile, yaml_string) + write_file(ENV.fetch('OUTPUT_STATIC_HTML_TEMPFILE_PATH'), yaml_string) end end diff --git a/scripts/lib/glfm/update_example_snapshots.rb b/scripts/lib/glfm/update_example_snapshots.rb index 7dc0d0f7c4b..e502990b03f 100644 --- a/scripts/lib/glfm/update_example_snapshots.rb +++ b/scripts/lib/glfm/update_example_snapshots.rb @@ -5,6 +5,7 @@ require 'yaml' require 'psych' require 'tempfile' require 'open3' +require 'active_support/core_ext/enumerable' require_relative 'constants' require_relative 'shared' require_relative 'parse_examples' @@ -115,11 +116,13 @@ module Glfm def write_snapshot_example_files(all_examples, skip_static_and_wysiwyg:) output("Reading #{GLFM_EXAMPLE_STATUS_YML_PATH}...") - glfm_examples_statuses = YAML.safe_load(File.open(GLFM_EXAMPLE_STATUS_YML_PATH), symbolize_names: true) + glfm_examples_statuses = YAML.safe_load(File.open(GLFM_EXAMPLE_STATUS_YML_PATH), symbolize_names: true) || {} validate_glfm_example_status_yml(glfm_examples_statuses) write_examples_index_yml(all_examples) + validate_glfm_config_file_example_names(all_examples) + write_markdown_yml(all_examples) if skip_static_and_wysiwyg @@ -151,6 +154,50 @@ module Glfm end end + def validate_glfm_config_file_example_names(all_examples) + valid_example_names = all_examples.pluck(:name).map(&:to_sym) # rubocop:disable CodeReuse/ActiveRecord + + # We are re-reading GLFM_EXAMPLE_STATUS_YML_PATH here, but that's OK, it's a small file, and rereading it + # allows us to handle it in the same loop as the other manually-curated config files. + [ + GLFM_EXAMPLE_STATUS_YML_PATH, + GLFM_EXAMPLE_METADATA_YML_PATH, + GLFM_EXAMPLE_NORMALIZATIONS_YML_PATH + ].each do |path| + output("Reading #{path}...") + io = File.open(path) + config_file_examples = YAML.safe_load(io, symbolize_names: true, aliases: true) + + # Skip validation if the config file is empty + next unless config_file_examples + + config_file_example_names = config_file_examples.keys + + # Validate that all example names exist in the config file refer to an existing example in `examples_index.yml`, + # unless it starts with the special prefix `00_`, which is preserved for usage as YAML anchors. + invalid_name = config_file_example_names.detect do |name| + !name.start_with?('00_') && valid_example_names.exclude?(name) + end + next unless invalid_name + + # NOTE: The extra spaces before punctuation in the error message allows for easier copy/pasting of the paths. + err_msg = + <<~TXT + + Error in input specification config file #{path} : + + Config file entry named #{invalid_name} + does not have a corresponding example entry in + #{ES_EXAMPLES_INDEX_YML_PATH} . + + Please delete or rename this config file entry. + + If this entry is being used as a YAML anchor, please rename it to start with '00_'. + TXT + raise err_msg + end + end + def write_examples_index_yml(all_examples) generate_and_write_for_all_examples( all_examples, ES_EXAMPLES_INDEX_YML_PATH, literal_scalars: false @@ -244,7 +291,7 @@ module Glfm wysiwyg_html_and_json_tempfile_path = Dir::Tmpname.create(WYSIWYG_HTML_AND_JSON_TEMPFILE_BASENAME) {} ENV['OUTPUT_WYSIWYG_HTML_AND_JSON_TEMPFILE_PATH'] = wysiwyg_html_and_json_tempfile_path - cmd = %(yarn jest --testMatch '**/render_wysiwyg_html_and_json.js' #{__dir__}/render_wysiwyg_html_and_json.js) + cmd = "yarn jest --testMatch '**/render_wysiwyg_html_and_json.js' #{__dir__}/render_wysiwyg_html_and_json.js" run_external_cmd(cmd) output("Reading generated WYSIWYG HTML and prosemirror JSON from tempfile " \ diff --git a/scripts/review_apps/review-apps.sh b/scripts/review_apps/review-apps.sh index e979d0f75cf..a50db8b6f5d 100755 --- a/scripts/review_apps/review-apps.sh +++ b/scripts/review_apps/review-apps.sh @@ -154,12 +154,8 @@ function disable_sign_ups() { true fi - # Create the root token - local set_token_rb="token = User.find_by_username('root').personal_access_tokens.create(scopes: [:api], name: 'Token to disable sign-ups'); token.set_token('${REVIEW_APPS_ROOT_TOKEN}'); begin; token.save!; rescue(ActiveRecord::RecordNotUnique); end" - retry "run_task \"${set_token_rb}\"" - - # Disable sign-ups - local disable_signup_rb="Gitlab::CurrentSettings.current_application_settings.update!(signup_enabled: false)" + # Create the root token + Disable sign-ups + local disable_signup_rb="token = User.find_by_username('root').personal_access_tokens.create(scopes: [:api], name: 'Token to disable sign-ups'); token.set_token('${REVIEW_APPS_ROOT_TOKEN}'); begin; token.save!; rescue(ActiveRecord::RecordNotUnique); end; Gitlab::CurrentSettings.current_application_settings.update!(signup_enabled: false)" if (retry "run_task \"${disable_signup_rb}\""); then echoinfo "Sign-ups have been disabled successfully." else |