Skip to content

Rework input paths parsing, add Windows CI #8

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

Merged
merged 1 commit into from
Feb 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions .github/workflows/ci-windows.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# NOTE: In contrast to Linux and macOS, the Windows build machines do not have Chrome installed.

name: "HTML2PDF on Windows"

# FIXME: Disabled until WDM detects Chrome on Windows reliably.
# on:
# pull_request:
# branches: [ "**" ]
on:
pull_request:
branches: [ "**" ]

jobs:
build:
Expand All @@ -21,6 +22,26 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install Google Chrome
run: |
choco install googlechrome --no-progress -y
shell: powershell

- name: Check Chrome Version
run: '& "C:\Program Files\Google\Chrome\Application\chrome.exe" --version'
shell: powershell

- name: Add Chrome to PATH
run: |
$chromePath = "C:\Program Files\Google\Chrome\Application"
echo "Adding $chromePath to PATH"
echo "$chromePath" | Out-File -Append -Encoding utf8 $env:GITHUB_PATH
shell: powershell

- name: Verify Chrome Installation
run: chrome --version
shell: powershell

- name: Upgrade pip
run: |
python -m pip install --upgrade pip
Expand Down
7 changes: 5 additions & 2 deletions hpdf/hpdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,11 @@ def exit_handler():
print("html2pdf: exit handler: quitting the ChromeDriver.") # noqa: T201
driver.quit()

for separate_path_pair_ in paths:
path_to_input_html, path_to_output_pdf = separate_path_pair_.split(":")
assert len(paths) % 2 == 0, f"Expecting an even number of input/output path arguments: {paths}."
for current_pair_idx in range(0, 2, len(paths)):
path_to_input_html = paths[current_pair_idx]
path_to_output_pdf = paths[current_pair_idx + 1]

assert os.path.isfile(path_to_input_html), path_to_input_html

path_to_output_pdf_dir = os.path.dirname(path_to_output_pdf)
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/01_hello_world/test.itest
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RUN: %html2pdf %S/index.html:%S/Output/index.pdf
RUN: %html2pdf %S/index.html %S/Output/index.pdf

RUN: %check_exists --file "%S/Output/index.pdf"
RUN: python %S/test.py
2 changes: 1 addition & 1 deletion tests/integration/02_two_pages/test.itest
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RUN: %html2pdf %S/index.html:%S/Output/index.pdf
RUN: %html2pdf %S/index.html %S/Output/index.pdf

RUN: %check_exists --file "%S/Output/index.pdf"
RUN: python %S/test.py
4 changes: 2 additions & 2 deletions tests/integration/03_cache_dir_argument/test.itest
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
RUN: %html2pdf --cache-dir %S/Output/cache %S/index.html:%S/Output/index.pdf | filecheck %s --dump-input=fail --check-prefix CHECK-RUN1
RUN: %html2pdf --cache-dir %S/Output/cache %S/index.html %S/Output/index.pdf | filecheck %s --dump-input=fail --check-prefix CHECK-RUN1
RUN: %check_exists --file "%S/Output/index.pdf"
RUN: python %S/test.py

CHECK-RUN1: html2pdf: ChromeDriver does not exist in the local cache:

RUN: %html2pdf --cache-dir %S/Output/cache %S/index.html:%S/Output/index.pdf | filecheck %s --dump-input=fail --check-prefix CHECK-RUN2
RUN: %html2pdf --cache-dir %S/Output/cache %S/index.html %S/Output/index.pdf | filecheck %s --dump-input=fail --check-prefix CHECK-RUN2
RUN: %check_exists --file "%S/Output/index.pdf"
RUN: python %S/test.py

Expand Down