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

build: add bazel rules #3

Merged
merged 1 commit into from
Mar 19, 2024
Merged

build: add bazel rules #3

merged 1 commit into from
Mar 19, 2024

Conversation

TzahiTaub
Copy link
Contributor

@TzahiTaub TzahiTaub commented Mar 17, 2024

This change is Reviewable

@codecov-commenter
Copy link

codecov-commenter commented Mar 17, 2024

Codecov Report

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

Project coverage is 35.00%. Comparing base (033efdb) to head (94821f2).

Files Patch % Lines
crates/committer_cli/src/main.rs 0.00% 13 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##              main       #3       +/-   ##
============================================
- Coverage   100.00%   35.00%   -65.00%     
============================================
  Files            1        2        +1     
  Lines            7       20       +13     
  Branches         7       20       +13     
============================================
  Hits             7        7               
- Misses           0       13       +13     

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

Copy link
Collaborator

@dorimedini-starkware dorimedini-starkware left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 4 files at r1, all commit messages.
Reviewable status: 3 of 4 files reviewed, 2 unresolved discussions (waiting on @alon-dotan-starkware and @TzahiTaub)


crates/committer/BUILD line 10 at r1 (raw file):

    edition = "2021",
    proc_macro_deps = all_crate_deps(proc_macro = True),
    visibility = ["//visibility:public"],

why does blockifier repo use "//crates:__subpackages__" visibility?

Code quote:

visibility = ["//visibility:public"],

crates/committer/BUILD line 11 at r1 (raw file):

    proc_macro_deps = all_crate_deps(proc_macro = True),
    visibility = ["//visibility:public"],
    deps = all_crate_deps(),

same format and order as the blockifier BUILD file

Suggestion:

    name="committer_exe",
    srcs=glob(["src/**/*.rs"]),
    visibility=["//visibility:public"],
    deps=all_crate_deps(),
    proc_macro_deps=all_crate_deps(proc_macro=True),
    edition="2021",

Copy link
Collaborator

@dorimedini-starkware dorimedini-starkware left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 4 files at r1.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @alon-dotan-starkware and @TzahiTaub)


crates/committer/src/main.rs line 5 at r1 (raw file):

/// Gets a binary input and an output file from the command line.
/// Reads the input file, adds 1 to each byte, and writes the result to the output file.

forward-facing comment

Suggestion:

/// Main entry point of the committer CLI.

crates/committer/src/main.rs line 7 at r1 (raw file):

/// Reads the input file, adds 1 to each byte, and writes the result to the output file.
fn main() {
    // Open the input file

we don't have comment linter scripts ATM

Suggestion:

// Open the input file.

crates/committer/src/main.rs line 22 at r1 (raw file):

    }
    std::fs::write(output_file_name, bytes).expect("Failed to write output");
}

remove the dummy logic before merging (we keep the input-output file logic, it will be useful)

Suggestion:

use std::env;
use std::path::Path;

/// Gets a binary input and an output file from the command line.
/// Reads the input file, adds 1 to each byte, and writes the result to the output file.
fn main() {
    // Open the input file
    let args: Vec<String> = env::args().collect();
    let input_file_name = Path::new(&args[1]);
    let output_file_name = Path::new(&args[2]);
    assert!(
        input_file_name.is_absolute() && output_file_name.is_absolute(),
        "Given paths must be absolute"
    );
    
    // Business logic to be implemented here.
    let output = std::fs::read(input_file_name).unwrap();
    
    // Output to file.
    std::fs::write(output_file_name, output).expect("Failed to write output");
}

@TzahiTaub TzahiTaub force-pushed the tzahi/add_bazel_rules branch 2 times, most recently from ec08531 to 56a74f2 Compare March 17, 2024 15:09
Copy link
Contributor Author

@TzahiTaub TzahiTaub left a comment

Choose a reason for hiding this comment

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

Reviewable status: 3 of 5 files reviewed, 5 unresolved discussions (waiting on @alon-dotan-starkware and @dorimedini-starkware)


crates/committer/BUILD line 10 at r1 (raw file):

Previously, dorimedini-starkware wrote…

why does blockifier repo use "//crates:__subpackages__" visibility?

I had to change it to use it in the main repo. As far as I understand, the blockifier repo target you mention is not used externally, but is a dependency of the py_lib under crates/native_blockifier/BUILD which is the one that is used externally, and also has a visibility public. We use the target above directly.


crates/committer/BUILD line 11 at r1 (raw file):

Previously, dorimedini-starkware wrote…

same format and order as the blockifier BUILD file

Done.


crates/committer/src/main.rs line 5 at r1 (raw file):

Previously, dorimedini-starkware wrote…

forward-facing comment

Done.


crates/committer/src/main.rs line 7 at r1 (raw file):

Previously, dorimedini-starkware wrote…

we don't have comment linter scripts ATM

Done.


crates/committer/src/main.rs line 22 at r1 (raw file):

Previously, dorimedini-starkware wrote…

remove the dummy logic before merging (we keep the input-output file logic, it will be useful)

Done.

@TzahiTaub TzahiTaub changed the title Add bazel rules build: add bazel rules Mar 17, 2024
Copy link
Collaborator

@dorimedini-starkware dorimedini-starkware left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r2, 1 of 1 files at r3, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @alon-dotan-starkware and @TzahiTaub)


crates/committer/src/lib.rs line 0 at r3 (raw file):
ah... didn't notice the file locations...
the committer crate should be a lib crate.

  1. restore this file
  2. move main.rs into crates/committer_cli/src/main.rs (will need another Cargo.toml for this)

Copy link
Contributor Author

@TzahiTaub TzahiTaub left a comment

Choose a reason for hiding this comment

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

Reviewable status: 2 of 7 files reviewed, 1 unresolved discussion (waiting on @alon-dotan-starkware and @dorimedini-starkware)


crates/committer/src/lib.rs line at r3 (raw file):

Previously, dorimedini-starkware wrote…

ah... didn't notice the file locations...
the committer crate should be a lib crate.

  1. restore this file
  2. move main.rs into crates/committer_cli/src/main.rs (will need another Cargo.toml for this)

Done.

Copy link
Contributor Author

@TzahiTaub TzahiTaub left a comment

Choose a reason for hiding this comment

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

Reviewable status: 2 of 9 files reviewed, 2 unresolved discussions (waiting on @alon-dotan-starkware and @dorimedini-starkware)


Cargo.lock line 13 at r4 (raw file):

[[package]]
name = "committer_cli"

Does this make sense? It's like one package in the repo states in depends on another?

Copy link
Collaborator

@dorimedini-starkware dorimedini-starkware left a comment

Choose a reason for hiding this comment

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

Reviewed 7 of 7 files at r4, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @alon-dotan-starkware and @TzahiTaub)


crates/committer_cli/Cargo.toml line 7 at r4 (raw file):

repository.workspace = true
license-file.workspace = true
description = "Cli for the committer package."

should this be all caps?

Suggestion:

CLI

crates/committer_cli/Cargo.toml line 10 at r4 (raw file):

[lints]
workspace = true

you sure this is how we get both clippy and rust lints?

Code quote:

[lints]
workspace = true

Copy link
Collaborator

@dorimedini-starkware dorimedini-starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @alon-dotan-starkware and @TzahiTaub)


crates/committer/BUILD line 0 at r4 (raw file):
delete this?

Copy link
Collaborator

@dorimedini-starkware dorimedini-starkware left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r5, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @alon-dotan-starkware and @TzahiTaub)

Copy link
Contributor Author

@TzahiTaub TzahiTaub left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @alon-dotan-starkware and @dorimedini-starkware)


crates/committer_cli/Cargo.toml line 10 at r4 (raw file):

Previously, dorimedini-starkware wrote…

you sure this is how we get both clippy and rust lints?

Yes, for rust/cargo 1.74 and above


crates/committer/BUILD line at r4 (raw file):

Previously, dorimedini-starkware wrote…

delete this?

Done.

Copy link
Contributor

@alon-dotan-starkware alon-dotan-starkware left a comment

Choose a reason for hiding this comment

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

Reviewed 4 of 7 files at r4.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @dorimedini-starkware)


Cargo.lock line 13 at r4 (raw file):

Previously, TzahiTaub (Tzahi) wrote…

Does this make sense? It's like one package in the repo states in depends on another?

Why do we need a different crate here?

Copy link
Contributor Author

@TzahiTaub TzahiTaub left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @dorimedini-starkware)


Cargo.lock line 13 at r4 (raw file):

Previously, alon-dotan-starkware wrote…

Why do we need a different crate here?

@dorimedini-starkware ?

Copy link
Collaborator

@dorimedini-starkware dorimedini-starkware left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @alon-dotan-starkware and @TzahiTaub)


Cargo.lock line 13 at r4 (raw file):

Previously, TzahiTaub (Tzahi) wrote…

@dorimedini-starkware ?

because this crate is an executable; we want to separate the business logic (library crate) from an executable that wraps it.
the lib crate will be published to crates.io, the executable (only used in our python backend) will not.

@TzahiTaub TzahiTaub added this pull request to the merge queue Mar 19, 2024
Merged via the queue into main with commit 40cd251 Mar 19, 2024
10 checks passed
@TzahiTaub TzahiTaub deleted the tzahi/add_bazel_rules branch May 7, 2024 09:56
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.

4 participants