Skip to content

Bazel migration for Flink module #237

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

Merged
merged 23 commits into from
Jan 21, 2025
Merged

Conversation

kumar-zlai
Copy link
Contributor

@kumar-zlai kumar-zlai commented Jan 17, 2025

Summary

Migrated Flink module to Bazel from sbt.

Checklist

  • Added Unit Tests
  • Covered by existing CI
  • Integration tested
  • Documentation update

Summary by CodeRabbit

  • New Features

    • Added Scala library definitions for the main application and testing.
    • Introduced new Apache Flink dependencies for streaming, metrics, and client interactions.
  • Chores

    • Updated build configuration to support a modular Scala project structure.
    • Enhanced Maven repository with additional Flink-related libraries.

Copy link

coderabbitai bot commented Jan 17, 2025

Walkthrough

This pull request enhances the Flink project's build configuration by introducing three new Scala library and test suite definitions in flink/BUILD.bazel. Additionally, the maven_repository.bzl file is updated with several new Apache Flink dependencies, version 1.17.0, to support various functionalities including streaming and testing utilities.

Changes

File Change Summary
flink/BUILD.bazel Added three new entities: lib (main Scala library), test-lib (Scala test library), and test (Scala test suite)
tools/build_rules/dependencies/maven_repository.bzl Added 7 new Flink-related Maven dependencies for version 1.17.0

Possibly related PRs

Suggested reviewers

  • nikhil-zlai
  • piyush-zlai

Poem

🚀 Bazel builds with Flink's might,
Libraries dancing, tests burning bright.
Dependencies aligned, code takes flight,
Scala's magic in build's pure delight!
🌟 Modular dreams take their height.

Warning

Review ran into problems

🔥 Problems

GitHub Actions: Resource not accessible by integration - https://docs.github.com/rest/actions/workflow-runs#list-workflow-runs-for-a-repository.

Please grant the required permissions to the CodeRabbit GitHub App under the organization or repository settings.


🪧 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

Copy link

@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

🧹 Nitpick comments (1)
flink/BUILD.bazel (1)

26-101: Consolidate test dependencies

test-lib and test targets have duplicate dependencies.

# Create a variable at the top of the file
+TEST_COMMON_DEPS = [
+    ":lib",
+    "//online:lib",
+    "//api:thrift",
+    # ... rest of common dependencies
+]

 scala_library(
     name = "test-lib",
     srcs = glob(["src/test/**/*.scala"]),
     visibility = ["//visibility:public"],
-    deps = [
-        ":lib",
-        "//online:lib",
-        # ... current deps
-    ],
+    deps = TEST_COMMON_DEPS,
 )

 scala_test_suite(
     name = "test",
     srcs = glob(["src/test/**/*.scala"]),
     visibility = ["//visibility:public"],
-    deps = [
-        ":lib",
-        "//online:lib",
-        # ... current deps
-    ],
+    deps = TEST_COMMON_DEPS,
 )
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 4b64daf and f449cbf.

📒 Files selected for processing (2)
  • flink/BUILD.bazel (1 hunks)
  • tools/build_rules/dependencies/maven_repository.bzl (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: no_spark_scala_tests
🔇 Additional comments (3)
tools/build_rules/dependencies/maven_repository.bzl (1)

54-61: Consider upgrading to Flink 1.18.1

Flink 1.17.0 is not the latest stable version.

✅ Verification successful

Current Flink version 1.17.0 is acceptable

While Flink 1.20.0 is available, 1.17.0 is secure and consistently used across the codebase. Upgrade at your convenience.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check latest Flink version and CVEs
curl -s https://api.github.com/repos/apache/flink/releases/latest | jq -r '.tag_name'
gh api graphql -f query='
{
  securityVulnerabilities(first: 5, ecosystem: MAVEN, package: "org.apache.flink:flink-core") {
    nodes {
      advisory {
        summary
        severity
      }
      vulnerableVersionRange
    }
  }
}'

Length of output: 614


Script:

#!/bin/bash
# Check latest Flink version from Maven Central
curl -s "https://search.maven.org/solrsearch/select?q=g:org.apache.flink+AND+a:flink-core&core=gav&rows=1&wt=json" | jq -r '.response.docs[0].v'

# Verify if this version is used elsewhere in the codebase
rg "org\.apache\.flink.*1\." -g '*.{xml,bzl,bazel}'

Length of output: 950


Script:

#!/bin/bash
# Check latest stable 1.x version from Maven Central
curl -s "https://search.maven.org/solrsearch/select?q=g:org.apache.flink+AND+a:flink-core+AND+v:1.*&core=gav&rows=5&wt=json" | jq -r '.response.docs[].v' | grep -v 'preview\|alpha\|beta\|rc' | sort -V | tail -n1

Length of output: 220

flink/BUILD.bazel (2)

1-24: LGTM: Main library configuration

Dependencies and source globs are well-structured.


66-66: Verify test coverage

PR description indicates no new tests were added.

Also applies to: 67-67

✅ Verification successful

Test coverage verified

The flink module has comprehensive test coverage with multiple test files in the correct location. The glob pattern in BUILD.bazel is properly configured to include these tests.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check test files
echo "Test files found:"
fd -e scala . src/test/

Length of output: 167


Script:

#!/bin/bash
# Find all Scala test files in the repository
echo "=== Searching for Scala files with 'test' in path ==="
fd -e scala -I test

echo -e "\n=== Searching for test annotations/classes in Scala files ==="
rg -l "(@Test|extends.*Test|class.*Test)" -g "*.scala"

Length of output: 12971

name = "test",
srcs = glob(["src/test/**/*.scala"]),
visibility = ["//visibility:public"],
deps = [
Copy link
Contributor

Choose a reason for hiding this comment

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

there seems to be a lot of repetition across targets - i would split these into two python arrays - flink_deps, flink_test_deps and re-use in three places.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

@nikhil-zlai nikhil-zlai left a comment

Choose a reason for hiding this comment

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

one comment but lgtm

"//aggregator:lib",
"//tools/build_rules/spark:spark-exec",
# Libraries
scala_artifact("org.apache.flink:flink-streaming-scala"),
Copy link
Contributor

Choose a reason for hiding this comment

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

when we build the flink jar - which of these modules are included and which ones are excluded / treated as provided? We'll want to mimic the sbt assembly behavior here (not blocking this pr but we'll need to address / tackle)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good point. I think by default bazel includes all dependency jars in the fat jar and we would need additional config setup to replicate excluded/provided behavior in sbt which i'm working as part of separate PR.

Copy link

@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

🧹 Nitpick comments (3)
flink/BUILD.bazel (3)

26-26: Restrict glob pattern to prevent accidental inclusion.

Add exclusions for temporary/hidden files:

glob(["src/main/**/*.scala"], exclude = [".*", "*~"])

52-58: Optimize ScalaTest dependencies.

scalatest already includes core modules. Remove redundant dependencies:

-    scala_artifact("org.scalatest:scalatest-matchers-core"),
-    scala_artifact("org.scalatest:scalatest-core"),
     scala_artifact("org.scalatest:scalatest"),

67-79: Simplify test target structure.

test-lib and test suite compile same sources. Consider:

  1. Remove test-lib and move deps to test suite, or
  2. Make test suite use test-lib's classes instead of recompiling sources
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 2e8fa95 and 6a08127.

📒 Files selected for processing (1)
  • flink/BUILD.bazel (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: no_spark_scala_tests
🔇 Additional comments (2)
flink/BUILD.bazel (2)

1-22: Reduce dependency duplication between flink_deps and flink_test_deps.

Create a base deps list and extend it for tests:

base_flink_deps = [
    scala_artifact("org.apache.flink:flink-streaming-scala"),
    # ... common deps
]
flink_deps = base_flink_deps
flink_test_deps = base_flink_deps + [
    # test-only deps
]

28-38: Clarify runtime vs provided dependencies.

Need to specify which dependencies should be bundled vs provided in the final jar.

@kumar-zlai kumar-zlai merged commit ddd29b6 into main Jan 21, 2025
4 checks passed
@kumar-zlai kumar-zlai deleted the kumarteja/flink-bazel-migration branch January 21, 2025 20:42
@coderabbitai coderabbitai bot mentioned this pull request Feb 13, 2025
4 tasks
@coderabbitai coderabbitai bot mentioned this pull request Apr 24, 2025
Closed
4 tasks
kumar-zlai added a commit that referenced this pull request Apr 25, 2025
## Summary
Migrated `Flink` module to Bazel from sbt.

## Checklist
- [ ] Added Unit Tests
- [x] Covered by existing CI
- [ ] Integration tested
- [ ] Documentation update



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
	- Added Scala library definitions for the main application and testing.
- Introduced new Apache Flink dependencies for streaming, metrics, and
client interactions.

- **Chores**
- Updated build configuration to support a modular Scala project
structure.
	- Enhanced Maven repository with additional Flink-related libraries.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
kumar-zlai added a commit that referenced this pull request Apr 29, 2025
## Summary
Migrated `Flink` module to Bazel from sbt.

## Checklist
- [ ] Added Unit Tests
- [x] Covered by existing CI
- [ ] Integration tested
- [ ] Documentation update



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
	- Added Scala library definitions for the main application and testing.
- Introduced new Apache Flink dependencies for streaming, metrics, and
client interactions.

- **Chores**
- Updated build configuration to support a modular Scala project
structure.
	- Enhanced Maven repository with additional Flink-related libraries.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
chewy-zlai pushed a commit that referenced this pull request May 15, 2025
## Summary
Migrated `Flink` module to Bazel from sbt.

## Checklist
- [ ] Added Unit Tests
- [x] Covered by existing CI
- [ ] Integration tested
- [ ] Documentation update



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
	- Added Scala library definitions for the main application and testing.
- Introduced new Apache Flink dependencies for streaming, metrics, and
client interactions.

- **Chores**
- Updated build configuration to support a modular Scala project
structure.
	- Enhanced Maven repository with additional Flink-related libraries.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
chewy-zlai pushed a commit that referenced this pull request May 15, 2025
## Summary
Migrated `Flink` module to Bazel from sbt.

## Checklist
- [ ] Added Unit Tests
- [x] Covered by existing CI
- [ ] Integration tested
- [ ] Documentation update



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
	- Added Scala library definitions for the main application and testing.
- Introduced new Apache Flink dependencies for streaming, metrics, and
client interactions.

- **Chores**
- Updated build configuration to support a modular Scala project
structure.
	- Enhanced Maven repository with additional Flink-related libraries.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
chewy-zlai pushed a commit that referenced this pull request May 16, 2025
## Summary
Migrated `Flink` module to Bazel from sbt.

## Cheour clientslist
- [ ] Added Unit Tests
- [x] Covered by existing CI
- [ ] Integration tested
- [ ] Documentation update



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
	- Added Scala library definitions for the main application and testing.
- Introduced new Apache Flink dependencies for streaming, metrics, and
client interactions.

- **Chores**
- Updated build configuration to support a modular Scala project
structure.
	- Enhanced Maven repository with additional Flink-related libraries.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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.

3 participants