Skip to content

Travis CI build does not fail on Asciidoctor warning #1491

Closed
@HonkingGoose

Description

@HonkingGoose

Executive summary/TL:DR:

The current rake script cannot fail the build on Asciidoctor warnings/errors. We cannot use the version of Asciidoctor we're currently using, because that does not have the necessary flag (--failure-level=LEVEL. This flag is available from Asciidoctor 1.5.7.0, but using >1.5.7.0 version without further changes to the book will break cross-reference links.

Proposed way to resolve this:

  • Update to Asciidoctor 2.0.10 in Switch to asciidoctor 2.0.10 #1373
  • Run Asciidoctor migration script from @jnavilla.
  • Speed up build error feedback time by using the fast html build first. Only build the epub, mobi and pdf files if the html build passes.

Which version of the book is affected?

Problem is with the Travis CI, source code on master.

Describe the bug:

The Travis CI build is passing, while the output of build log contains warnings from Asciidoctor build

The Travis CI build should fail when Asciidoctor logs a warning when running bundle exec rake book:build.

Steps to reproduce:

  1. Open pull request with a Asciidoctor style error, like missing a newline before a unordered list (Example: Create section: branch renaming #1476 pull request).
  2. Travis CI runs bundle exec rake book:build.
  3. Asciidoctor logs a WARNING.
  4. Travis CI passes.
  5. GitHub lets you merge bad stuff.

Expected behavior:

  1. Open pull request with a Asciidoctor style error, like missing a newline before a unordered list (Example: Create section: branch renaming #1476 pull request).
  2. Travis CI runs bundle exec rake book:build.
  3. Asciidoctor logs a WARNING.
  4. Warning is caught by the Travis CI in some way.
  5. Travis CI fails.
  6. GitHub stop your from merging bad stuff because the test is failing.

Additional context:

I noticed that pull #1490 is fixing something that should not have been allowed past the Travis CI build.

Example of a build which has a Asciidoctor warning but a passing Travis CI build:
https://travis-ci.org/github/progit/progit2/builds/718311991
Line 319 has the first warning (it issues the same warning 3 times):

asciidoctor: WARNING: book/03-git-branching/sections/branch-management.asc: line 80: invalid style for listing block: CAUTION

My research into a possible fix:

I found out that Asciidoctor gained the ability to error out on a given failure level (asciidoctor/asciidoctor#2003):

From Asciidoctor manual about processing

--failure-level=LEVEL
The minimum logging level that triggers a non-zero exit code (failure). If this option is not set (default: FATAL), the program exits with exit code zero even if warnings or errors have been logged.

From the Asciidoctor user manual, handle missing or undefined attributes

If you want the processor to fail when the document contains a missing attribute, set the attribute-missing attribute to warn and pass the --failure-level=WARN option to the processor.

From the Asciidoctor user manual Appendix D: Application messages

ERROR Errors do not stop conversion, but the output document will almost certainly be wrong.
FAILURE Failures are fatal; no output document will be produced.
WARNING Warnings do not stop conversion, but they indicate possible problems, and the output may not be what you were expecting.


Attempt at fixing this:

WARNINGS:

It might be possible to fix this, by letting Asciidoctor fail when the .html build of the book contains errors.
⚠️ Do not change the params variable in the rake file, as that applies to all 4 of the builds.
🐛 The asciidoctor-pdf program may not use the logger: asciidoctor/asciidoctor#2003 (comment) and may crash when using --failure-level=WARN.


I would first try changing this line into:

bundle exec asciidoctor --failure-level=WARN --attribute revnumber='#{version_string}' --attribute revdate='#{date_string} -a data-uri progit.asc

and see where that gets us.

I couldn't find a --failure-level=ERROR in the official documentation, this was mentioned here though: asciidoctor/asciidoctor#2003 (comment). So it might exist, or it might not exist.


Alternatively, you can also close this issue as wont-fix. That's also OK. I wanted to flag the issue, so that the maintainer can decide on what to do. 👍

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions