Skip to content

Fix CI#546

Merged
chrisaddy merged 4 commits intomasterfrom
nix-ci
May 22, 2025
Merged

Fix CI#546
chrisaddy merged 4 commits intomasterfrom
nix-ci

Conversation

@chrisaddy
Copy link
Copy Markdown
Collaborator

@chrisaddy chrisaddy commented May 21, 2025

This pull request introduces significant updates to the CI/CD pipeline, Python dependency management, and Docker configurations to improve development workflows and testing processes. The key changes include switching to Docker-based testing, updating dependency management, and refining Dockerfile configurations for multiple services.

CI/CD and Testing Improvements:

  • Updated .github/workflows/test.yaml to simplify the CI workflow by removing the matrix strategy and hardcoding ubuntu-latest as the runner. This change also removes unused steps for installing dependencies.
  • Introduced a Dockerfile.test for running tests in a containerized environment, including dependency installation via uv sync --all-groups.
  • Added a tests service in compose.yaml for running Python tests with coverage reporting using Docker Compose.

Dependency Management:

  • Modified .mise.toml to use docker compose run tests for running Python tests and simplified the python:install task by removing the --all-packages flag. [1] [2]
  • Updated pyproject.toml to define a dev dependency group for development tools and added configuration for pytest and coverage.
  • Adjusted the requires-python version in pyproject.toml from >=3.13 to >=3.12 for broader compatibility.

Dockerfile Updates:

  • Refactored application/datamanager/Dockerfile and application/positionmanager/Dockerfile to align their configurations, including setting PYTHONPATH, copying source files to /app/src, and using uv sync --no-dev for dependency installation. [1] [2]
  • Updated exposed ports and refined the ENTRYPOINT commands to include the --app-dir flag for better structure. [1] [2]

Dependency Additions:

  • Added the datamanager dependency to the application/datamanager/pyproject.toml file.

Summary by CodeRabbit

  • New Features

    • Added a dedicated Docker Compose service and Dockerfile for running tests in a containerized environment.
    • Introduced a new development dependency group for streamlined setup of development tools and libraries.
  • Improvements

    • Simplified and unified test execution by running tests via Docker Compose.
    • Enhanced test coverage reporting with improved configuration and exclusion patterns.
    • Updated Dockerfiles for improved dependency management, environment variables, and entrypoints.
    • Lowered the minimum required Python version to 3.12 for broader compatibility.
  • Chores

    • Updated .gitignore to exclude additional coverage-related files and directories.

@chrisaddy chrisaddy self-assigned this May 21, 2025
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 21, 2025

Warning

Rate limit exceeded

@chrisaddy has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 4 minutes and 28 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 85ce3b8 and 2b134e6.

📒 Files selected for processing (7)
  • .github/workflows/test.yaml (1 hunks)
  • .mise.toml (2 hunks)
  • Dockerfile.test (1 hunks)
  • application/datamanager/Dockerfile (1 hunks)
  • application/datamanager/pyproject.toml (1 hunks)
  • compose.yaml (1 hunks)
  • pyproject.toml (2 hunks)

"""

Walkthrough

The changes introduce a Docker-based testing workflow, update development and test dependencies, and streamline configuration files. Python version requirements are adjusted, coverage and pytest settings are enhanced, and service Dockerfiles are refactored for clarity and consistency. The GitHub Actions workflow is simplified to run tests only on Ubuntu, while Docker Compose now supports a dedicated tests service.

Changes

File(s) Change Summary
.github/workflows/test.yaml Simplified workflow: removed matrix for OS testing, now runs only on Ubuntu; cleaned up dependency install steps.
.gitignore Added patterns to ignore additional coverage files and directories.
.mise.toml Simplified python:install task; replaced python:test task with a Docker Compose-based test run.
Dockerfile.test New file: Dockerfile for running tests, sets up Python 3.13, installs uv, configures pytest, and installs dependencies.
application/datamanager/Dockerfile
application/positionmanager/Dockerfile
Refactored Dockerfiles: set PYTHONPATH, updated dependency installation commands, changed source copy steps, updated entrypoints for uvicorn, and adjusted exposed ports (datamanager only).
application/datamanager/pyproject.toml Added "datamanager" to the dependencies list; lowered Python version requirement from 3.13 to 3.12.
compose.yaml Added a new tests service: builds from Dockerfile.test, mounts source, and runs tests with coverage reporting.
pyproject.toml Lowered required Python version to 3.12; added a [tool.pytest.ini_options] section and [tool.coverage.run] configuration; introduced a dev dependency group with development and test tools.

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant Docker Compose
    participant Test Container
    participant Coverage Tools

    Developer->>Docker Compose: Run `docker compose run tests`
    Docker Compose->>Test Container: Build & start with Dockerfile.test
    Test Container->>Test Container: Install dependencies (uv sync)
    Test Container->>Test Container: Set up pytest and coverage env vars
    Test Container->>Test Container: Run pytest with coverage
    Test Container->>Coverage Tools: Combine and report coverage
    Test Container->>Developer: Output coverage reports
Loading

Possibly related PRs

Suggested labels

application, bug

Suggested reviewers

  • forstmeier

Poem

🐇
In containers I now hop,
Running tests without a stop.
Compose and Docker, side by side,
With coverage files we now confide.
Python sings from twelve to three,
Dev tools join the jubilee!

— A jubilant rabbit in the code meadow
"""


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@chrisaddy chrisaddy force-pushed the nix-ci branch 9 times, most recently from a70a97e to 5532068 Compare May 21, 2025 16:36
@chrisaddy chrisaddy changed the title Nix CI Fix CI May 21, 2025
@chrisaddy chrisaddy force-pushed the nix-ci branch 2 times, most recently from 1ca1399 to 5263466 Compare May 21, 2025 16:59
@chrisaddy chrisaddy marked this pull request as ready for review May 21, 2025 16:59
@graphite-app graphite-app Bot requested a review from forstmeier May 21, 2025 16:59
set up nix for full ci/cd goodness

set up nix gha action for ci

removing nix
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🔭 Outside diff range comments (1)
.github/workflows/test.yaml (1)

29-29: ⚠️ Potential issue

Mismatch in coverage report filename
The tests service generates coverage.xml by default, but path-to-lcov is set to .python_coverage.xml. Coveralls won’t find the report as-is.

Please update path-to-lcov to coverage.xml or configure the test container to emit .python_coverage.xml.

🧹 Nitpick comments (8)
pyproject.toml (1)

29-43: Review runtime vs. dev dependency placement.
coverage and pytest appear in both the main dependencies array and the dev group. Consider removing testing tools from runtime dependencies to reduce production install size and potential attack surface.

Dockerfile.test (1)

8-9: Syncing all dependency groups for tests.
Copying just the pyproject.toml and running uv sync --all-groups ensures dev dependencies are available. Consider also copying a lock file for fully reproducible builds.

application/positionmanager/Dockerfile (1)

1-1: Optional: use python:3.13-slim for smaller images.
Switching to the full python:3.13 image works, but if no OS-level packages are required, using python:3.13-slim reduces image size and attack surface.

.mise.toml (2)

3-3: Suggest explicitly specifying dev dependency groups
The uv sync command now relies on default settings; consider adding --all-groups for clarity and to ensure dev dependencies (e.g., linters, test frameworks) are installed when running tasks locally.


30-30: Clean up test container after execution
When running docker compose run tests, adding the --rm flag will automatically remove stopped containers, preventing resource buildup over repeated runs.

compose.yaml (1)

9-16: Consider refactoring complex command
The multiline shell command under command could be moved into an entrypoint script in the image for readability, easier maintenance, and better layer caching.

application/datamanager/Dockerfile (1)

21-23: Remove commented-out legacy entrypoint
Consider deleting the commented-out ENTRYPOINT line to keep the Dockerfile clean, or relocate it into documentation if needed for historical reference.

.github/workflows/test.yaml (1)

7-13: Clean up commented-out matrix configuration
Keeping commented strategy lines can clutter the workflow. Remove them if cross-OS testing is no longer required.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 31eb7f7 and a78278c.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (9)
  • .github/workflows/test.yaml (1 hunks)
  • .gitignore (1 hunks)
  • .mise.toml (2 hunks)
  • Dockerfile.test (1 hunks)
  • application/datamanager/Dockerfile (1 hunks)
  • application/datamanager/pyproject.toml (1 hunks)
  • application/positionmanager/Dockerfile (1 hunks)
  • compose.yaml (1 hunks)
  • pyproject.toml (2 hunks)
🔇 Additional comments (20)
.gitignore (1)

9-12: Coverage files ignored to avoid VCS clutter.
The new ignore patterns .coverage*, .coverage/, coverage.xml, and .python_coverage.xml correctly prevent coverage artifacts from being checked in as part of the Dockerized test workflows.

pyproject.toml (3)

54-57: Coverage run configuration looks good.
Omitting __init__.py and test files with parallel mode is appropriate for accurate metrics.


58-61: Coverage reporting settings are sound.
show_missing and skip_covered will highlight gaps without overwhelming reports.


62-63: XML output target matches ignore rules.
Specifying .python_coverage.xml aligns with the .gitignore updates to prevent these files from being committed.

application/datamanager/pyproject.toml (1)

12-12: Verify the new self-dependency.
The service is adding "datamanager" to its own dependencies, which can create a cyclic or redundant requirement. If this is intended for workspace linking, confirm that it's correctly resolved by the build tool; otherwise, remove it.

Dockerfile.test (3)

1-2: Confirm base image and tool installation.
Using python:3.13 and copying uv from ghcr.io/astral-sh/uv:latest assumes the 3.13 tag exists on Docker Hub and that the uv binary is compatible. Please verify the availability of python:3.13 and test the uv binary in this environment.


4-4: Root directory for pytest set.
ENV PYTEST_ADDOPTS="--rootdir=/tests" aligns with /tests as the mounted working directory. Good for isolating test runs.


6-6: WORKDIR matches mount point.
Using /tests as both WORKDIR and mount path simplifies bind mounting in compose.yaml. No issues here.

application/positionmanager/Dockerfile (4)

4-5: Set PYTHONPATH for module resolution.
Defining ENV PYTHONPATH=/app/src ensures uv picks up the src directory. This follows the pattern in the datamanager service. Well done.


9-9: Sync only production dependencies.
Using uv sync --no-dev is correct for a production build to exclude dev tools.


11-11: Copy application source directory.
Changing from service-specific folders to a consistent ./src directory promotes uniformity across services.


15-15: Entrypoint adjusted for uv CLI.
Updating the module path to positionmanager.main:application with --app-dir src aligns with the workspace layout. Looks correct.

compose.yaml (1)

2-7: Verify the tests service build configuration
Ensure the context: . and dockerfile: Dockerfile.test accurately reflect the repository layout and that Dockerfile.test is located at the repo root.

application/datamanager/Dockerfile (5)

4-4: Set PYTHONPATH for application imports
Using ENV PYTHONPATH=/app/src aligns with the new directory structure and entrypoint flags — this change looks correct.


7-8: Install required runtime dependencies
Adding curl alongside libgomp1 and cleaning up apt lists follows best practices for minimal, secure images.


13-13: Synchronize production dependencies only
Running uv sync --no-dev ensures dev dependencies are excluded from the final image, improving security and reducing size.


15-15: Adjust source copy location
Copying ./src explicitly ensures that only application code (and not extraneous files) is included in the image.


19-19: Expose application port update
Updating from port 8000 to 8080 matches conventions used across services and aligns with the Compose definitions.

.github/workflows/test.yaml (2)

14-15: Simplified runner configuration
Hardcoding runs-on: ubuntu-latest aligns with the containerized test approach and reduces maintenance overhead.


24-24: Use consistent test invocation command
Invoking mise tasks run python:test delegates testing to the Docker Compose service, ensuring parity between local and CI runs.

Comment thread pyproject.toml
Comment thread pyproject.toml
Comment thread compose.yaml Outdated
@chrisaddy chrisaddy force-pushed the nix-ci branch 3 times, most recently from 800d394 to 85ce3b8 Compare May 22, 2025 01:01
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
Dockerfile.test (1)

1-1: Ensure Python base image aligns with project compatibility and optimizes image size.

The project’s pyproject.toml specifies >=3.12, but this Dockerfile uses the full python:3.13 image. To both guarantee compatibility and reduce image size/build time, consider pinning to a specific patch version and using a slim variant. For example:

- FROM python:3.13
+ FROM python:3.13-slim

Or, if you prefer to test on the minimum supported version:

- FROM python:3.13
+ FROM python:3.12-slim
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a78278c and 85ce3b8.

📒 Files selected for processing (6)
  • .mise.toml (2 hunks)
  • Dockerfile.test (1 hunks)
  • application/datamanager/Dockerfile (1 hunks)
  • application/datamanager/pyproject.toml (1 hunks)
  • compose.yaml (1 hunks)
  • pyproject.toml (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • application/datamanager/Dockerfile
  • pyproject.toml
  • compose.yaml
  • application/datamanager/pyproject.toml
  • .mise.toml
🧰 Additional context used
🪛 Hadolint (2.12.0)
Dockerfile.test

[error] 8-8: COPY with more than 2 arguments requires the last argument to end with /

(DL3021)

🔇 Additional comments (2)
Dockerfile.test (2)

4-6: ENV and WORKDIR configuration is appropriate.

Setting PYTEST_ADDOPTS to --rootdir=/tests and switching the working directory to /tests aligns correctly with how the Compose service mounts the source for testing.


9-9: Dependency synchronization step is correctly configured.

Running uv sync --all-groups ensures all dependency groups (including dev/test) are installed for coverage and test execution.

Comment thread Dockerfile.test
Comment thread Dockerfile.test
Copy link
Copy Markdown
Collaborator

@forstmeier forstmeier left a comment

Choose a reason for hiding this comment

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

Just some questions to address otherwise it looks good.

Comment thread .github/workflows/test.yaml Outdated
Comment on lines +7 to +13
# name: Run Python tests (${{ matrix.os }})
# runs-on: ${{ matrix.os }}
# strategy:
# matrix:
# os:
# - ubuntu-latest
# - macos-latest
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

These comments can be removed.

version = "0.1.0"
description = "Data management service"
requires-python = ">=3.13"
requires-python = ">=3.12"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No issues just checking we're okay downgrading to 3.12.

"duckdb>=1.2.2",
"polars>=1.29.0",
"pyarrow>=20.0.0",
"datamanager"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is this actually needed now?

Comment thread compose.yaml
@@ -0,0 +1,17 @@

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Removing leading empty line.

Comment thread pyproject.toml
version = "0.1.0"
description = "Open source quantitative hedge fund 🍊"
requires-python = ">=3.13"
requires-python = ">=3.12"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same question.

Comment thread Dockerfile.test
@@ -0,0 +1,9 @@
FROM python:3.13
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is version 3.13 whereas you've set the pyproject.toml to 3.12. Intentional?

chrisaddy added 2 commits May 21, 2025 21:49
…compose.yaml

Fix YAML indentation in compose file
…compose.yaml

Fix YAML indentation in compose file

Merge pull request #552 from pocketsizefund/codex/fix-indentation-in-compose.yaml

Fix YAML indentation in compose file
@chrisaddy chrisaddy merged commit 8433650 into master May 22, 2025
4 checks passed
@chrisaddy chrisaddy deleted the nix-ci branch May 22, 2025 01:50
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.

2 participants