Skip to content

Comments

Fix CI collection error and improve build hygiene#63

Open
heidi-dang wants to merge 3 commits intomainfrom
fix-ci-collection-error-5516841422681149426
Open

Fix CI collection error and improve build hygiene#63
heidi-dang wants to merge 3 commits intomainfrom
fix-ci-collection-error-5516841422681149426

Conversation

@heidi-dang
Copy link
Owner

This PR fixes a recurring CI failure in GitHub Actions where the macos-latest runner fails with Exit Code 2 during test collection. The failure was caused by an unconditional import heidi_cpp in tests/test_core_integration.py while the C++ extension is only built on Linux.

Changes:

  1. Tests: Modified tests/test_core_integration.py to use pytest.importorskip("heidi_cpp"). This allows pytest to gracefully skip the module during collection if the extension is not found, matching the intended behavior on non-Linux platforms.
  2. Git Hygiene: Updated .gitignore to include C++ build artifacts (build/, *.so, *.o, etc.) to prevent accidental commits and maintain repository cleanliness.
  3. Code Quality: Refactored heidi_engine/state_machine.py to use datetime.now(timezone.utc) instead of the deprecated datetime.utcnow(), resolving several deprecation warnings observed during test execution.

Verified locally by running pytest -v both with and without the C++ extension built.


PR created automatically by Jules for task 5516841422681149426 started by @heidi-dang

…ension is missing

- Use `pytest.importorskip("heidi_cpp")` in `tests/test_core_integration.py` to handle missing C++ extension.
- Update `.gitignore` to ignore C++ build artifacts (`build/`, `*.so`, etc.).
- Replace deprecated `datetime.utcnow()` with `datetime.now(timezone.utc)` in `heidi_engine/state_machine.py`.
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@gemini-code-assist
Copy link

Summary of Changes

Hello @heidi-dang, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly improves the project's stability and maintainability. It eliminates a persistent CI failure on macOS by making test collection more robust to platform-specific dependencies. Additionally, it cleans up the repository by ignoring C++ build outputs and updates core code to use modern, timezone-aware datetime practices, resolving deprecation warnings and enhancing overall code quality.

Highlights

  • CI Stability: Resolved a recurring CI failure on macos-latest runners by modifying tests/test_core_integration.py to use pytest.importorskip("heidi_cpp"), ensuring tests gracefully skip the C++ extension when not available.
  • Build Hygiene: Enhanced repository cleanliness by updating .gitignore to include common C++ build artifacts such as build/, *.so, *.o, *.obj, *.dll, and *.dylib.
  • Code Quality: Addressed deprecation warnings by refactoring heidi_engine/state_machine.py to replace datetime.utcnow() with datetime.now(timezone.utc) for timezone-aware datetime objects.
Changelog
  • .gitignore
    • Added new entries to ignore C++ build directories and artifact files like .so, .o, .obj, .dll, and .dylib.
  • heidi_engine/state_machine.py
    • Imported the timezone object from the datetime module.
    • Replaced all instances of datetime.utcnow() with datetime.now(timezone.utc) to use timezone-aware datetime objects.
  • tests/test_core_integration.py
    • Modified the import statement for heidi_cpp to use heidi_cpp = pytest.importorskip("heidi_cpp"), allowing tests to be skipped if the module is not available.
Activity
  • The pull request was automatically created by Jules for task 5516841422681149426, initiated by @heidi-dang.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@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

The pull request successfully addresses the CI collection failures on macOS by using pytest.importorskip for the C++ extension and improves build hygiene with updated .gitignore rules. The transition to datetime.now(timezone.utc) in state_machine.py is a positive step towards modernizing the codebase, although it introduces a minor inconsistency in timestamp formatting compared to other parts of the system and some redundant logic in state initialization.

Comment on lines 166 to 167
"started_at": datetime.now(timezone.utc).isoformat(),
"updated_at": datetime.now(timezone.utc).isoformat(),

Choose a reason for hiding this comment

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

medium

The switch to datetime.now(timezone.utc).isoformat() correctly avoids the deprecation of utcnow(), but it changes the string format by adding a timezone offset (e.g., +00:00). This creates an inconsistency with heidi_engine/telemetry.py, which still uses the offset-less utcnow() format, leading to mixed timestamp styles in state.json. Consider updating telemetry.py as well or using .replace(tzinfo=None) to maintain the existing format. Additionally, calling now() twice here is redundant, particularly as _persist() (called on line 169) will immediately overwrite updated_at with a new timestamp.

- Fix CI collection error by skipping `heidi_cpp` and `heidid` tests when components are missing.
- Add `setpgid(0, 0)` in `subprocess.cpp` to correctly support `killpg` for timeouts.
- Fix use-after-free risk in `Daemon` by using joinable thread and atomic flag.
- Replace deprecated `datetime.utcnow()` with `datetime.now(timezone.utc)` codebase-wide.
- Update `.gitignore` to include C++ build artifacts.
- Fix CI collection error by skipping `heidi_cpp` and `heidid` tests when components are missing.
- Add `setpgid(0, 0)` in `subprocess.cpp` to correctly support `killpg` for timeouts.
- Fix use-after-free risk in `Daemon` by using joinable thread and atomic flag.
- Replace deprecated `datetime.utcnow()` with `datetime.now(timezone.utc)` and standardized on ISO8601 with `Z` suffix and millisecond precision.
- Update `.gitignore` to include C++ build artifacts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant