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

refactor(localnet): reduce number of docker compose files #2365

Merged
merged 7 commits into from
Jun 24, 2024

Conversation

gartnera
Copy link
Member

@gartnera gartnera commented Jun 20, 2024

Description

Reduce number of docker compose files by instead injecting environment variables where possible. Use these environment variables in conditionals rather than command line arguments also.

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Include instructions and any relevant details so others can reproduce.

  • Tested CCTX in localnet
  • Tested in development environment
  • Go unit tests
  • Go integration tests
  • Tested via GitHub Actions

Checklist:

  • I have added unit tests that prove my fix feature works

Summary by CodeRabbit

  • Chores
    • Streamlined build and test workflows to improve efficiency.
    • Updated environment variables and configurations in various local network setup files.
    • Modified scripts to use new environment variables, enhancing flexibility and maintainability.

@gartnera gartnera mentioned this pull request Jun 20, 2024
10 tasks
@gartnera gartnera force-pushed the refactor-docker-compose branch 2 times, most recently from 7c1f799 to 39c2e20 Compare June 20, 2024 22:42
@gartnera gartnera added the no-changelog Skip changelog CI check label Jun 20, 2024
@gartnera gartnera force-pushed the refactor-docker-compose branch from 1669503 to d9b2f23 Compare June 21, 2024 16:34
Copy link
Contributor

coderabbitai bot commented Jun 21, 2024

Important

Review skipped

Review was skipped due to path filters

Files ignored due to path filters (19)
  • .github/workflows/build.yml is excluded by none and included by none
  • .github/workflows/execute_advanced_tests.yaml is excluded by none and included by none
  • .github/workflows/publish-release.yml is excluded by none and included by none
  • Makefile is excluded by none and included by none
  • contrib/localnet/docker-compose-additionalevm.yml is excluded by none and included by none
  • contrib/localnet/docker-compose-import-data.yml is excluded by none and included by none
  • contrib/localnet/docker-compose-monitoring.yml is excluded by none and included by none
  • contrib/localnet/docker-compose-performance.yml is excluded by none and included by none
  • contrib/localnet/docker-compose-setup-only.yml is excluded by none and included by none
  • contrib/localnet/docker-compose-stress.yml is excluded by none and included by none
  • contrib/localnet/docker-compose-upgrade-light.yml is excluded by none and included by none
  • contrib/localnet/docker-compose-upgrade.yml is excluded by none and included by none
  • contrib/localnet/docker-compose.yml is excluded by none and included by none
  • contrib/localnet/orchestrator/start-zetae2e.sh is excluded by none and included by none
  • contrib/localnet/scripts/import-data.sh is excluded by none and included by none
  • contrib/localnet/scripts/start-upgrade-orchestrator.sh is excluded by none and included by none
  • contrib/localnet/scripts/start-zetaclientd.sh is excluded by none and included by none
  • contrib/localnet/scripts/start-zetacored.sh is excluded by none and included by none
  • docs/development/LOCAL_TESTING.md is excluded by none and included by none

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The updates streamline several workflows by replacing direct Docker Compose commands with Makefile commands, and introduce new environment variables to enhance configuration flexibility. Changes span across GitHub workflow YAML files, Docker Compose configurations, and shell scripts, aiming to improve maintainability and ease of local network management.

Changes

Files/Paths Change Summaries
.github/workflows/build.yml, .github/workflows/execute_advanced_tests.yaml, .github/workflows/publish-release.yml Replaced Docker Compose commands with make stop-localnet for better workflow efficiency.
Makefile Introduced new environment variables for various tests and setup commands. Adjusted commands to use these variables.
contrib/localnet/docker-compose-additionalevm.yml Removed orchestrator service entrypoint configuration, added ADDITIONAL_EVM env variable.
contrib/localnet/docker-compose-monitoring.yml Removed version declaration, reduced number of services.
contrib/localnet/docker-compose-stress.yml, docker-compose.yml, docker-compose-upgrade.yml Updated environment variables, removed orchestrator services, added volume mappings.
contrib/localnet/orchestrator/start-zetae2e.sh, contrib/localnet/scripts/start-zetae2e.sh Swapped $OPTION with $LOCALNET_MODE, updated default upgrade height, and called script with mode-based arguments.
contrib/localnet/scripts/import-data.sh Changed directory for storing exported genesis data.
contrib/localnet/scripts/start-upgrade-orchestrator.sh Adjusted CHAINID variable, removed UPGRADE_HEIGHT declaration.
contrib/localnet/scripts/start-zetaclientd.sh, start-zetacored.sh Updated conditional checks to use new environment variables, modified script logic accordingly.

Sequence Diagram(s)

sequenceDiagram
    participant GitHubActions as GitHub Actions
    participant Makefile as Makefile
    participant DockerCompose as Docker Compose
    participant LocalnetEnv as Localnet Environment

    GitHubActions->>Makefile: make stop-localnet
    Makefile->>DockerCompose: docker compose down
    DockerCompose->>LocalnetEnv: Stop services
Loading

Poem

In the realm of code, a kingdom bright,
Docker commands took flight. 🚀
With a Makefile song, they now stream,
Simplification, a coder's dream.
Amidst env vars and scripts so keen,
Localnet flows like a gentle stream. 🌊
Cheers to workflows, smooth and light!


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.

@github-actions github-actions bot added the ci Changes to CI pipeline or github actions label Jun 21, 2024
@gartnera gartnera marked this pull request as ready for review June 21, 2024 17:48
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: 6

Outside diff range and nitpick comments (5)
contrib/localnet/docker-compose-monitoring.yml (1)

Line range hint 45-45: Add a newline at the end of the file.

The YAML file should end with a newline character to comply with UNIX text file formatting standards.

contrib/localnet/scripts/start-zetaclientd.sh (1)

Line range hint 10-10: Consider removing or using the OPTION variable.

The OPTION variable is declared but not used in the script, which could lead to confusion and clutter. Consider removing it if it's no longer needed, or ensure it's used appropriately if required.

contrib/localnet/docker-compose.yml (2)

Line range hint 26-26: Formatting issue: Too many spaces after a comma.

Ensure consistent formatting by removing the extra spaces after commas to adhere to YAML best practices.


Line range hint 159-159: Missing new line at end of file.

It's a common practice to end files with a newline character to conform to POSIX standards.

contrib/localnet/scripts/start-zetacored.sh (1)

Line range hint 135-135: Improve the safety of sourcing external scripts.

Using source with a relative path can lead to issues if the script is not run from the expected directory. Consider using an absolute path or validating the script's presence before sourcing.

+ if [[ -f "$HOME/add-keys.sh" ]]; then
+   source "$HOME/add-keys.sh"
+ else
+   echo "Required script add-keys.sh not found."
+   exit 1
+ fi
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f9ca2be and c2f838d.

Files selected for processing (14)
  • .github/workflows/build.yml (2 hunks)
  • .github/workflows/execute_advanced_tests.yaml (4 hunks)
  • .github/workflows/publish-release.yml (1 hunks)
  • Makefile (3 hunks)
  • contrib/localnet/docker-compose-additionalevm.yml (2 hunks)
  • contrib/localnet/docker-compose-monitoring.yml (1 hunks)
  • contrib/localnet/docker-compose-stress.yml (5 hunks)
  • contrib/localnet/docker-compose-upgrade.yml (3 hunks)
  • contrib/localnet/docker-compose.yml (4 hunks)
  • contrib/localnet/orchestrator/start-zetae2e.sh (6 hunks)
  • contrib/localnet/scripts/import-data.sh (1 hunks)
  • contrib/localnet/scripts/start-upgrade-orchestrator.sh (1 hunks)
  • contrib/localnet/scripts/start-zetaclientd.sh (2 hunks)
  • contrib/localnet/scripts/start-zetacored.sh (3 hunks)
Files skipped from review due to trivial changes (5)
  • .github/workflows/build.yml
  • .github/workflows/execute_advanced_tests.yaml
  • .github/workflows/publish-release.yml
  • contrib/localnet/docker-compose-additionalevm.yml
  • contrib/localnet/scripts/import-data.sh
Additional context used
yamllint
contrib/localnet/docker-compose-monitoring.yml

[error] 45-45: no new line character at the end of file (new-line-at-end-of-file)

contrib/localnet/docker-compose-upgrade.yml

[error] 45-45: no new line character at the end of file (new-line-at-end-of-file)

contrib/localnet/docker-compose-stress.yml

[error] 73-73: no new line character at the end of file (new-line-at-end-of-file)

contrib/localnet/docker-compose.yml

[warning] 26-26: too many spaces after comma (commas)


[error] 159-159: no new line character at the end of file (new-line-at-end-of-file)

Shellcheck
contrib/localnet/scripts/start-zetaclientd.sh

[warning] 10-10: OPTION appears unused. Verify use (or export if used externally). (SC2034)

contrib/localnet/scripts/start-zetacored.sh

[warning] 135-135: ShellCheck can't follow non-constant source. Use a directive to specify location. (SC1090)

Gitleaks
contrib/localnet/scripts/start-upgrade-orchestrator.sh

4-4: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key)

Additional comments not posted (6)
contrib/localnet/docker-compose-upgrade.yml (1)

35-43: Refactor to use environment variable for UPGRADE_HEIGHT.

This change aligns with the PR's objective to manage configurations more effectively through environment variables. Ensure that the UPGRADE_HEIGHT variable is properly set in the environment where this Docker Compose is executed.

contrib/localnet/docker-compose-stress.yml (1)

7-8: Use of ZETACORED_REPLICAS to manage replicas dynamically.

Introducing ZETACORED_REPLICAS as an environment variable enhances flexibility in configuring the number of node replicas during stress tests. This change is consistent with the PR's goal of better configuration management.

Also applies to: 11-12, 25-25, 41-41

contrib/localnet/scripts/start-zetaclientd.sh (1)

66-66: Conditional use of ADDITIONAL_EVM for chain configuration.

The script now uses the ADDITIONAL_EVM environment variable to conditionally apply chain configurations. This change makes the script more flexible and aligns with the PR's objective of improving environment variable management.

Also applies to: 85-85

contrib/localnet/orchestrator/start-zetae2e.sh (1)

78-78: Enhanced conditional logic and environment variable usage.

The modifications to use LOCALNET_MODE and UPGRADE_HEIGHT variables improve the flexibility and configurability of the script. The conditional checks and default settings are well-implemented.

Also applies to: 83-83, 100-100, 142-142, 162-162, 171-171, 177-177

Makefile (2)

28-33: Environment variables added for better configuration management.

The introduction of environment variables such as LOCALNET_MODE, E2E_ARGS, UPGRADE_HEIGHT, ZETACORED_IMPORT_GENESIS_DATA, and ZETACORED_START_PERIOD enhances the flexibility and configurability of the build process.


232-238: Usage of environment variables in Docker commands.

The use of environment variables in Docker compose commands for different testing scenarios (E2E_ARGS, LOCALNET_MODE, UPGRADE_HEIGHT, ZETACORED_IMPORT_GENESIS_DATA) is a good practice, making the build process more dynamic and adaptable to different environments.

Also applies to: 242-242, 253-261, 267-274

contrib/localnet/scripts/start-zetacored.sh Show resolved Hide resolved
contrib/localnet/scripts/start-zetacored.sh Show resolved Hide resolved
contrib/localnet/docker-compose-upgrade.yml Outdated Show resolved Hide resolved
contrib/localnet/docker-compose-stress.yml Outdated Show resolved Hide resolved
Copy link
Contributor

@swift1337 swift1337 left a comment

Choose a reason for hiding this comment

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

LGTM; Small note: can you briefly describe new env vars in LOCAL_TESTING.md?

.github/workflows/execute_advanced_tests.yaml Outdated Show resolved Hide resolved
Makefile Show resolved Hide resolved
contrib/localnet/scripts/import-data.sh Outdated Show resolved Hide resolved
@gartnera gartnera force-pushed the refactor-docker-compose branch from c2f838d to 1f4987c Compare June 24, 2024 16:40
@gartnera gartnera merged commit 3eb36cd into develop Jun 24, 2024
19 checks passed
@gartnera gartnera deleted the refactor-docker-compose branch June 24, 2024 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci Changes to CI pipeline or github actions no-changelog Skip changelog CI check
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants