Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem: testground image not pushed to registry #1479

Merged
merged 5 commits into from
Jun 20, 2024

Conversation

yihuang
Copy link
Collaborator

@yihuang yihuang commented Jun 20, 2024

Solution:

  • build the current version of the image in root flake
  • push to github container registry

test run on my personal repo: https://github.com/yihuang/cronos/pkgs/container/cronos-testground

👮🏻👮🏻👮🏻 !!!! REFERENCE THE PROBLEM YOUR ARE SOLVING IN THE PR TITLE AND DESCRIBE YOUR SOLUTION HERE !!!! DO NOT FORGET !!!! 👮🏻👮🏻👮🏻

PR Checklist:

  • Have you read the CONTRIBUTING.md?
  • Does your PR follow the C4 patch requirements?
  • Have you rebased your work on top of the latest master?
  • Have you checked your code compiles? (make)
  • Have you included tests for any non-trivial functionality?
  • Have you checked your code passes the unit tests? (make test)
  • Have you checked your code formatting is correct? (go fmt)
  • Have you checked your basic code style is fine? (golangci-lint run)
  • If you added any dependencies, have you checked they do not contain any known vulnerabilities? (go list -json -m all | nancy sleuth)
  • If your changes affect the client infrastructure, have you run the integration test?
  • If your changes affect public APIs, does your PR follow the C4 evolution of public contracts?
  • If your code changes public APIs, have you incremented the crate version numbers and documented your changes in the CHANGELOG.md?
  • If you are contributing for the first time, please read the agreement in CONTRIBUTING.md now and add a comment to this pull request stating that your PR is in accordance with the Developer's Certificate of Origin.

Thank you for your code, it's appreciated! :)

Summary by CodeRabbit

  • New Features

    • Implemented GitHub Actions workflow for building and pushing Testground images.
    • Added a Docker image configuration for the "cronos-testground" test environment.
    • Introduced overrides and configurations for building Python projects using Poetry in a Nix environment.
  • Enhancements

    • Modified Nix expressions to include additional overlays and updated package inheritance.
    • Improved BenchmarkContext class with lazy initialization for sync attribute.
  • Documentation

    • Added a new function to print runtime configuration for verifying image builds in the main.py file.
  • Refactor

    • Renamed the script entry point from "benchmark" to "testground-testcase" in pyproject.toml.

Solution:
- build the current version of the image in root flake
- push to github container registry
@yihuang yihuang requested a review from a team as a code owner June 20, 2024 01:05
@yihuang yihuang requested review from mmsqe and calvinaco and removed request for a team June 20, 2024 01:05
Copy link
Contributor

coderabbitai bot commented Jun 20, 2024

Warning

Rate limit exceeded

@yihuang has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 31 minutes and 41 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

Files that changed from the base of the PR and between 303b0b8 and cb2d875.

Walkthrough

The recent modifications introduce a comprehensive GitHub Actions workflow to automate building and pushing a Testground Docker image, integrate Nix and Poetry for Python benchmarks, and improve the test environment configuration. These changes bolster the automation, interoperability, and maintainability across the CI/CD pipelines and the development environment.

Changes

File Summary
.github/workflows/container.yml Introduces a workflow for building and pushing a Docker image for Testground with nix and GitHub Actions.
flake.nix Includes new overlays and packages, modifying the Nix setup for better integration of Testground and benchmarks.
nix/benchmark.nix Adds and configures specific build system overrides for Python projects using Poetry within the Nix framework.
nix/testground-image.nix Adds Docker image configuration for the cronos-testground environment, detailing content, ports, and commands.
testground/benchmark/overlay.nix Adds customization logic for Python project overrides and benchmark environment within Nix.
testground/benchmark/.../context.py Modifies the sync attribute to a property with lazy initialization for the BenchmarkContext class.
testground/benchmark/.../main.py Adds an info(ctx: Context) function to print runtime configurations and updates TEST_CASES dictionary.
testground/benchmark/flake.nix Updates inputs and overlays, replacing cronos with poetry2nix and revising development shells.
testground/benchmark/pyproject.toml Renames the entry point script from "benchmark" to "testground-testcase".

Sequence Diagram

sequenceDiagram
    participant Developer
    participant GitHub Actions
    participant Docker Registry
    participant Nix
    participant Poetry

    Developer->>GitHub: Push to main branch or tag version
    GitHub->>GitHub Actions: Trigger workflow
    GitHub Actions->>Nix: Download Nix packages and overlays
    GitHub Actions->>Poetry: Install Python dependencies
    GitHub Actions->>GitHub Actions: Build Docker image
    GitHub Actions->>Docker Registry: Push Docker image
    Docker Registry->>Developer: Notify that image is available
Loading

Poem

In a world of code so vast and bright,
A workflow's born to set things right. 🌌
With Docker's might and Nix's cheer,
Benchmarks dance, no need to fear. 💻
Poetry sings its dependency rhyme,
Testground thrives, it's deployment time! 🚀


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @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.

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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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.

Copy link
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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 54ae5cf and b650471.

Files ignored due to path filters (2)
  • flake.lock is excluded by !**/*.lock
  • testground/benchmark/flake.lock is excluded by !**/*.lock
Files selected for processing (5)
  • .github/workflows/container.yml (1 hunks)
  • flake.nix (1 hunks)
  • nix/benchmark.nix (1 hunks)
  • nix/testground-image.nix (1 hunks)
  • testground/benchmark/overlay.nix (1 hunks)
Additional comments not posted (12)
nix/testground-image.nix (3)

1-8: The Docker image configuration for "cronos-testground" is correctly set with appropriate contents for the test environment.


9-11: The exposed ports and command configuration are well-defined, ensuring the Docker container is properly set up for network interactions and execution.


12-14: Setting PYTHONUNBUFFERED=1 in the environment variables is a good practice for Docker environments, aiding in better log management.

nix/benchmark.nix (2)

3-20: The build system overrides in the benchmark configuration are well-defined, ensuring that each component has the necessary build tools and libraries.


22-31: The Poetry application configuration is correctly set up with an appropriate project directory, Python version, and overrides. The use of gitignoreSourcePure for managing source files is commendable.

testground/benchmark/overlay.nix (2)

3-28: The overrides for Python project builds are appropriately defined, ensuring that the necessary build tools and libraries are included. The source management using gitignoreSourcePure is effectively utilized.


29-45: The function calls for benchmark, image, and environment setups are well-organized and correctly linked to their respective configurations, promoting modularity and maintainability.

.github/workflows/container.yml (3)

1-12: The workflow configuration for triggers and environment variables is correctly set up, ensuring that the Docker image is built and pushed automatically on relevant events.


13-20: The job configuration and permissions are appropriately set, ensuring the workflow has the necessary access rights to perform its tasks.


21-51: The steps for building and pushing the Docker image are well-defined, utilizing Nix and Docker commands effectively to ensure the image is correctly built and pushed to the registry.

flake.nix (2)

42-42: Ensure that testground-image is properly defined and available in the Nix environment, as it is now being inherited in the package set.

Verification successful

The testground-image is correctly defined in nix/testground-image.nix and is properly included in the Nix environment. The definition uses dockerTools.buildLayeredImage to build a Docker image with the necessary components and configurations.

  • flake.nix properly inherits testground-image.
  • testground-image is defined in testground/benchmark/overlay.nix.
  • The actual definition of testground-image in nix/testground-image.nix is valid and correctly set up.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `testground-image` is properly defined in the Nix environment.

# Test: Search for the definition of `testground-image` to ensure it is available.
rg --type nix $'testground-image'

Length of output: 203



Script:

#!/bin/bash
# Description: Verify the contents of `../../nix/testground-image.nix` to ensure `testground-image` is correctly defined.

# Locate and display the contents of `../../nix/testground-image.nix`.
cat $(fd testground-image.nix)

Length of output: 437


34-36: Ensure that the new overlay from testground/benchmark/overlay.nix is correctly implemented and does not conflict with existing configurations.

Verification successful

Ensure that the new overlay from testground/benchmark/overlay.nix is correctly implemented and does not conflict with existing configurations.

  • The new overlay in testground/benchmark/overlay.nix provides specific configurations for benchmarking, including overrides and environment setup for Python packages.
  • Existing overlays, such as poetry2nix and gomod2nix, have distinct purposes and configurations.

Based on the provided content, there are no apparent conflicts between the new overlay and the existing overlays. The new overlay is focused on Python benchmarking, whereas gomod2nix deals with Go module configurations.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the new overlay does not conflict with existing configurations.

# Test: Check for potential conflicts in overlay definitions.
rg --type nix $'overlays.default'

Length of output: 220



Script:

#!/bin/bash
# Description: Display the content of the new overlay and existing overlays for comparison.

# Display content of the new overlay
echo "Content of testground/benchmark/overlay.nix:"
cat testground/benchmark/overlay.nix

# Display content of existing overlays
echo "Content of poetry2nix overlay:"
cat $(fd poetry2nix)

echo "Content of gomod2nix overlay:"
cat $(fd gomod2nix)

Length of output: 33648

@mmsqe
Copy link
Collaborator

mmsqe commented Jun 20, 2024

not sure it's a issue on arm64 only, but I get

docker start $(docker ps -f ancestor="ghcr.io/yihuang/cronos-testground:latest" -aq)
Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "/bin/testground-testcase": stat /bin/testground-testcase: no such file or directory: unknown
Error: failed to start containers: 1629ed45d969

Copy link
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: 0

Outside diff range and nitpick comments (1)
testground/benchmark/benchmark/main.py (1)

Line range hint 42-45: Refactor the exception handling to use contextlib.suppress for a cleaner and more Pythonic approach.

-    try:
-        proc.wait(5)
-    except subprocess.TimeoutExpired:
-        pass
+    with contextlib.suppress(subprocess.TimeoutExpired):
+        proc.wait(5)
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b650471 and 303b0b8.

Files ignored due to path filters (1)
  • testground/benchmark/flake.lock is excluded by !**/*.lock
Files selected for processing (7)
  • flake.nix (2 hunks)
  • nix/testground-image.nix (1 hunks)
  • testground/benchmark/benchmark/context.py (2 hunks)
  • testground/benchmark/benchmark/main.py (1 hunks)
  • testground/benchmark/flake.nix (2 hunks)
  • testground/benchmark/overlay.nix (1 hunks)
  • testground/benchmark/pyproject.toml (1 hunks)
Files skipped from review due to trivial changes (1)
  • testground/benchmark/pyproject.toml
Files skipped from review as they are similar to previous changes (3)
  • flake.nix
  • nix/testground-image.nix
  • testground/benchmark/overlay.nix
Additional context used
Ruff
testground/benchmark/benchmark/main.py

42-45: Use contextlib.suppress(subprocess.TimeoutExpired) instead of try-except-pass (SIM105)

Replace with contextlib.suppress(subprocess.TimeoutExpired)

Additional comments not posted (6)
testground/benchmark/benchmark/main.py (1)

49-54: The new info function is a simple utility to print runtime configuration. This is a good practice for debugging and verifying the image build process. However, consider adding a more descriptive function name or a detailed docstring to clarify its specific purpose in the context of testground.

testground/benchmark/flake.nix (3)

5-6: Adding poetry2nix as a dependency is appropriate for managing Python dependencies. Make sure all necessary configurations are updated to accommodate this change.


66-70: The configuration for the new testground-testcase package and application is well-defined. However, verify that the executable path matches the actual location in the Docker container to avoid runtime errors.


58-60: The addition of overlays in the Nix configuration is crucial for extending functionality. Ensure that the overlays are correctly configured and tested, especially since they can significantly alter the behavior of the packages.

testground/benchmark/benchmark/context.py (2)

15-21: Converting sync to a lazy-initialized property is a good practice for resource management, ensuring that the SyncService is only initialized when needed. This change enhances the efficiency of the Context class.


116-117: Properly handling resource cleanup in the __exit__ method is crucial. Ensure that all resources are appropriately released to prevent leaks.

@yihuang
Copy link
Collaborator Author

yihuang commented Jun 20, 2024

not sure it's a issue on arm64 only, but I get

docker start $(docker ps -f ancestor="ghcr.io/yihuang/cronos-testground:latest" -aq)
Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "/bin/testground-testcase": stat /bin/testground-testcase: no such file or directory: unknown
Error: failed to start containers: 1629ed45d969

works now, you can test the image like this:

$ docker run --rm -e TEST_CASE=info ghcr.io/yihuang/cronos-testground:latest

@yihuang
Copy link
Collaborator Author

yihuang commented Jun 20, 2024

not sure it's a issue on arm64 only, but I get

docker start $(docker ps -f ancestor="ghcr.io/yihuang/cronos-testground:latest" -aq)
Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "/bin/testground-testcase": stat /bin/testground-testcase: no such file or directory: unknown
Error: failed to start containers: 1629ed45d969

works now, you can test the image like this:

$ docker run --rm -e TEST_CASE=info ghcr.io/yihuang/cronos-testground:latest

Can also run the cronosd like this:

$ docker run --rm -v /tmp:/tmp ghcr.io/yihuang/cronos-testground:latest /bin/cronosd version --long

@yihuang yihuang added this pull request to the merge queue Jun 20, 2024
Merged via the queue into crypto-org-chain:main with commit 903b590 Jun 20, 2024
34 checks passed
@yihuang yihuang deleted the upload-container branch June 20, 2024 02:11
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