Skip to content

Conversation

@albertocavalcante
Copy link
Owner

@albertocavalcante albertocavalcante commented Jan 25, 2026

Summary

Add Buck2 scaffolding alongside existing Gradle and Bazel builds for learning and comparing build systems in a real project.

  • Basic Buck2 configuration (.buckconfig, .buckversion, .buckroot)
  • Platform definitions using prelude platforms
  • CI workflow that builds and runs on Linux and macOS
  • Example targets (genrule, sh_binary, export_file)
  • Starlark lint job in CI (Buck2's equivalent to buildifier)

Background

This is a learning/comparison project to explore build system limitations, pros/cons, and benchmarks in a real-life codebase. Gradle remains the "official" build system.

Notes

  • Builds require --target-platforms=prelude//platforms:default flag due to prelude's use of select() in rule definitions
  • Buck2 does not have a direct equivalent to Bazel's buildifier, but buck2 starlark lint provides linting
  • Prelude is cloned at CI time from github.com/facebook/buck2-prelude

Test plan

  • buck2 build //... succeeds locally
  • buck2 run //examples/hello:greet outputs expected message
  • buck2 starlark lint passes on all BUCK files
  • CI workflow passes on Linux and macOS

Summary by CodeRabbit

  • New Features

    • Added Buck2 as a supported build system alongside existing tools, including example build targets and a minimal runnable example.
  • Documentation

    • Added a hello-world example with usage instructions and a demo script.
  • Chores

    • Introduced Buck2 configuration, platform/toolchain scaffolding, ignore patterns, and a Buck2 version marker.
    • Added CI workflow for linting and building on Linux and macOS.

✏️ Tip: You can customize this high-level summary in your review settings.

Add Buck2 scaffolding alongside existing Gradle and Bazel builds for
learning and comparing build systems in a real project.

Includes:
- Basic Buck2 configuration (.buckconfig, .buckversion, .buckroot)
- Platform definitions using prelude platforms
- CI workflow that builds and runs on Linux and macOS
- Example targets (genrule, sh_binary, export_file)
- Starlark lint job in CI (Buck2's equivalent to buildifier)

Note: Builds require --target-platforms=prelude//platforms:default
due to prelude's use of select() in rule definitions.
Copilot AI review requested due to automatic review settings January 25, 2026 04:40
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @albertocavalcante, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request integrates Buck2 into the project as an experimental build system. The primary goal is to facilitate learning and comparison with existing Gradle and Bazel builds, without replacing them. It establishes the foundational configuration, introduces example build targets, and sets up necessary toolchains and platform definitions, laying the groundwork for further exploration of Buck2's capabilities within a real-world codebase.

Highlights

  • Buck2 Integration: Introduced Buck2 as a third build system for comparison and learning, alongside existing Gradle and Bazel setups.
  • Core Configuration: Added essential Buck2 configuration files (.buckconfig, .buckversion, BUCK root file) to define project structure, cells, and default build settings.
  • Example Targets: Provided concrete examples of Buck2 build targets, including genrule, sh_binary, and export_file, demonstrating basic functionality.
  • Toolchain and Platform Setup: Configured the system_genrule_toolchain and established platform definitions, leveraging Buck2's prelude for standard configurations.
  • Git Ignore Updates: Updated .gitignore to properly exclude Buck2-specific build artifacts and temporary files.
  • CI Integration Readiness: The PR description indicates a planned CI workflow for Buck2 builds and linting, setting the stage for automated validation, though specific CI config files are not part of this patch.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/ci-buck2.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link

coderabbitai bot commented Jan 25, 2026

Warning

Rate limit exceeded

@albertocavalcante has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 10 minutes and 56 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.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Walkthrough

Adds Buck2 configuration, CI workflow, example Buck targets, platform/toolchain placeholders, and repository ignores to enable Buck2-based builds and linting alongside existing build systems.

Changes

Cohort / File(s) Summary
Buck2 Core Configuration
​.buckconfig, ​.buckversion
New Buck2 project config and Buck2 version marker; sets cells, parser/build defaults, materialization and digest settings, and project ignore patterns.
Git Ignore
​.gitignore
Added Buck2-related ignore patterns: buck-out/, prelude/, .buck2-prelude/, and user.buckconfig.
Repository Root BUCK
BUCK
New root BUCK file introducing Buck2 usage, quick-start notes, and guidance about required --target-platforms flag.
CI Workflow
.github/workflows/ci-buck2.yml
New GitHub Actions workflow ("CI (Buck2)") with lint and build jobs; installs pinned Buck2, initializes prelude, runs starlark lint, audits cells, and builds/runs targets in a platform matrix.
Examples
examples/hello/BUCK, examples/hello/README.md, examples/hello/greet.sh
Added hello example: genrule (hello), sh_binary (greet), export_file (readme), README, and script demonstrating build/run.
Platforms / Toolchains / Third-party docs
platforms/BUCK, toolchains/BUCK, third_party/buck2/BUCK
Added platform placeholder, instantiated system_genrule_toolchain (name="genrule", PUBLIC), and third-party dependency documentation examples (commented).

Sequence Diagram(s)

sequenceDiagram
    participant GH as GitHub
    participant Runner as Runner
    participant Buck2 as Buck2
    participant Prelude as Prelude Repo
    participant Targets as Build Targets

    GH->>Runner: Trigger CI (push / PR / dispatch)

    rect rgba(100,150,200,0.5)
    Note over Runner: Lint Job
    Runner->>Buck2: Download & install pinned Buck2
    Runner->>Prelude: Clone/init prelude if missing
    Runner->>Buck2: Discover BUCK files (excl. prelude)
    Runner->>Buck2: Run starlark lint on files
    end

    rect rgba(150,100,200,0.5)
    Note over Runner: Build Job (matrix)
    Runner->>Buck2: Download & install Buck2 for matrix target
    Runner->>Prelude: Ensure prelude initialized
    Runner->>Buck2: Audit cells & list targets
    Runner->>Buck2: Build targets with --target-platforms
    Runner->>Targets: Run example target for verification
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped in with configs, neat and new,
Prelude and toolchains, and a CI too,
A tiny hello, a script that sings,
Buck2 warms the burrow with build-time springs,
Let's hop to builds and watch the outputs brew!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding Buck2 as a third build system alongside Gradle and Bazel for learning and comparison purposes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces Buck2 as a new build system for comparison purposes, which is a great initiative for exploring different build tools. The scaffolding is well-structured with clear configuration files and examples. I've identified a couple of areas for improvement to enhance reproducibility and user experience. My main suggestions are to pin the Buck2 version for more stable CI builds and to update the example commands in the README to include a required flag, ensuring they work as expected out of the box.

- Pin Buck2 version to 2026-01-19 for reproducible builds
- Add --target-platforms flag to README example commands
- Update CI workflow to use pinned version
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds Buck2 as a third build system alongside existing Gradle and Bazel builds for learning and comparing build systems. The addition is scaffolding-level, focusing on basic configuration and example targets rather than building the actual Groovy LSP project.

Changes:

  • Added Buck2 configuration files (.buckconfig, .buckversion, .buckroot)
  • Created example targets demonstrating genrule, sh_binary, and export_file rules
  • Implemented CI workflow with linting and cross-platform builds
  • Set up toolchain and platform definitions using Buck2 prelude

Reviewed changes

Copilot reviewed 10 out of 12 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
.buckconfig Main Buck2 configuration defining cells, platforms, and build settings
.buckversion Specifies Buck2 version (currently "latest")
.buckroot Empty marker file indicating Buck2 workspace root
BUCK Root build file with documentation about Buck2 setup
.gitignore Added Buck2-specific ignore patterns (buck-out/, prelude/, etc.)
examples/hello/BUCK Example build targets demonstrating Buck2 rules
examples/hello/greet.sh Shell script for sh_binary example
examples/hello/README.md Documentation for example targets
toolchains/BUCK Toolchain definitions using prelude's system toolchains
platforms/BUCK Reserved for future custom platform definitions
third_party/buck2/BUCK Reserved for external dependencies
.github/workflows/ci-buck2.yml CI workflow for building and linting Buck2 files

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@claude
Copy link

claude bot commented Jan 25, 2026

PR Review: Buck2 Build System Integration

Summary

This PR adds Buck2 build system scaffolding alongside existing Gradle and Bazel builds. The implementation is well-structured and follows best practices for configuration files, CI setup, and documentation.


✅ Strengths

1. Code Quality

  • Excellent documentation in configuration files (.buckconfig, BUCK files)
  • Clear separation of concerns (platforms, toolchains, examples)
  • Consistent use of comments to explain non-obvious decisions
  • Good use of shell scripting best practices (set -euo pipefail)

2. Security

  • ✅ No hardcoded credentials or secrets
  • ✅ Safe file operations (no path traversal risks)
  • ✅ Proper input validation in shell scripts
  • ✅ SHA-pinned GitHub Actions (e.g., checkout@11bd71901bbe5b1630ceea73d27597364c9af683)
  • ✅ Secure download verification with version pinning

3. Performance

  • ✅ Efficient CI path filters to avoid unnecessary builds
  • ✅ Deferred materialization configured for faster incremental builds
  • ✅ Shallow git clones (--depth 1) for prelude
  • ✅ Appropriate concurrency settings with cancel-in-progress

4. Git Workflow

  • ✅ Follows conventional commit format:
    • feat(build): add Buck2 as third build system for comparison
    • fix: address review feedback for Buck2 scaffolding
  • ✅ Commits are well-structured with descriptive bodies
  • ✅ No lint issues (Starlark lint passes)

⚠️ Areas of Concern

1. Testing (TDD) - ❌ BLOCKER

This PR introduces new build infrastructure but does not include any tests. According to AGENTS.md code-quality.md:

When TDD is Required:

  • New feature: ✅ YES — test defines behavior first
  • Config/wiring only: ⚠️ OPTIONAL — no logic to test

While this is primarily configuration, there are shell scripts with logic that should be tested:

  • examples/hello/greet.sh - Has parameter handling logic (NAME="${1:-World}")
  • CI workflow steps have complex bash logic for Buck2 installation and prelude initialization

Recommendation:

  • Add tests for greet.sh behavior (e.g., verify output with/without arguments)
  • Consider integration tests that verify Buck2 builds produce expected outputs
  • At minimum, verify that the example targets build and run successfully in CI (currently only checked in manual test plan)

2. Coverage Gap

The PR description states:

## Test plan
- [x] `buck2 build //...` succeeds locally
- [x] `buck2 run //examples/hello:greet` outputs expected message
- [x] `buck2 starlark lint` passes on all BUCK files
- [ ] CI workflow passes on Linux and macOS  ← INCOMPLETE

Issue: The fourth checklist item is incomplete, but the CI is actually passing. This should be checked off.

3. Potential Maintenance Burden

From .buckconfig:22-25:

# Stub cells for FB-internal references in the prelude.
# These map to prelude to allow parsing, but some rules may
# reference targets that don't exist in the open-source prelude.

Question: This comment suggests some Buck2 prelude rules may not work. Should we document which rules are known to be problematic? This could save future debugging time.


📋 Checklist Against Standards

Criterion Status Notes
Code Quality ✅ PASS Well-documented, clear structure
Kotlin Conventions N/A No Kotlin code in this PR
Null Safety N/A No Kotlin code in this PR
Error Handling ✅ PASS Shell scripts use proper error handling
Security ✅ PASS No secrets, safe operations, SHA-pinned actions
TDD ❌ FAIL No tests for shell script logic
Coverage ⚠️ INCOMPLETE Manual testing done, but incomplete checklist
Edge Cases ⚠️ UNKNOWN No tests to verify edge case handling
Performance ✅ PASS Efficient CI configuration
Git Workflow ✅ PASS Conventional commits, explicit file additions
Lint ✅ PASS Starlark lint passes

🎯 Action Items

Before Merge:

  1. [REQUIRED] Add tests for examples/hello/greet.sh:

    // Example test structure (adapt to your test framework)
    @Test fun `greet script outputs default greeting without arguments`()
    @Test fun `greet script outputs custom greeting with argument`()
  2. [REQUIRED] Update test plan checklist - check off the CI item (it's passing)

Nice to Have:
3. Document known limitations of buck2-prelude rules (which rules don't work due to FB-internal references)
4. Consider adding integration tests that verify Buck2 builds produce correct artifacts


🏆 Overall Assessment

This is a well-implemented scaffolding PR with excellent documentation and security practices. The main blocker is the absence of tests for shell script logic, which violates the TDD requirement in AGENTS.md.

Recommendation: Add tests for greet.sh before merging, then this will be ready to ship.


Review completed following .agent/rules/code-quality.md and .agent/rules/git-workflow.md

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

🤖 Fix all issues with AI agents
In `@examples/hello/README.md`:
- Around line 13-23: Update the usage examples in the README examples for the
hello package to include the required
--target-platforms=prelude//platforms:default flag; specifically add this flag
to the three invocations shown (the buck2 build //examples/hello/... line, both
buck2 run //examples/hello:greet lines, and the buck2 build
//examples/hello:hello --show-output line) so that all example commands invoke
the same platform selection used by the prelude genrule.
🧹 Nitpick comments (4)
.buckversion (1)

1-4: Pin Buck2 to a date-tagged release instead of latest for reproducible builds.

The latest tag moves on every Buck2 push and creates nondeterministic builds across CI runs. Use a specific date-tagged release (format: YYYY-MM-DD, e.g., 2026-01-19) to ensure all developers and CI agents use the same Buck2 version.

.github/workflows/ci-buck2.yml (3)

92-100: Add error handling for empty file list in lint step.

If no BUCK files are found (e.g., all deleted), xargs with an empty input will still invoke buck2 starlark lint with no arguments, which may produce unexpected behavior. Consider using xargs --no-run-if-empty (GNU) or checking the file count.

♻️ Suggested improvement
       - name: Lint BUCK files
         run: |
           # Find all BUCK files (excluding prelude which is external)
           # Use xargs to properly handle the file list
           echo "Finding BUCK files to lint..."
           find . -name 'BUCK' -not -path './prelude/*' | sort | tee /tmp/buck_files.txt
           echo ""
+          if [ ! -s /tmp/buck_files.txt ]; then
+            echo "No BUCK files found to lint"
+            exit 0
+          fi
           echo "Running starlark lint..."
-          xargs buck2 starlark lint < /tmp/buck_files.txt
+          xargs --no-run-if-empty buck2 starlark lint < /tmp/buck_files.txt

126-130: JDK setup may be unnecessary for current examples.

The current Buck2 examples (genrule, sh_binary, export_file) don't require Java. Consider removing the JDK setup step until Java-based Buck2 targets are added, to reduce CI time and dependencies. Alternatively, add a comment explaining the intent if this is preparation for future Java targets.


161-168: Consider extracting prelude initialization to a reusable action.

The prelude initialization logic is duplicated between the lint and build jobs. For maintainability, consider extracting this into a composite action or a reusable workflow step. This is a minor refactor that can be deferred.

- Pin prelude to commit 995098b for reproducible builds
- Update actions/checkout to v6.0.1 (matching other workflows)
- Update actions/setup-java to v5.1.0 (matching other workflows)
- Fix typo: kotlincd_toolchain -> kotlin_toolchain
@albertocavalcante
Copy link
Owner Author

RE: macOS runner version (macos-14 vs macos-15)

macos-14 is intentional: it provides Apple Silicon (aarch64) runners which match the buck2_target: aarch64-apple-darwin. Using macos-15 may not guarantee aarch64 architecture and could cause binary incompatibility.

The Buck2 build matrix is:

  • ubuntu-24.04x86_64-unknown-linux-gnu
  • macos-14aarch64-apple-darwin

This is consistent with how the runner architecture maps to the target triple.

Copilot AI review requested due to automatic review settings January 25, 2026 04:52
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 12 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Cache prelude directory keyed by BUCK2_PRELUDE_COMMIT
- Add TODO comment about dtolnay/install-buck2 action for future exploration
- Closes #1038
@albertocavalcante albertocavalcante merged commit 6f343fc into main Jan 25, 2026
23 of 24 checks passed
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