Skip to content
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
2 changes: 2 additions & 0 deletions .github/workflows/ci_fuzz_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: "HTML2PDF4Doc Fuzz Testing on Linux"
on:
pull_request:
branches: [ "**" ]
schedule:
- cron: "00 00 * * *"

jobs:
build:
Expand Down
1 change: 0 additions & 1 deletion ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ ignore = [
"PLR5501",

"UP035", # [*] Import from `collections.abc` instead: `Iterator`
"UP038", # [*] Use `X | Y` in `isinstance` call instead of `(X, Y)` (conflict with Pylint)
]

# Avoid trying to fix flake8-bugbear (`B`) violations.
Expand Down
47 changes: 32 additions & 15 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import json
import os
import re
import subprocess
import sys
from pathlib import Path
from typing import Optional
Expand Down Expand Up @@ -200,13 +201,16 @@ def test_integration(


@task(aliases=["tf"])
def test_fuzz(context):
def test_fuzz(context, long: bool = False):
arg_long = "--long" if long else ""

run_invoke(
context,
"""
f"""
python html2pdf4doc/html2pdf4doc_fuzzer.py
tests/fuzz/01_strictdoc_guide_202510/strictdoc/docs/strictdoc_01_user_guide-PDF.html
tests/fuzz/01_strictdoc_guide_202510/
{arg_long}
""",
)

Expand Down Expand Up @@ -355,16 +359,25 @@ def _is_full_ci_test() -> bool:
Returns True if the tag is found in PR body/title or commit message.
Returns False for local runs or when tag not found.
"""

if "@full_test" in _get_last_commit_message_or_empty():
print("[is_full_ci_test] @full_test found in the last commit message.") # noqa: T201
return True

event_name = os.getenv("GITHUB_EVENT_NAME")
event_path = os.getenv("GITHUB_EVENT_PATH")

# No GitHub env (e.g. local run)
# No GitHub env (e.g. local run).
if not event_name or not event_path or not Path(event_path).exists():
print( # noqa: T201
"[is_full_ci_test] No GitHub environment detected — running in local mode."
)
return False

if event_name == "schedule":
"[is_full_ci_test] Detected scheduled run."
return True

try:
with open(event_path, encoding="utf-8") as f:
event = json.load(f)
Expand All @@ -376,25 +389,29 @@ def _is_full_ci_test() -> bool:

tag = "@full_test"

# Check PR body/title
# Check PR body.
if event_name == "pull_request":
pr = event.get("pull_request", {})
body = (pr.get("body") or "").lower()
title = (pr.get("title") or "").lower()
if tag in body or tag in title:
print( # noqa: T201
"[is_full_ci_test] Detected @full_test in PR body/title."
)
return True

# Check commit message
if event_name == "push":
commit_msg = (event.get("head_commit", {}).get("message") or "").lower()
if tag in commit_msg:
if tag in body:
print( # noqa: T201
"[is_full_ci_test] Detected @full_test in commit message."
"[is_full_ci_test] Detected @full_test in PR title."
)
return True

print("[is_full_ci_test] @full_test not found.") # noqa: T201
return False


def _get_last_commit_message_or_empty() -> str:
try:
result = subprocess.run(
["git", "log", "-1", "--pretty=%B"],
capture_output=True,
text=True,
check=True,
)
return result.stdout.strip().lower()
except Exception:
return ""
Loading