Add CI workflow, Dependabot, and testcontainers infrastructure#1
Add CI workflow, Dependabot, and testcontainers infrastructure#1
Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Fix E501 line-too-long violations across source, examples, and tests. Fix integration test auth by using explicit Secret.from_token credentials instead of relying on env vars. Fix serialization test to use env-var based secrets that support to_dict(). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary of ChangesHello, 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 establishes foundational project infrastructure by integrating Dependabot for automated dependency management and setting up a comprehensive CI workflow using GitHub Actions. It significantly enhances the testing environment by introducing Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Ignored Files
Using Gemini Code AssistThe 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
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 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. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces significant infrastructure improvements, including a CI workflow, Dependabot configuration, and a robust integration testing setup using testcontainers. The refactoring of tests to be self-contained is a great step towards reliability and ease of use. I've provided a couple of suggestions to further enhance the CI workflow's efficiency and to make the testcontainer setup more idiomatic.
| ```yaml | ||
| name: CI | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [main] | ||
| push: | ||
| branches: [main] | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| lint: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.13" | ||
| - run: pip install ruff | ||
| - run: ruff check . | ||
| - run: ruff format --check . | ||
|
|
||
| test: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.13" | ||
| - run: pip install -e ".[dev]" | ||
| - run: pytest tests/ --cov=haystack_integrations --cov-report=term-missing -v | ||
| ``` |
There was a problem hiding this comment.
The CI workflow can be improved for efficiency and reproducibility.
- Dependency Caching: To speed up workflow runs, you can enable pip dependency caching in the
setup-pythonaction. This will cache installed packages and reuse them in subsequent runs. - Reproducible Linting: The
lintjob currently installs the latest version ofrufffrom PyPI (pip install ruff). It's better to install dependencies from your project'spyproject.tomlto ensure the linter version is consistent with what's defined for the project. This prevents unexpected issues when a new version ofruffis released.
Here is a suggested update that incorporates these improvements and adds step names for clarity:
name: CI
on:
pull_request:
branches: [main]
push:
branches: [main]
workflow_dispatch:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13"
cache: 'pip'
- name: Install dependencies
run: pip install -e ".[dev]"
- name: Check linting
run: ruff check .
- name: Check formatting
run: ruff format --check .
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13"
cache: 'pip'
- name: Install dependencies
run: pip install -e ".[dev]"
- name: Run tests
run: pytest tests/ --cov=haystack_integrations --cov-report=term-missing -vThere was a problem hiding this comment.
Fixed in d0372b7. Added pip caching, step names, and switched lint job to install from .[dev] so ruff version stays consistent with the project.
| @pytest.fixture(scope="session") | ||
| def arcadedb_url(): | ||
| """Start an ArcadeDB container and yield its HTTP base URL.""" | ||
| container = ( | ||
| DockerContainer(ARCADEDB_IMAGE) | ||
| .with_exposed_ports(2480) | ||
| .with_env( | ||
| "JAVA_OPTS", | ||
| "-Darcadedb.server.rootPassword=arcadedb", | ||
| ) | ||
| ) | ||
| container.start() | ||
| _wait_for_ready(container) | ||
|
|
||
| host = container.get_container_host_ip() | ||
| port = container.get_exposed_port(2480) | ||
| yield f"http://{host}:{port}" | ||
|
|
||
| container.stop() |
There was a problem hiding this comment.
The custom _wait_for_ready function can be replaced by using the built-in waiting strategies from testcontainers. This makes the code more concise and idiomatic by leveraging the library's features for handling container readiness.
You can use Wait.for_http(...) to wait for the HTTP endpoint to be ready. With this change, you can also remove the _wait_for_ready function and the import time and import requests statements. You will need to add from testcontainers.core.wait import Wait.
| @pytest.fixture(scope="session") | |
| def arcadedb_url(): | |
| """Start an ArcadeDB container and yield its HTTP base URL.""" | |
| container = ( | |
| DockerContainer(ARCADEDB_IMAGE) | |
| .with_exposed_ports(2480) | |
| .with_env( | |
| "JAVA_OPTS", | |
| "-Darcadedb.server.rootPassword=arcadedb", | |
| ) | |
| ) | |
| container.start() | |
| _wait_for_ready(container) | |
| host = container.get_container_host_ip() | |
| port = container.get_exposed_port(2480) | |
| yield f"http://{host}:{port}" | |
| container.stop() | |
| @pytest.fixture(scope="session") | |
| def arcadedb_url(): | |
| """Start an ArcadeDB container and yield its HTTP base URL.""" | |
| container = ( | |
| DockerContainer(ARCADEDB_IMAGE) | |
| .with_exposed_ports(2480) | |
| .with_env( | |
| "JAVA_OPTS", | |
| "-Darcadedb.server.rootPassword=arcadedb", | |
| ) | |
| .with_waiting_for(Wait.for_http("/api/v1/ready", status_code=204, timeout=60)) | |
| ) | |
| container.start() | |
| host = container.get_container_host_ip() | |
| port = container.get_exposed_port(2480) | |
| yield f"http://{host}:{port}" | |
| container.stop() |
There was a problem hiding this comment.
Fixed in d0372b7. Replaced custom _wait_for_ready with testcontainers' built-in HttpWaitStrategy. Note: the suggested API (Wait.for_http()) doesn't exist in testcontainers-python — the actual API is HttpWaitStrategy(port, path).for_status_code(204).with_startup_timeout(60) with .waiting_for() on the container. All 26 tests pass.
Address code review feedback: - Add pip cache to setup-python steps - Install ruff from project deps for version consistency - Add step names for clarity - Replace custom _wait_for_ready with testcontainers HttpWaitStrategy Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
unittest.TestCaseto pytest functions using thearcadedb_urlsession fixturetestcontainers,docker,ruff(both[project.optional-dependencies]and hatch envs)Test plan
🤖 Generated with Claude Code