Skip to content
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

Add session to generate screenshots from html #877

Merged
merged 20 commits into from Feb 16, 2024

Conversation

Spacetown
Copy link
Member

The used tool wkhtmltoimage was hard to get running on my Mac and I discovered that the tool can't handle CSS variables. The tool isn't developed any further and I searched for something else.
This PR adds a session to generate a JPEG from a HTML by using a server running a Chrome in a headless mode. The server needs to be started manually by the user if it's not started yet. The server wasn't able to provide PNG therefore I switched to JPEG.
I updated the docs and the examples that they fit together.

The used tool doesn't support CSS variables and isn't maintained anymore.
The screenshots are generated by a server running in a docker container
which uses a headless Chrome to render the HTML.
The examples generated the reports to STDOUT but in the docs the
filename used by the test was mentioned. Now the docs match to the call
in the shell script.

The test reads the original content before executing the test because
the test changes the content directly.
@Spacetown Spacetown added Docs related to the documentation or website QA related to testing, build infrastructure, etc labels Jan 28, 2024
@Spacetown Spacetown added this to the Upcoming release milestone Jan 28, 2024
@Spacetown Spacetown requested a review from latk January 28, 2024 00:31
@Spacetown
Copy link
Member Author

@latk Please can you check if this dependency is OK? I want to get rid of the manual capturing of the HTML for the documentation. Maybe we can try to capture the screenshots during the build of the documentation, if there is nothing changed in the HTML the file is binary identical.

Copy link

codecov bot commented Jan 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (1c0e1d5) 95.27% compared to head (2555c61) 95.30%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #877      +/-   ##
==========================================
+ Coverage   95.27%   95.30%   +0.03%     
==========================================
  Files          54       54              
  Lines        4525     4534       +9     
  Branches      893      893              
==========================================
+ Hits         4311     4321      +10     
  Misses        130      130              
+ Partials       84       83       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

doc/examples/example.sh Outdated Show resolved Hide resolved
doc/examples/example_csv.csv Outdated Show resolved Hide resolved
noxfile.py Outdated Show resolved Hide resolved
noxfile.py Outdated Show resolved Hide resolved
noxfile.py Outdated Show resolved Hide resolved
noxfile.py Outdated Show resolved Hide resolved
@latk
Copy link
Member

latk commented Jan 28, 2024

if this dependency is OK?

sure, wkhtml2pdf seems obsolete, and https://github.com/bedrockio/export-html looks OK (open source, easy to use via scripts)

The server needs to be started manually by the user if it's not started yet.

Not the biggest fan of this because that's a manual step. We already automatically build and launch Docker containers for tests, so starting the Chrome container automatically could make sense as well.

The server wasn't able to provide PNG therefore I switched to JPEG.

That's tolerable if there's no other way, but nice crisp PNGs would be nicer. The container's docs mention PNG export – what challenges did you encounter when using that feature?

if there is nothing changed in the HTML the file is binary identical.

If that's the case that's great. Previously, the screenshots would include metadata like the creation date (I think), which made it impossible to check if the screenshots were up to date.

@Spacetown Spacetown force-pushed the add_session_to_generate_png_from_html branch from 36bff53 to a0ec119 Compare January 28, 2024 21:18
@Spacetown Spacetown marked this pull request as draft January 28, 2024 21:27
- Generate screenshots if documentation isn't build in a container
- If documentation is generated in the pipeline fail if files are
  modified.
@Spacetown Spacetown force-pushed the add_session_to_generate_png_from_html branch 2 times, most recently from 2a8a69c to 765ac5a Compare February 2, 2024 21:40
@Spacetown Spacetown force-pushed the add_session_to_generate_png_from_html branch 2 times, most recently from 276a96c to 745e77f Compare February 2, 2024 23:18
@Spacetown Spacetown force-pushed the add_session_to_generate_png_from_html branch from 745e77f to 41f69fb Compare February 2, 2024 23:28
@Spacetown Spacetown marked this pull request as ready for review February 2, 2024 23:34
@Spacetown Spacetown merged commit 52c88f0 into gcovr:main Feb 16, 2024
27 checks passed
@Spacetown Spacetown deleted the add_session_to_generate_png_from_html branch February 16, 2024 14:00
@Spacetown Spacetown removed this from the Upcoming release milestone Feb 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs related to the documentation or website QA related to testing, build infrastructure, etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants