Skip to content

Add check-images script to pdf build - #481

Open
TylerZeroMaster wants to merge 3 commits into
mainfrom
CORE-4493-prince-check-images
Open

TylerZeroMaster wants to merge 3 commits into
mainfrom
CORE-4493-prince-check-images

Conversation

@TylerZeroMaster

Copy link
Copy Markdown
Contributor

https://openstax.atlassian.net/browse/CORE-4493

Add a script that PrinceXML runs. It reports if any images are missing from the box model or if they have dimensions 0x0. The build fails if any are found.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The image check incorrectly rejects images intentionally hidden by print CSS, including by ancestors, causing valid PDF builds to fail.

2 open issues
What changed in this PR

This PR adds image validation to the PrinceXML PDF build, aiming to fail builds when images are missing from the rendered layout or have zero width or height.

Changes:

  • Add a script that checks image layout boxes after rendering and flags failures.
  • Run the script during PDF generation.
  • Include the script in the Docker image.
File Description
dockerfiles/​steps/​step-pdf.bash Pass the image-validation script to PrinceXML.
dockerfiles/​check-images.js Detect missing or zero-size image boxes and mark rendering as failed.
Dockerfile Copy the validation script into the container.

Review effort: Balanced

Comment thread dockerfiles/check-images.js Resolved
Comment thread dockerfiles/steps/step-pdf.bash Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Both regression tests accept any nonzero exit status without checking the expected diagnostic, so unrelated failures can pass without verifying image-checker behavior.

1 open issue
2 resolved since last review

Review effort: Balanced

Comment thread test/test-step-02.bash
Comment on lines +139 to +146
expect_step_pdf_failure() {
image_case="$1"
if SKIP_DOCKER_BUILD=1 \
../enki --keep-data --data-dir "$BOOK_DIR" --command step-pdf --repo 'philschatz/tiny-book' --ref long-lived-branch-for-testing-with-#-char; then
echo "Expected step-pdf to fail for the $image_case image case"
exit 1
fi
}

@jivey jivey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That copilot comment about the non-print branch seems interesting, though I'm not very familiar with this, so let me know if I should re-review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants