From 53ab1c7df8b77cb1f57ded27369735ea5af4ab37 Mon Sep 17 00:00:00 2001 From: Joao Duarte Date: Fri, 6 Jul 2018 09:59:29 +0100 Subject: [PATCH] submit pr on versioned docs when build fails Currently the versioned docs build script will compile the new docs, test them, and either: - abort the build if the test fails - submit a PR if the test passes Now that we have some confidence in the process (the build has been producing PRs for the past two months), this commit changes the behaviour to: - submit a PR if the test fails - commit directly if the test passes This way someone can manual fix the broken documentation directly in the PR instead of having to reproduce the failure locally. --- versioned_plugins.rb | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/versioned_plugins.rb b/versioned_plugins.rb index bdf3490..4f5b685 100644 --- a/versioned_plugins.rb +++ b/versioned_plugins.rb @@ -14,7 +14,7 @@ class VersionedPluginDocs < Clamp::Command option "--latest-only", :flag, "Only generate documentation for latest version of each plugin", :default => false option "--repair", :flag, "Apply several heuristics to correct broken documentation", :default => false option "--plugin-regex", "REGEX", "Only generate if plugin matches given regex", :default => "logstash-(?:codec|filter|input|output)" - option "--submit-pr", :flag, "Create a PR against logstash-docs after generation", :default => false + option "--dry-run", :flag, "Don't create a commit or pull request against logstash-docs", :default => false option "--test", :flag, "Clone docs repo and test generated docs", :default => false PLUGIN_SKIP_LIST = [ @@ -37,8 +37,23 @@ def execute clone_docs_repo generate_docs if new_versions? - test_docs if test? - submit_pr if submit_pr? + if test? + exit_status = test_docs + if exit_status == 0 # success + puts "success!" + else + puts "failed to build docs :(" + unless dry_run? + puts "submitting PR for manual fixing." + submit_pr + end + exit exit_status + end + end + unless dry_run? + puts "commiting to logstash-docs" + commit + end else puts "No new versions detected. Exiting.." end @@ -143,17 +158,20 @@ def submit_pr "auto generated update of versioned plugin documentation", "") end + def commit + Dir.chdir(logstash_docs_path) do |path| + `git checkout versioned_plugin_docs` + `git add .` + `git commit -m "updated versioned plugin docs" -a` + `git push origin versioned_plugin_docs` + end + end + def test_docs puts "Cloning Docs repository" `git clone --depth 1 https://github.com/elastic/docs #{docs_path}` puts "Running docs build.." `perl #{docs_path}/build_docs.pl --doc #{logstash_docs_path}/docs/versioned-plugins/index.asciidoc --chunk 1` - if $?.success? - puts "success!" - else - puts "failed to build docs. terminating" - exit $?.exitstatus - end end def fetch_doc(repo, tag)