Skip to content

submit pr on versioned docs when build fails #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 6, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 27 additions & 9 deletions versioned_plugins.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down