Skip to content

Commit

Permalink
Adds search variables to Kibana link checker (#2292)
Browse files Browse the repository at this point in the history
  • Loading branch information
lcawl authored Nov 22, 2021
1 parent 2bbcdc8 commit b00435f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
8 changes: 7 additions & 1 deletion build_docs.pl
Original file line number Diff line number Diff line change
Expand Up @@ -361,11 +361,14 @@ sub check_kibana_links {
# ${STACK_DOCS}upgrading-elastic-stack.html
# ${SECURITY_SOLUTION_DOCS}sec-requirements.html
# ${STACK_GETTING_STARTED}get-started-elastic-stack.html
# ${APP_SEARCH_DOCS}authentication.html
# ${ENTERPRISE_SEARCH_DOCS}authentication.html
# ${WORKPLACE_SEARCH_DOCS}workplace-search-getting-started.html

my $extractor = sub {
my $contents = shift;
return sub {
while ( $contents =~ m!`(\$\{(?:baseUrl|ELASTIC.+|KIBANA_DOCS|PLUGIN_DOCS|FLEET_DOCS|APM_DOCS|STACK_DOCS|SECURITY_SOLUTION_DOCS|STACK_GETTING_STARTED)\}[^`]+)`!g ) {
while ( $contents =~ m!`(\$\{(?:baseUrl|ELASTIC.+|KIBANA_DOCS|PLUGIN_DOCS|FLEET_DOCS|APM_DOCS|STACK_DOCS|SECURITY_SOLUTION_DOCS|STACK_GETTING_STARTED|APP_SEARCH_DOCS|ENTERPRISE_SEARCH_DOCS|WORKPLACE_SEARCH_DOCS)\}[^`]+)`!g ) {
my $path = $1;
$path =~ s/\$\{(?:DOC_LINK_VERSION|urlVersion)\}/$version/;
# In older versions, the variable `${ELASTIC_DOCS}` referred to
Expand All @@ -380,6 +383,9 @@ sub check_kibana_links {
$path =~ s!\$\{STACK_DOCS\}!en/elastic-stack/$version/!;
$path =~ s!\$\{SECURITY_SOLUTION_DOCS\}!en/security/$version/!;
$path =~ s!\$\{STACK_GETTING_STARTED\}!en/elastic-stack-get-started/$version/!;
$path =~ s!\$\{APP_SEARCH_DOCS\}!en/app-search/$version/!;
$path =~ s!\$\{ENTERPRISE_SEARCH_DOCS\}!en/enterprise-search/$version/!;
$path =~ s!\$\{WORKPLACE_SEARCH_DOCS\}!en/workplace-search/$version/!;
# Replace the "https://www.elastic.co/guide/" URL prefix so that
# it becomes a file path in the built docs.
$path =~ s!\$\{(?:baseUrl|ELASTIC_WEBSITE_URL)\}guide/!!;
Expand Down
18 changes: 18 additions & 0 deletions integtest/spec/all_books_broken_link_detection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,24 @@
include_examples 'there are broken links in kibana',
'en/elastic-stack-get-started/master/not-a-page.html'
end
describe 'when there is a broken App Search link' do
include_context 'there is a kibana link', true,
'${APP_SEARCH_DOCS}not-a-search-page.html', true
include_examples 'there are broken links in kibana',
'en/app-search/master/not-a-search-page.html'
end
describe 'when there is a broken Enterprise Search link' do
include_context 'there is a kibana link', true,
'${ENTERPRISE_SEARCH_DOCS}not-a-search-page.html', true
include_examples 'there are broken links in kibana',
'en/enterprise-search/master/not-a-search-page.html'
end
describe 'when there is a broken Workplace Search link' do
include_context 'there is a kibana link', true,
'${WORKPLACE_SEARCH_DOCS}not-a-search-page.html', true
include_examples 'there are broken links in kibana',
'en/workplace-search/master/not-a-search-page.html'
end
describe 'when using --keep_hash and --sub_dir together like a PR test' do
describe 'when there is a broken link in one of the books being built' do
convert_before do |src, dest|
Expand Down

0 comments on commit b00435f

Please sign in to comment.