Skip to content

Commit cfe2d53

Browse files
committed
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.
1 parent 6967d57 commit cfe2d53

File tree

1 file changed

+27
-9
lines changed

1 file changed

+27
-9
lines changed

versioned_plugins.rb

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class VersionedPluginDocs < Clamp::Command
1414
option "--latest-only", :flag, "Only generate documentation for latest version of each plugin", :default => false
1515
option "--repair", :flag, "Apply several heuristics to correct broken documentation", :default => false
1616
option "--plugin-regex", "REGEX", "Only generate if plugin matches given regex", :default => "logstash-(?:codec|filter|input|output)"
17-
option "--submit-pr", :flag, "Create a PR against logstash-docs after generation", :default => false
17+
option "--dry-run", :flag, "Don't create a commit or pull request against logstash-docs", :default => false
1818
option "--test", :flag, "Clone docs repo and test generated docs", :default => false
1919

2020
PLUGIN_SKIP_LIST = [
@@ -37,8 +37,23 @@ def execute
3737
clone_docs_repo
3838
generate_docs
3939
if new_versions?
40-
test_docs if test?
41-
submit_pr if submit_pr?
40+
if test?
41+
exit_status = test_docs
42+
if exit_status == 0 # success
43+
puts "success!"
44+
else
45+
puts "failed to build docs :("
46+
unless dry_run?
47+
puts "submitting PR for manual fixing."
48+
submit_pr
49+
end
50+
exit exit_status
51+
end
52+
end
53+
unless dry_run?
54+
puts "commiting to logstash-docs"
55+
commit
56+
end
4257
else
4358
puts "No new versions detected. Exiting.."
4459
end
@@ -143,17 +158,20 @@ def submit_pr
143158
"auto generated update of versioned plugin documentation", "")
144159
end
145160

161+
def commit
162+
Dir.chdir(logstash_docs_path) do |path|
163+
`git checkout versioned_plugin_docs`
164+
`git add .`
165+
`git commit -m "updated versioned plugin docs" -a`
166+
`git push origin versioned_plugin_docs`
167+
end
168+
end
169+
146170
def test_docs
147171
puts "Cloning Docs repository"
148172
`git clone --depth 1 https://github.com/elastic/docs #{docs_path}`
149173
puts "Running docs build.."
150174
`perl #{docs_path}/build_docs.pl --doc #{logstash_docs_path}/docs/versioned-plugins/index.asciidoc --chunk 1`
151-
if $?.success?
152-
puts "success!"
153-
else
154-
puts "failed to build docs. terminating"
155-
exit $?.exitstatus
156-
end
157175
end
158176

159177
def fetch_doc(repo, tag)

0 commit comments

Comments
 (0)