Skip to content

fix: downgrade python-ripgrep version to 0.0.8 in dependencies#7514

Merged
Soulter merged 2 commits intomasterfrom
fix/7496
Apr 13, 2026
Merged

fix: downgrade python-ripgrep version to 0.0.8 in dependencies#7514
Soulter merged 2 commits intomasterfrom
fix/7496

Conversation

@Soulter
Copy link
Copy Markdown
Member

@Soulter Soulter commented Apr 13, 2026

  • fix: downgrade python-ripgrep version to 0.0.8 in dependencies
  • fix: update smoke test workflow to support multiple OS and Python versions

Modifications / 改动点

  • This is NOT a breaking change. / 这不是一个破坏性变更。

Screenshots or Test Results / 运行截图或测试结果


Checklist / 检查清单

  • 😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
    / 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。

  • 👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
    / 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”

  • 🤓 I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in requirements.txt and pyproject.toml.
    / 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到 requirements.txtpyproject.toml 文件相应位置。

  • 😮 My changes do not introduce malicious code.
    / 我的更改没有引入恶意代码。

Summary by Sourcery

Update smoke test infrastructure for cross-platform, multi-version coverage and adjust a dependency version for compatibility.

Bug Fixes:

  • Downgrade the python-ripgrep dependency to 0.0.8 in both pyproject.toml and requirements.txt to resolve compatibility issues.

Enhancements:

  • Revise the smoke_test GitHub Actions workflow to run against a matrix of OSes and Python versions while caching pip installs.
  • Replace the inline shell-based smoke test with a new cross-platform Python startup check script that validates the health endpoint and captures logs for failures.

CI:

  • Extend the smoke test workflow to run on Linux, macOS, and Windows across multiple Python versions with improved dependency installation.

Tests:

  • Add a Python-based smoke_startup_check script to standardize and harden application startup smoke testing across environments.

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Apr 13, 2026
@Soulter Soulter changed the title fix/7496 fix: downgrade python-ripgrep version to 0.0.8 in dependencies Apr 13, 2026
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • The CI matrix includes Python 3.14, which is not yet generally available; consider limiting the matrix to released Python versions to avoid spurious workflow failures.
  • In scripts/smoke_startup_check.py, using tempfile.TemporaryDirectory as a context manager instead of mkdtemp plus manual cleanup would simplify lifecycle management and make it harder to leak temporary directories if the script is modified in the future.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The CI matrix includes Python `3.14`, which is not yet generally available; consider limiting the matrix to released Python versions to avoid spurious workflow failures.
- In `scripts/smoke_startup_check.py`, using `tempfile.TemporaryDirectory` as a context manager instead of `mkdtemp` plus manual cleanup would simplify lifecycle management and make it harder to leak temporary directories if the script is modified in the future.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Soulter Soulter merged commit afeda9b into master Apr 13, 2026
21 checks passed
@Soulter Soulter deleted the fix/7496 branch April 13, 2026 12:54
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request downgrades the python-ripgrep dependency to version 0.0.8 and introduces a new cross-platform smoke test script, scripts/smoke_startup_check.py, to verify the application's startup health. Feedback was provided to improve resource management in the smoke test script, specifically recommending the use of tempfile.TemporaryDirectory for more robust cleanup and the removal of redundant file unlinking.

Comment on lines +57 to +112
smoke_root = Path(tempfile.mkdtemp(prefix="astrbot-smoke-root-"))
env["ASTRBOT_ROOT"] = str(smoke_root)
log_path = smoke_root / "smoke.log"
webui_dir = smoke_root / "webui"
webui_dir.mkdir()
(webui_dir / "index.html").write_text(
"<!doctype html><title>AstrBot</title>",
encoding="utf-8",
)

with log_path.open("wb") as log_file:
proc = subprocess.Popen(
[
sys.executable,
str(REPO_ROOT / "main.py"),
"--webui-dir",
str(webui_dir),
],
cwd=REPO_ROOT,
stdout=log_file,
stderr=subprocess.STDOUT,
env=env,
)

print(f"Starting smoke test on {HEALTH_URL}")
deadline = time.monotonic() + STARTUP_TIMEOUT_SECONDS
try:
while time.monotonic() < deadline:
if _is_ready():
print("Smoke test passed")
return 0

return_code = proc.poll()
if return_code is not None:
print(
f"AstrBot exited before becoming healthy. Exit code: {return_code}",
file=sys.stderr,
)
print(_tail(log_path), file=sys.stderr)
return 1

time.sleep(1)

print(
"Smoke test failed: health endpoint did not become ready in time.",
file=sys.stderr,
)
print(_tail(log_path), file=sys.stderr)
return 1
finally:
_stop_process(proc)
try:
log_path.unlink()
except OSError:
pass
shutil.rmtree(smoke_root, ignore_errors=True)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current implementation of main has a few issues regarding resource management:

  1. If an exception occurs during setup (e.g., webui_dir.mkdir() fails or subprocess.Popen raises an error), the temporary directory will not be cleaned up because the try...finally block starts too late.
  2. The log_path.unlink() call is redundant as shutil.rmtree(smoke_root) is called immediately after.
  3. Using tempfile.TemporaryDirectory as a context manager is more idiomatic and ensures cleanup even if setup fails.

Consider refactoring the main function to use a context manager for the temporary directory and ensure the process is stopped in a finally block that covers the entire lifecycle.

    with tempfile.TemporaryDirectory(prefix="astrbot-smoke-root-") as smoke_root_str:
        smoke_root = Path(smoke_root_str)
        env["ASTRBOT_ROOT"] = str(smoke_root)
        log_path = smoke_root / "smoke.log"
        webui_dir = smoke_root / "webui"
        webui_dir.mkdir()
        (webui_dir / "index.html").write_text(
            "<!doctype html><title>AstrBot</title>",
            encoding="utf-8",
        )

        proc = None
        try:
            with log_path.open("wb") as log_file:
                proc = subprocess.Popen(
                    [
                        sys.executable,
                        str(REPO_ROOT / "main.py"),
                        "--webui-dir",
                        str(webui_dir),
                    ],
                    cwd=REPO_ROOT,
                    stdout=log_file,
                    stderr=subprocess.STDOUT,
                    env=env,
                )

            print(f"Starting smoke test on {HEALTH_URL}")
            deadline = time.monotonic() + STARTUP_TIMEOUT_SECONDS
            while time.monotonic() < deadline:
                if _is_ready():
                    print("Smoke test passed")
                    return 0

                return_code = proc.poll()
                if return_code is not None:
                    print(
                        f"AstrBot exited before becoming healthy. Exit code: {return_code}",
                        file=sys.stderr,
                    )
                    print(_tail(log_path), file=sys.stderr)
                    return 1

                time.sleep(1)

            print(
                "Smoke test failed: health endpoint did not become ready in time.",
                file=sys.stderr,
            )
            print(_tail(log_path), file=sys.stderr)
            return 1
        finally:
            if proc:
                _stop_process(proc)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant