Skip to content

Commit 970151c

Browse files
authored
chore(tasks): prepare the fuzzing job for scheduled runs (#57)
* chore(ruff.toml): remove obsolete UP038 check * chore(tasks): prepare the fuzzing job for scheduled runs
1 parent 023dd32 commit 970151c

File tree

3 files changed

+34
-16
lines changed

3 files changed

+34
-16
lines changed

.github/workflows/ci_fuzz_linux.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ name: "HTML2PDF4Doc Fuzz Testing on Linux"
33
on:
44
pull_request:
55
branches: [ "**" ]
6+
schedule:
7+
- cron: "00 00 * * *"
68

79
jobs:
810
build:

ruff.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ ignore = [
8282
"PLR5501",
8383

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

8887
# Avoid trying to fix flake8-bugbear (`B`) violations.

tasks.py

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import json
55
import os
66
import re
7+
import subprocess
78
import sys
89
from pathlib import Path
910
from typing import Optional
@@ -200,13 +201,16 @@ def test_integration(
200201

201202

202203
@task(aliases=["tf"])
203-
def test_fuzz(context):
204+
def test_fuzz(context, long: bool = False):
205+
arg_long = "--long" if long else ""
206+
204207
run_invoke(
205208
context,
206-
"""
209+
f"""
207210
python html2pdf4doc/html2pdf4doc_fuzzer.py
208211
tests/fuzz/01_strictdoc_guide_202510/strictdoc/docs/strictdoc_01_user_guide-PDF.html
209212
tests/fuzz/01_strictdoc_guide_202510/
213+
{arg_long}
210214
""",
211215
)
212216

@@ -355,16 +359,25 @@ def _is_full_ci_test() -> bool:
355359
Returns True if the tag is found in PR body/title or commit message.
356360
Returns False for local runs or when tag not found.
357361
"""
362+
363+
if "@full_test" in _get_last_commit_message_or_empty():
364+
print("[is_full_ci_test] @full_test found in the last commit message.") # noqa: T201
365+
return True
366+
358367
event_name = os.getenv("GITHUB_EVENT_NAME")
359368
event_path = os.getenv("GITHUB_EVENT_PATH")
360369

361-
# No GitHub env (e.g. local run)
370+
# No GitHub env (e.g. local run).
362371
if not event_name or not event_path or not Path(event_path).exists():
363372
print( # noqa: T201
364373
"[is_full_ci_test] No GitHub environment detected — running in local mode."
365374
)
366375
return False
367376

377+
if event_name == "schedule":
378+
"[is_full_ci_test] Detected scheduled run."
379+
return True
380+
368381
try:
369382
with open(event_path, encoding="utf-8") as f:
370383
event = json.load(f)
@@ -376,25 +389,29 @@ def _is_full_ci_test() -> bool:
376389

377390
tag = "@full_test"
378391

379-
# Check PR body/title
392+
# Check PR body.
380393
if event_name == "pull_request":
381394
pr = event.get("pull_request", {})
382395
body = (pr.get("body") or "").lower()
383-
title = (pr.get("title") or "").lower()
384-
if tag in body or tag in title:
385-
print( # noqa: T201
386-
"[is_full_ci_test] Detected @full_test in PR body/title."
387-
)
388-
return True
389396

390-
# Check commit message
391-
if event_name == "push":
392-
commit_msg = (event.get("head_commit", {}).get("message") or "").lower()
393-
if tag in commit_msg:
397+
if tag in body:
394398
print( # noqa: T201
395-
"[is_full_ci_test] Detected @full_test in commit message."
399+
"[is_full_ci_test] Detected @full_test in PR title."
396400
)
397401
return True
398402

399403
print("[is_full_ci_test] @full_test not found.") # noqa: T201
400404
return False
405+
406+
407+
def _get_last_commit_message_or_empty() -> str:
408+
try:
409+
result = subprocess.run(
410+
["git", "log", "-1", "--pretty=%B"],
411+
capture_output=True,
412+
text=True,
413+
check=True,
414+
)
415+
return result.stdout.strip().lower()
416+
except Exception:
417+
return ""

0 commit comments

Comments
 (0)