Skip to content

Comments

feature: simplify velox build configuration#165

Merged
rustatian merged 5 commits intomasterfrom
feature/simplify-config
Jun 21, 2024
Merged

feature: simplify velox build configuration#165
rustatian merged 5 commits intomasterfrom
feature/simplify-config

Conversation

@rustatian
Copy link
Member

@rustatian rustatian commented Jun 21, 2024

Reason for This PR

  • Configuration complexity.

Description of Changes

  • Removed build_args as not needed to be included. Instead, only debug.enabled=true/false option was added.
  • Velox now gets the ref from the [roadrunner] section to specify version and automatically injects build time.
  • Previous configuration will still work with the new Velox, but build_args section would be skipped.
  • Zap logger was replaced with Go std slog.

License Acceptance

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

PR Checklist

[Author TODO: Meet these criteria.]
[Reviewer TODO: Verify that these criteria are met. Request changes if not]

  • All commits in this PR are signed (git commit -s).
  • The reason for this PR is clearly provided (issue no. or explanation).
  • The description of changes is clear and encompassing.
  • Any required documentation changes (code and docs) are included in this PR.
  • Any user-facing changes are mentioned in CHANGELOG.md.
  • All added/changed functionality is tested.

Summary by CodeRabbit

  • New Features

    • Introduced a debug configuration section in velox_rr_v2024.toml.
  • Enhancements

    • Updated logging system across multiple components to use log/slog instead of go.uber.org/zap.
    • Improved logging statements for better clarity and consistency.
  • Configuration Changes

    • Reformatted velox.toml and velox_rr_v2024.toml for better readability.
    • Updated velox_rr_v2024.toml to include a debug section and updated log levels.
  • Refactor

    • Renamed Structure to StructureName in various files for improved clarity.
    • Updated function signatures to include additional parameters for better flexibility.

@rustatian rustatian added the C-enhancement Category: enhancement. Meaning improvements of current module, transport, etc.. label Jun 21, 2024
@rustatian rustatian requested a review from wolfy-j June 21, 2024 18:18
@rustatian rustatian self-assigned this Jun 21, 2024
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 21, 2024

Warning

Rate limit exceeded

@rustatian has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 46 minutes and 16 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 ab771a2 and 9532907.

Walkthrough

The recent changes across multiple files primarily involved migrating the logging framework from go.uber.org/zap to log/slog. Several method signatures, log statements, and configurations were updated accordingly. Additionally, new features include the introduction of debug flags and version handling, structural modifications to configuration files, and refactoring of template-related code to use more descriptive names.

Changes

Files/Groups Change Summaries
builder/builder.go, builder_test.go, builder/template_test.go, builder/templates/entry.go, builder/templates/templateV2.go Migration of logging from zap to slog, method signature adjustments, and renaming of struct fields.
config.go Added Debug field in Config struct and modified Validate method to initialize Debug and validate GitHub token.
github/pool.go, gitlab/repo.go Replaced zap logging with slog, updated logger types in structs and logging statements.
internal/cli/root.go, internal/cli/build/build.go Replaced zap logging with slog, updated function signatures, and logger initializations.
logger/logger.go Refactored BuildLogger to use slog instead of zap, removed level encoders, and added stringToSlogLevel function.
go.mod Removed go.uber.org/zap dependency and added go.uber.org/atomic and go.uber.org/multierr.
velox.toml, velox_rr_v2024.toml Reformatted configuration sections, added debug settings, and updated version references.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant Builder
    participant Logger
    
    User->>CLI: Run build command
    CLI->>Logger: Initialize slog.Logger
    CLI->>Builder: Create Builder with slog.Logger
    Builder->>Logger: Log build process details
    Builder->>CLI: Return build result
    CLI->>User: Display result
Loading

Poem

In fields of code where bunnies hop,
We swapped out zap to make things pop!
With slog in hand, our logs align,
Debug flags sparkle, metrics shine.
Repos clone, templates refine,
Our software’s grows so sleek, divine!
🐇✨


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: 2

Outside diff range and nitpick comments (2)
internal/cli/build/build.go (1)

Line range hint 19-70: Refactor the error handling strategy for consistency and robustness.

The current implementation uses os.Exit(1) directly within the command execution, which is not recommended as it prevents the execution of deferred statements and can lead to resources not being properly released. Consider returning an error instead and letting the caller handle it.

- os.Exit(1)
+ return fmt.Errorf("error occurred: %w", err)
internal/cli/root.go (1)

Line range hint 19-65: Ensure proper error handling in the configuration loading process.

The configuration loading and validation process should handle potential errors more gracefully. Instead of directly returning the error, consider logging the error and providing a more user-friendly message.

- return err
+ zlog.Error("Failed to load configuration", slog.Any("error", err))
+ return fmt.Errorf("configuration loading failed: %w", err)
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1020826 and a4d97fd.

Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
Files selected for processing (18)
  • builder/builder.go (16 hunks)
  • builder/builder_test.go (2 hunks)
  • builder/template_test.go (5 hunks)
  • builder/templates/entry.go (1 hunks)
  • builder/templates/templateV2.go (1 hunks)
  • builder/templates/templateV2023.go (2 hunks)
  • builder/templates/templateV2024.go (2 hunks)
  • config.go (4 hunks)
  • config_test.go (2 hunks)
  • github/pool.go (8 hunks)
  • github/repo.go (8 hunks)
  • gitlab/repo.go (6 hunks)
  • go.mod (2 hunks)
  • internal/cli/build/build.go (4 hunks)
  • internal/cli/root.go (4 hunks)
  • logger/logger.go (1 hunks)
  • velox.toml (1 hunks)
  • velox_rr_v2024.toml (1 hunks)
Files skipped from review due to trivial changes (2)
  • builder/templates/templateV2023.go
  • go.mod
Additional comments not posted (19)
builder/templates/templateV2.go (1)

44-44: LGTM!

The update from Structure to StructureName in the Plugins() function is consistent with the changes across the codebase.

logger/logger.go (1)

16-32: Refactor suggestion for better readability.

The BuildLogger function can be made more concise by extracting the repeated slog.New call outside the switch-case.
[REFACTOR_SUGGESTion]

func BuildLogger(level, mode string) *slog.Logger {
	var lg *slog.Handler
	switch mode {
	case production:
		lg = slog.NewJSONHandler(os.Stderr, &slog.HandlerOptions{
			AddSource: false,
			Level:     stringToSlogLevel(level),
		})
	case development:
		lg = slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{
			AddSource: true,
			Level:     stringToSlogLevel(level),
		})
	default:
		lg = slog.DefaultHandler()
	}
	return slog.New(lg)
}
builder/templates/templateV2024.go (1)

9-16: Dependency updates approved.

The updates to module versions in GoModTemplateV2024 are appropriate. Ensure to verify the compatibility of these new versions with the project's requirements.

internal/cli/build/build.go (1)

64-67: Improve error logging details for better traceability.

Currently, the error logging is quite generic. It would be beneficial to include more context about the error, such as the function or the specific operation that failed, to aid in debugging.

- zlog.Error("fatal", slog.Any("error", err))
+ zlog.Error("Build operation failed", slog.Any("error", err), slog.String("operation", "building project"))

[REFACTOR_SUGGESTion]

builder/templates/entry.go (1)

11-13: Review the structural changes to Entry.

The renaming of Structure to StructureName is clear and makes sense. Ensure that this change is propagated throughout the codebase wherever Entry struct is used to avoid breaking changes.

builder/template_test.go (1)

54-89: Ensure test coverage for new structure names.

The tests have been updated to reflect the new StructureName field. Verify that these tests cover all scenarios where StructureName is used, especially in edge cases or where the structure name might be dynamically generated or altered.

gitlab/repo.go (2)

9-9: Update to use slog for logging:

The changes correctly update the logging library from zap to slog, ensuring consistency with the rest of the project's logging strategy.

Also applies to: 25-25, 28-28


46-46: Detailed and appropriate logging:

The log statements added in various parts of the GetPluginsModData function provide good insight into the function's operation, which is crucial for debugging and monitoring.

Also applies to: 73-73, 88-88, 126-126

config.go (2)

22-22: Addition of Debug struct and inclusion in Config:

The addition of the Debug struct to the configuration is well-implemented. It allows easier control over debugging features, which can be critical for development and troubleshooting.

Also applies to: 32-34


67-71: Initialization of Debug field in Config.Validate:

The initialization ensures that the Debug field is never nil, which prevents potential nil pointer dereferences later in the code. This is a good practice for robustness.

velox_rr_v2024.toml (1)

2-2: Configuration updates in velox_rr_v2024.toml:

The addition of the debug section and updates to the ref values align with the PR's objectives to simplify and update the build configurations.

Also applies to: 5-8

velox.toml (1)

2-6: Refinement of build arguments in velox.toml:

The specification of build arguments is important for reproducible builds. The inclusion of -trimpath and detailed -ldflags helps ensure that the build environment does not affect the binaries.

github/pool.go (2)

29-29: Refactor: Logger change from zap to slog.

The logger in the processor struct and newPool function has been successfully migrated from zap to slog. This change aligns with the PR's goal to simplify the logging mechanism.

Also applies to: 40-40


64-68: Refactor: Consistent usage of the slog logger with structured logging.

The structured logging statements have been appropriately adapted to use slog's conventions, enhancing readability and maintainability of the logging code.

Also applies to: 96-96, 121-121, 158-158

github/repo.go (2)

34-34: Refactor: Logger change from zap to slog.

The logger in the GHRepo struct and NewGHRepoInfo function has been successfully migrated from zap to slog. This is a straightforward change that aligns with the overall logging migration strategy.

Also applies to: 37-37


56-56: Refactor: Consistent usage of the slog logger with structured logging in the DownloadTemplate method.

Structured logging statements have been successfully adapted to use slog. This enhances the clarity and maintainability of the logging code within this method.

Also applies to: 66-66, 73-73, 88-88, 103-103, 145-145, 152-152

builder/builder_test.go (1)

84-84: Refactor: Updated NewBuilder initialization in tests.

The test initialization for NewBuilder has been updated to include the new parameters rrVersion and debug, and to use slog.Default() for logging. This change is necessary to align the tests with the updated constructor of the Builder class.

builder/builder.go (2)

40-42: Enhancement: Added debug and rrVersion parameters to the Builder struct and constructor.

The addition of debug and rrVersion parameters to the Builder struct and its constructor enhances the configurability and flexibility of the build process. The logging has also been migrated to slog, which is consistent with changes across the project.

Also applies to: 45-51


101-101: Refactor: Comprehensive logging updates in the Build method and related functions.

Logging throughout the Build method and related functions has been systematically updated to use slog, with additional detailed logs introduced at key operations. This improves the traceability and debuggability of the build process.

Also applies to: 115-115, 164-164, 173-173, 189-189, 200-200, 210-210, 289-289, 304-304, 319-319, 330-330

Comment on lines +21 to +23
Debug: &Debug{
Enabled: true,
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Enhance test coverage for new configurations.

The addition of the Debug field in the Config struct is well-integrated. Consider expanding test coverage to ensure the new debug functionality behaves as expected under various scenarios.

Would you like assistance in creating additional test cases for this functionality?

Signed-off-by: Valery Piashchynski <[email protected]>
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: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a4d97fd and 2645c4b.

Files selected for processing (6)
  • builder/builder.go (17 hunks)
  • github/pool.go (8 hunks)
  • github/repo.go (8 hunks)
  • gitlab/repo.go (6 hunks)
  • logger/logger.go (1 hunks)
  • velox_rr_v2024.toml (1 hunks)
Files skipped from review as they are similar to previous changes (5)
  • builder/builder.go
  • github/pool.go
  • github/repo.go
  • gitlab/repo.go
  • velox_rr_v2024.toml
Additional comments not posted (1)
logger/logger.go (1)

36-51: Check mapping of log levels in stringToSlogLevel.

The function stringToSlogLevel correctly maps string representations to slog.Level. However, the levels "fatal" and "panic" both map to slog.LevelError. Verify if this is the intended behavior, as typically these levels might warrant distinct handling.

Signed-off-by: Valery Piashchynski <[email protected]>
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 2645c4b and ab771a2.

Files selected for processing (3)
  • builder/builder.go (17 hunks)
  • internal/cli/build/build.go (4 hunks)
  • velox_rr_v2024.toml (2 hunks)
Files skipped from review as they are similar to previous changes (3)
  • builder/builder.go
  • internal/cli/build/build.go
  • velox_rr_v2024.toml

Signed-off-by: Valery Piashchynski <[email protected]>
Signed-off-by: Valery Piashchynski <[email protected]>
@rustatian rustatian merged commit 4dd6fff into master Jun 21, 2024
@rustatian rustatian deleted the feature/simplify-config branch June 21, 2024 22:28
@coderabbitai coderabbitai bot mentioned this pull request Oct 16, 2024
6 tasks
@coderabbitai coderabbitai bot mentioned this pull request Aug 17, 2025
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-enhancement Category: enhancement. Meaning improvements of current module, transport, etc..

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

1 participant