-
Notifications
You must be signed in to change notification settings - Fork 2k
Refactor book:build task #1598
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
Refactor book:build task #1598
Conversation
This preliminary commit move build-related variables from :build task out to :book namespace. Such variables will be referenced by each generating tasks. Signed-off-by: Bagas Sanjaya <[email protected]>
For each formats, including currently unsupported Mobi format, extract from :build task. Signed-off-by: Bagas Sanjaya <[email protected]>
This file task is required to build books. Signed-off-by: Bagas Sanjaya <[email protected]>
The default task is now empty, so we can simply list its dependency tasks. Signed-off-by: Bagas Sanjaya <[email protected]>
Clean all generated artifacts (contributors list and book formats). Signed-off-by: Bagas Sanjaya <[email protected]>
As suggested by @jnavila. Check only HTML and epub books. As before this refactor, default book:build task also check them. Signed-off-by: Bagas Sanjaya <[email protected]>
Instead of invoking :check as dependency, explicitly invoke it inside the body of :build. As suggested by @jnavila, any errors raised from :check should not cause FTBFS, thus ignore them. Signed-off-by: Bagas Sanjaya <[email protected]>
As suggested by @jnavila. Similar to :build, but don't ignore any errors. Signed-off-by: Bagas Sanjaya <[email protected]>
Signed-off-by: Bagas Sanjaya <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think of these changes?
Apply suggestions from @HonkingGoose: - README rewording - FIXME line fitting on Rakefile Co-authored-by: HonkingGoose <[email protected]>
review ping |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for proposing. These are mostly style comments.
As per code review, @jnavila reported an error that requires begin/end block for multiline rescue body. Signed-off-by: Bagas Sanjaya <[email protected]>
As per code review by @jnavila Signed-off-by: Bagas Sanjaya <[email protected]>
As requested by @jnavila in code review. Signed-off-by: Bagas Sanjaya <[email protected]>
In order to check contributors list by commit hash, the hash have to be added to the list. Signed-off-by: Bagas Sanjaya <[email protected]>
…it hash As requested by @jnavila in code review. Compare current HEAD commit hash against the hash stored in the header of contributors list. If these match, go on. If not, refresh (rm and generate contributors list again). Signed-off-by: Bagas Sanjaya <[email protected]>
As to be consistent with other non-interpolated strings. Signed-off-by: Bagas Sanjaya <[email protected]>
…sk-refactor Signed-off-by: Bagas Sanjaya <[email protected]>
review ping |
Rakefile
Outdated
# Check contributors list | ||
# This checks commit hash stored in the header of list against current HEAD | ||
def check_contrib | ||
if File.exist?('book/contributors.txt') | ||
current_head_hash = `git rev-parse --short HEAD`.strip | ||
header = `head -n 1 book/contributors.txt`.strip | ||
# Match regex, then coerce resulting array to string by join | ||
header_hash = header.scan(/[a-f0-9]{7,}/).join | ||
|
||
if header_hash == current_head_hash | ||
puts "Hash on header of contributors list (#{header_hash}) matches the current HEAD (#{current_head_hash})" | ||
else | ||
puts "Hash on header of contributors list (#{header_hash}) does not match the current HEAD (#{current_head_hash}), refreshing" | ||
`rm book/contributors.txt` | ||
# Reenable and invoke task again | ||
Rake::Task['book/contributors.txt'].reenable | ||
Rake::Task['book/contributors.txt'].invoke | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Check contributors list | |
# This checks commit hash stored in the header of list against current HEAD | |
def check_contrib | |
if File.exist?('book/contributors.txt') | |
current_head_hash = `git rev-parse --short HEAD`.strip | |
header = `head -n 1 book/contributors.txt`.strip | |
# Match regex, then coerce resulting array to string by join | |
header_hash = header.scan(/[a-f0-9]{7,}/).join | |
if header_hash == current_head_hash | |
puts "Hash on header of contributors list (#{header_hash}) matches the current HEAD (#{current_head_hash})" | |
else | |
puts "Hash on header of contributors list (#{header_hash}) does not match the current HEAD (#{current_head_hash}), refreshing" | |
`rm book/contributors.txt` | |
# Reenable and invoke task again | |
Rake::Task['book/contributors.txt'].reenable | |
Rake::Task['book/contributors.txt'].invoke | |
end | |
end | |
end | |
# Check contributors list | |
# This checks the commit hash stored in the header of the list against the current HEAD | |
def check_contrib | |
if File.exist?('book/contributors.txt') | |
current_head_hash = `git rev-parse --short HEAD`.strip | |
header = `head -n 1 book/contributors.txt`.strip | |
# Match regex, then coerce resulting array to string by join | |
header_hash = header.scan(/[a-f0-9]{7,}/).join | |
if header_hash == current_head_hash | |
puts "Hash on header of contributors list (#{header_hash}) matches the current HEAD (#{current_head_hash})" | |
else | |
puts "Hash on header of contributors list (#{header_hash}) does not match the current HEAD (#{current_head_hash}), refreshing" | |
`rm book/contributors.txt` | |
# Re-enable and invoke task again | |
Rake::Task['book/contributors.txt'].reenable | |
Rake::Task['book/contributors.txt'].invoke | |
end | |
end | |
end |
Some small comment fixes.
The build is failing with syntax error. |
That line cause FTBFS on CI. It was forgotten to be deleted on previous commit, due to hurry. Signed-off-by: Bagas Sanjaya <[email protected]>
review ping |
It looks good to me. Thank you very much! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
progit/progit2#1598 Co-authored-by: Bagas Sanjaya <[email protected]>
progit/progit2#1598 Co-authored-by: Bagas Sanjaya <[email protected]>
Changes
This PR refactors monolithic
book:build
task into several smaller tasks:book/contributors.txt
file task: generates contributors list required to build book formatsbook:build_html
- build HTML formatbook:build_epub
- build Epub formatbook:build_pdf
- build PDF formatbook:check
- check HTML and EpubThis also add convenience tasks:
book:clean
- clean artifacts (contributors list and books)book:ci
- build books with checking enforced (not ignored), targeted for CI.Note: The CI doesn't execute
book:ci
, but still runningbook:build
instead. Discussions are welcome whether the CI should switch tobook:ci
or not.Context
Fixes #1595