Skip to content

Commit

Permalink
Test documentation links against a TOC file
Browse files Browse the repository at this point in the history
  • Loading branch information
ShimShtein committed Feb 20, 2024
1 parent c20a21d commit 06a3169
Show file tree
Hide file tree
Showing 5 changed files with 1,681 additions and 74 deletions.
16 changes: 8 additions & 8 deletions lib/foreman_theme_satellite/documentation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Documentation

# Managing Hosts
'ForemanRemoteExecution' => "#{ForemanThemeSatellite.documentation_root}/managing_hosts/configuring_and_setting_up_remote_jobs_managing-hosts",
'ExecutingaJob' => "#{ForemanThemeSatellite.documentation_root}/managing_hosts/configuring_and_setting_up_remote_jobs_managing-hosts#configuring-the-global-smartproxy-remote-execution-setting_managing-hosts",
'ExecutingaJob' => "#{ForemanThemeSatellite.documentation_root}/managing_hosts/configuring_and_setting_up_remote_jobs_managing-hosts#Configuring_the_Global_capsule_Remote_Execution_Setting_in_satellite_managing-hosts",
'JobTemplates' => "#{ForemanThemeSatellite.documentation_root}/managing_hosts/configuring_and_setting_up_remote_jobs_managing-hosts#setting-up-job-templates_managing-hosts",
'ReportTemplates' => "#{ForemanThemeSatellite.documentation_root}/managing_hosts/using_report_templates_to_monitor_hosts_managing-hosts",
'Reports' => "#{ForemanThemeSatellite.documentation_root}/managing_hosts/using_report_templates_to_monitor_hosts_managing-hosts",
Expand Down Expand Up @@ -59,17 +59,17 @@ module Documentation
'Auditing' => "#{ForemanThemeSatellite.documentation_root}/satellite_overview_concepts_and_deployment_considerations/appe-architecture_guide-glossary_of_terms#varl-Glossary_of_Terms-Audits",

# Install
'HTTP(S)Proxy' => "#{ForemanThemeSatellite.documentation_root}//installing_satellite_server_in_a_connected_network_environment/performing-additional-configuration#Configuring_Server_with_an_HTTP_Proxy_satellite",
'HTTP(S)Proxy' => "#{ForemanThemeSatellite.documentation_root}/installing_satellite_server_in_a_connected_network_environment/performing-additional-configuration#Configuring_Server_with_an_HTTP_Proxy_satellite",

# Misc
'GettingHelp' => "https://access.redhat.com/products/red-hat-satellite/#support",

# Managing Security Compliance
'Monitoring_Compliance_security-compliance' => "#{ForemanThemeSatellite.documentation_root}/managing_security_compliance/Monitoring_Compliance_security-compliance",
'Managing_Compliance_Policies_security-compliance' => "#{ForemanThemeSatellite.documentation_root}/managing_security_compliance/Managing_Compliance_Policies_security-compliance",
'Configuring_SCAP_Contents_security-compliance' => "#{ForemanThemeSatellite.documentation_root}/managing_security_compliance/Configuring_SCAP_Contents_security-compliance",
'tailoring-xccdf-profiles_security-compliance' => "#{ForemanThemeSatellite.documentation_root}/managing_security_compliance/Configuring_SCAP_Contents_security-compliance#tailoring-xccdf-profiles_security-compliance",
'deploying-compliance-policies_security-compliance' => "#{ForemanThemeSatellite.documentation_root}/managing_security_compliance/compliance-policy-deployment-options_security-compliance",
'Monitoring_Compliance_security-compliance' => "#{ForemanThemeSatellite.documentation_root}/managing_security_compliance/monitoring_compliance_security-compliance",
'Managing_Compliance_Policies_security-compliance' => "#{ForemanThemeSatellite.documentation_root}/managing_security_compliance/managing_compliance_policies_security-compliance",
'Configuring_SCAP_Contents_security-compliance' => "#{ForemanThemeSatellite.documentation_root}/managing_security_compliance/configuring_scap_contents_security-compliance",
'tailoring-xccdf-profiles_security-compliance' => "#{ForemanThemeSatellite.documentation_root}/managing_security_compliance/configuring_scap_contents_security-compliance#tailoring-xccdf-profiles_security-compliance",
'deploying-compliance-policies_security-compliance' => "#{ForemanThemeSatellite.documentation_root}/managing_security_compliance/deploying-compliance-policies_security-compliance",
}.freeze

PLUGINS_DOCUMENTATION = {
Expand All @@ -78,7 +78,7 @@ module Documentation
}.freeze

SPECIAL_LINKS = [
[/docs\.theforeman\.org\/.*?\/Managing_Hosts\/.*?registering-a-host.*?managing-hosts/i, "#{ForemanThemeSatellite.documentation_root}/managing_hosts/registering_hosts_to_server_managing-hosts#Registering_Hosts_managing-hosts"],
[/docs\.theforeman\.org\/.*?\/Managing_Hosts\/.*?registering-a-host.*?managing-hosts/i, "#{ForemanThemeSatellite.documentation_root}/managing_hosts/registering_hosts_to_server_managing-hosts#Registering_Hosts_by_Using_Global_Registration_managing-hosts"],
]

DOCS_GUIDES_LINKS = {
Expand Down
34 changes: 24 additions & 10 deletions lib/tasks/foreman_theme_satellite_tasks.rake
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
require 'rake/testtask'

# Tasks
namespace :foreman_theme_satellite do
namespace :example do
desc 'Example Task'
task task: :environment do
# Task goes here
end
end
end

# Tests
namespace :test do
desc 'Test ForemanThemeSatellite'
Expand Down Expand Up @@ -38,6 +28,30 @@ namespace :foreman_theme_satellite do

Rake::Task['rubocop_foreman_theme_satellite'].invoke
end

desc 'Validate documentation links against given TOC file'
task :validate_docs do
toc_file = ENV['TOC']
unless toc_file
toc_file = File.expand_path('../../test/fixtures/toc.json', __dir__)
puts "Using default TOC: #{toc_file}, to override please specify TOC=<toc_file>"
end

require_relative '../../test/link_checker'
checker = LinksChecker.new(toc: toc_file)

require_relative '../foreman_theme_satellite/documentation'

all_links = ForemanThemeSatellite::Documentation::USER_GUIDE_DICTIONARY
.merge(ForemanThemeSatellite::Documentation::PLUGINS_DOCUMENTATION)
.merge(Hash[ForemanThemeSatellite::Documentation::SPECIAL_LINKS])

failed = all_links.filter { |_key, doc_address| !doc_address.include?('/html/') && checker.test_link(doc_address) }

abort((failed.map { |key, doc_address| "FAILED: Cannot find #{doc_address} in TOC for entry: #{key}" } + ["Total failed: #{failed.count} entries"]).join("\n")) unless failed.empty?

puts "Successfully tested #{all_links.count} links"
end
end

Rake::Task[:test].enhance ['test:foreman_theme_satellite']
Expand Down
Loading

0 comments on commit 06a3169

Please sign in to comment.