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 use Absolute path for Makefile #2670

Merged
merged 1 commit into from
Oct 4, 2024

Conversation

kpango
Copy link
Collaborator

@kpango kpango commented Oct 2, 2024

Description

SSIA

Related Issue

Versions

  • Vald Version: v1.7.13
  • Go Version: v1.23.2
  • Rust Version: v1.81.0
  • Docker Version: v27.3.1
  • Kubernetes Version: v1.31.1
  • Helm Version: v3.16.1
  • NGT Version: v2.2.4
  • Faiss Version: v1.8.0

Checklist

Special notes for your reviewer

Summary by CodeRabbit

  • New Features
    • Added new functions for generating dead link checks, GitHub Actions workflows, Helm schemas, and Custom Resource Definitions.
  • Improvements
    • Updated paths in various Makefiles to utilize a root directory variable, enhancing flexibility and maintainability.
    • Improved Docker build context and Git commit template referencing.
    • Enhanced URL construction in stack trace handling for better representation of runtime information.
    • Updated dependency versions for compatibility and potential bug fixes.
    • Incremented version numbers for Prometheus Stack, Telepresence, and Docker Setup Buildx Action.
  • Bug Fixes
    • Corrected file paths in the proto cleaning process to ensure proper operation.

Copy link
Contributor

coderabbitai bot commented Oct 2, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

The pull request introduces modifications primarily to various Makefiles, focusing on updating path references to utilize the $(ROOTDIR) variable. This change ensures that paths for proto directories, Docker builds, Git commit templates, Helm charts, and Kubernetes commands are resolved relative to the root directory of the repository. Additionally, new functions are added to enhance Go application building and testing. Overall, the changes improve path management and maintainability across the Makefiles.

Changes

File Change Summary
Makefile Updated paths for PROTODIRS, PROTOS, and PBDOCS to use $(ROOTDIR). Modified changelog/update target to reference CHANGELOG.md using $(ROOTDIR).
Makefile.d/docker.mk Adjusted Docker build command to use $(ROOTDIR) for the Dockerfile path, changing build context accordingly.
Makefile.d/functions.mk Added new functions: gen-deadlink-checker, gen-workflow, gen-vald-helm-schema, gen-vald-crd. Modified existing functions to include additional parameters.
Makefile.d/git.mk Updated Git commit template path to use $(ROOTDIR) instead of a relative path.
Makefile.d/helm.mk Changed paths for packaging Helm charts and generating documentation to include $(ROOTDIR).
Makefile.d/k8s.mk Updated paths for directory creation, file movement, Helm install commands, and Kubernetes commands to utilize $(ROOTDIR).
Makefile.d/proto.mk Modified paths in proto/clean target to use $(ROOTDIR) for removing protobuf artifacts.
internal/info/info.go Enhanced info struct with a new field valdReplacer and updated methods for improved URL handling and stack trace representation.
internal/net/grpc/errdetails/errdetails.go Simplified string construction for stack trace entries in DebugInfoFromInfoDetail function.
go.mod Updated versions for several dependencies to their latest releases.
versions/PROMETHEUS_STACK_VERSION Updated version from 63.1.0 to 65.0.0.
versions/TELEPRESENCE_VERSION Updated version from 2.19.1 to 2.20.0.
versions/actions/DOCKER_SETUP_BUILDX_ACTION Updated version from 3.6.1 to 3.7.0.

Possibly related PRs

Suggested reviewers

  • hlts2
  • kmrmt

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>, please review it.
    • 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 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 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 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 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.

@vdaas-ci
Copy link
Collaborator

vdaas-ci commented Oct 2, 2024

[CHATOPS:HELP] ChatOps commands.

  • 🙆‍♀️ /approve - approve
  • 🍱 /format - format codes and add licenses
  • /gen-test - generate test codes
  • 🏷️ /label - add labels
  • 🔚 2️⃣ 🔚 /label actions/e2e-deploy - run E2E deploy & integration test

coderabbitai[bot]
coderabbitai bot previously approved these changes Oct 2, 2024
Copy link
Contributor

github-actions bot commented Oct 3, 2024

@vdaas-ci
Copy link
Collaborator

vdaas-ci commented Oct 3, 2024

Profile Report

typevald-agent-ngtvald-lb-gatewayvald-discoverervald-manager-index
cpu
heap
other images

kmrmt
kmrmt previously approved these changes Oct 3, 2024
@kpango kpango requested review from datelier and removed request for hlts2 October 3, 2024 07:01
@kpango kpango dismissed stale reviews from kmrmt and coderabbitai[bot] via 2481a88 October 3, 2024 10:30
@kpango kpango force-pushed the refactor/makefile/add-absolute-path branch from ae7e07f to 2481a88 Compare October 3, 2024 10:30
Copy link

cloudflare-workers-and-pages bot commented Oct 3, 2024

Deploying vald with  Cloudflare Pages  Cloudflare Pages

Latest commit: 78ec9c8
Status: ✅  Deploy successful!
Preview URL: https://dd73f850.vald.pages.dev
Branch Preview URL: https://refactor-makefile-add-absolu.vald.pages.dev

View logs

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 (2)
internal/net/grpc/errdetails/errdetails.go (1)

414-414: LGTM! Consider using fmt.Sprintf for better readability.

The change simplifies the string concatenation for stack entries, which is good. The use of stack.ShortString() instead of stack.String() is also an improvement, likely reducing the verbosity of the stack trace.

For even better readability and performance, consider using fmt.Sprintf:

debug.StackEntries = append(debug.GetStackEntries(), fmt.Sprintf("id: %d stack_trace: %s", i, stack.ShortString()))

This approach is more idiomatic Go and can be slightly more efficient for string formatting.

internal/info/info.go (1)

303-306: Consider using path.Base for extracting the function name.

Replacing the manual string manipulation with path.Base from the path package can improve code clarity and handle edge cases more robustly.

Apply this diff to enhance the function name extraction:

-index := strings.LastIndex(funcName, "/")
-if index != -1 {
-    funcName = funcName[index+1:]
-}
+funcName = path.Base(funcName)

Remember to import the path package at the top of the file:

+ "path"
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ae7e07f and 2481a88.

📒 Files selected for processing (9)
  • Makefile (2 hunks)
  • Makefile.d/docker.mk (2 hunks)
  • Makefile.d/functions.mk (0 hunks)
  • Makefile.d/git.mk (1 hunks)
  • Makefile.d/helm.mk (2 hunks)
  • Makefile.d/k8s.mk (9 hunks)
  • Makefile.d/proto.mk (1 hunks)
  • internal/info/info.go (5 hunks)
  • internal/net/grpc/errdetails/errdetails.go (1 hunks)
💤 Files with no reviewable changes (1)
  • Makefile.d/functions.mk
🚧 Files skipped from review as they are similar to previous changes (5)
  • Makefile
  • Makefile.d/docker.mk
  • Makefile.d/git.mk
  • Makefile.d/k8s.mk
  • Makefile.d/proto.mk
🔇 Additional comments (22)
Makefile.d/helm.mk (15)

40-40: LGTM: Improved path robustness

The use of $(ROOTDIR) in the helm package command ensures that the correct path is used regardless of the current working directory. This change improves the robustness of the Makefile.


47-47: LGTM: Consistent path update

The use of $(ROOTDIR) in the helm package command for vald-helm-operator is consistent with the previous change and provides the same benefits of improved path robustness.


55-55: LGTM: Consistent path update

The use of $(ROOTDIR) in the helm package command for vald-benchmark-operator maintains consistency with the previous changes and improves path robustness.


59-59: LGTM: Consistent path update

The use of $(ROOTDIR) in the helm package command for vald-readreplica maintains consistency with the previous changes and improves path robustness.


67-67: LGTM: Consistent path updates for documentation

The use of $(ROOTDIR) in the paths for the Vald README and its dependencies ensures consistency with previous changes and improves the robustness of the documentation generation process.

Also applies to: 70-73


77-77: LGTM: Consistent path updates for vald-helm-operator documentation

The use of $(ROOTDIR) in the paths for the vald-helm-operator README and its dependencies maintains consistency with previous changes and ensures robust documentation generation.

Also applies to: 80-83


87-87: LGTM: Consistent path update for vald-readreplica documentation

The use of $(ROOTDIR) in the path for the vald-readreplica README maintains consistency with previous changes and ensures robust documentation generation.


90-90: LGTM: Consistent path updates for vald-benchmark-operator documentation

The use of $(ROOTDIR) in the paths for the vald-benchmark-operator README and its dependencies maintains consistency with previous changes and ensures robust documentation generation.

Also applies to: 92-95


99-102: LGTM: Completed path updates for vald-readreplica documentation

The use of $(ROOTDIR) in the paths for the vald-readreplica README and its dependencies completes the modifications for this target, maintaining consistency and ensuring robust documentation generation.


115-115: LGTM: Consistent path updates for Vald schema generation

The use of $(ROOTDIR) in the paths for the Vald schema and its dependency maintains consistency with previous changes and ensures robust schema generation.

Also applies to: 117-118


123-123: LGTM: Consistent path updates for vald-helm-operator schema generation

The use of $(ROOTDIR) in the paths for the vald-helm-operator schema and its dependency maintains consistency with previous changes and ensures robust schema generation.

Also applies to: 125-126


131-131: LGTM: Consistent path updates for vald-benchmark-job schema generation

The use of $(ROOTDIR) in the paths for the vald-benchmark-job schema and its dependency maintains consistency with previous changes and ensures robust schema generation.

Also applies to: 133-134


139-139: LGTM: Consistent path updates for vald-benchmark-scenario schema generation

The use of $(ROOTDIR) in the paths for the vald-benchmark-scenario schema and its dependency maintains consistency with previous changes and ensures robust schema generation.

Also applies to: 141-142


147-147: LGTM: Consistent path updates for vald-benchmark-operator schema generation

The use of $(ROOTDIR) in the paths for the vald-benchmark-operator schema and its dependency maintains consistency with previous changes and ensures robust schema generation.

Also applies to: 149-150


Line range hint 40-150: LGTM: Comprehensive path refactoring improves Makefile robustness

This PR consistently updates all relevant paths in the Makefile to use $(ROOTDIR). This change affects various targets including Helm chart packaging, documentation generation, and schema generation for multiple components (Vald, vald-helm-operator, vald-benchmark-operator, vald-readreplica, etc.).

The refactoring improves the robustness of the Makefile by ensuring that correct paths are used regardless of the current working directory. This consistency across all targets enhances maintainability and reduces the risk of path-related errors.

Overall, these changes represent a positive improvement to the build system.

internal/info/info.go (7)

40-43: Addition of 'valdReplacer' field enhances URL handling in stack traces.

The introduction of the valdReplacer *strings.Replacer field to the info struct allows for efficient and consistent URL replacements when generating stack traces. This enhances the functionality of the info package by improving the accuracy of stack trace URLs.


119-126: Definition of new constants improves code readability and maintainability.

Introducing constants like goSrc, goMod, and googleGolang simplifies path handling and makes the code more readable. This practice reduces magic strings and potential errors from mistyped strings.


311-331: Enhanced URL construction logic improves stack trace accuracy.

The updated logic for generating URLs in the getDetail method correctly handles various cases, such as Go source files and Google libraries. This refinement ensures that stack trace URLs point to the exact locations in the respective repositories, aiding in debugging and navigation.


352-352: Appropriate use of valdReplacer for URL replacement.

Using i.valdReplacer.Replace effectively replaces the relevant parts of the file path to construct accurate URLs for stack traces related to the Vald repository.


354-354: Consistent URL replacement with valdReplacer.

Continuing to utilize i.valdReplacer.Replace ensures consistent handling of file paths when generating URLs, which enhances maintainability.


420-422: Lazy initialization of valdReplacer prevents nil pointer dereference.

By initializing valdReplacer within the prepare method only if it is nil, the code ensures that valdReplacer is ready when needed without redundant initializations.


430-432: Addition of ShortString method provides concise stack trace representation.

The ShortString method offers a succinct way to represent stack trace information, which can be useful for logging purposes where full details are unnecessary.

coderabbitai[bot]
coderabbitai bot previously approved these changes Oct 3, 2024
Copy link

codecov bot commented Oct 3, 2024

Codecov Report

Attention: Patch coverage is 0% with 30 lines in your changes missing coverage. Please review.

Project coverage is 23.98%. Comparing base (da0ac80) to head (78ec9c8).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
internal/info/info.go 0.00% 28 Missing ⚠️
hack/docker/gen/main.go 0.00% 1 Missing ⚠️
internal/net/grpc/errdetails/errdetails.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2670      +/-   ##
==========================================
- Coverage   23.99%   23.98%   -0.01%     
==========================================
  Files         539      539              
  Lines       47179    47195      +16     
==========================================
+ Hits        11319    11321       +2     
- Misses      35090    35105      +15     
+ Partials      770      769       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kpango kpango requested a review from vankichi October 4, 2024 04:35
@vankichi vankichi merged commit da446c0 into main Oct 4, 2024
190 of 193 checks passed
@vankichi vankichi deleted the refactor/makefile/add-absolute-path branch October 4, 2024 05:04
vdaas-ci pushed a commit that referenced this pull request Oct 4, 2024
kpango added a commit that referenced this pull request Oct 7, 2024
…Makefile (#2673)

* Refactor use Absolute path for Makefile (#2670)

Signed-off-by: kpango <[email protected]>

* Apply suggestions from code review

Signed-off-by: Kiichiro YUKAWA <[email protected]>

---------

Signed-off-by: kpango <[email protected]>
Signed-off-by: Kiichiro YUKAWA <[email protected]>
Co-authored-by: Yusuke Kato <[email protected]>
Co-authored-by: Kiichiro YUKAWA <[email protected]>
@kpango kpango mentioned this pull request Oct 11, 2024
takuyaymd pushed a commit to takuyaymd/vald that referenced this pull request Dec 2, 2024
takuyaymd pushed a commit to takuyaymd/vald that referenced this pull request Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants