Skip to content

Commit f0edc50

Browse files
authored
Rework input paths parsing, add Windows CI (#8)
Windows CI is very slow but at least it is working now.
1 parent 927c44c commit f0edc50

File tree

5 files changed

+34
-10
lines changed

5 files changed

+34
-10
lines changed

.github/workflows/ci-windows.yml

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
# NOTE: In contrast to Linux and macOS, the Windows build machines do not have Chrome installed.
2+
13
name: "HTML2PDF on Windows"
24

3-
# FIXME: Disabled until WDM detects Chrome on Windows reliably.
4-
# on:
5-
# pull_request:
6-
# branches: [ "**" ]
5+
on:
6+
pull_request:
7+
branches: [ "**" ]
78

89
jobs:
910
build:
@@ -21,6 +22,26 @@ jobs:
2122
with:
2223
python-version: ${{ matrix.python-version }}
2324

25+
- name: Install Google Chrome
26+
run: |
27+
choco install googlechrome --no-progress -y
28+
shell: powershell
29+
30+
- name: Check Chrome Version
31+
run: '& "C:\Program Files\Google\Chrome\Application\chrome.exe" --version'
32+
shell: powershell
33+
34+
- name: Add Chrome to PATH
35+
run: |
36+
$chromePath = "C:\Program Files\Google\Chrome\Application"
37+
echo "Adding $chromePath to PATH"
38+
echo "$chromePath" | Out-File -Append -Encoding utf8 $env:GITHUB_PATH
39+
shell: powershell
40+
41+
- name: Verify Chrome Installation
42+
run: chrome --version
43+
shell: powershell
44+
2445
- name: Upgrade pip
2546
run: |
2647
python -m pip install --upgrade pip

hpdf/hpdf.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,11 @@ def exit_handler():
265265
print("html2pdf: exit handler: quitting the ChromeDriver.") # noqa: T201
266266
driver.quit()
267267

268-
for separate_path_pair_ in paths:
269-
path_to_input_html, path_to_output_pdf = separate_path_pair_.split(":")
268+
assert len(paths) % 2 == 0, f"Expecting an even number of input/output path arguments: {paths}."
269+
for current_pair_idx in range(0, 2, len(paths)):
270+
path_to_input_html = paths[current_pair_idx]
271+
path_to_output_pdf = paths[current_pair_idx + 1]
272+
270273
assert os.path.isfile(path_to_input_html), path_to_input_html
271274

272275
path_to_output_pdf_dir = os.path.dirname(path_to_output_pdf)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
RUN: %html2pdf %S/index.html:%S/Output/index.pdf
1+
RUN: %html2pdf %S/index.html %S/Output/index.pdf
22

33
RUN: %check_exists --file "%S/Output/index.pdf"
44
RUN: python %S/test.py
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
RUN: %html2pdf %S/index.html:%S/Output/index.pdf
1+
RUN: %html2pdf %S/index.html %S/Output/index.pdf
22

33
RUN: %check_exists --file "%S/Output/index.pdf"
44
RUN: python %S/test.py

tests/integration/03_cache_dir_argument/test.itest

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
RUN: %html2pdf --cache-dir %S/Output/cache %S/index.html:%S/Output/index.pdf | filecheck %s --dump-input=fail --check-prefix CHECK-RUN1
1+
RUN: %html2pdf --cache-dir %S/Output/cache %S/index.html %S/Output/index.pdf | filecheck %s --dump-input=fail --check-prefix CHECK-RUN1
22
RUN: %check_exists --file "%S/Output/index.pdf"
33
RUN: python %S/test.py
44

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

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

0 commit comments

Comments
 (0)