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

feat: Added the ability to use the TEACH-ME mode #221

Merged
merged 34 commits into from
Nov 14, 2024
Merged

feat: Added the ability to use the TEACH-ME mode #221

merged 34 commits into from
Nov 14, 2024

Conversation

FroVolod
Copy link
Collaborator

@FroVolod FroVolod commented Sep 13, 2024

./cargo-near --teach-me near new test

Screenshot 2024-10-03 at 19 51 28

./cargo-near --teach-me near build --manifest-path /Users/frovolod/Documents/NEAR/neardevhub-contract-1/Cargo.toml

Screenshot 2024-10-04 at 08 08 49

./cargo-near --teach-me near deploy --manifest-path /Users/frovolod/Documents/NEAR/neardevhub-contract-1/Cargo.toml
Screen.Recording.2024-10-04.at.08.16.08.mov

@FroVolod FroVolod marked this pull request as ready for review October 4, 2024 05:23
@FroVolod
Copy link
Collaborator Author

FroVolod commented Oct 4, 2024

@race-of-sloths

@race-of-sloths-bot
Copy link

@FroVolod Thank you for your contribution! Your pull request is now a part of the Race of Sloths!

Shows profile picture for the author of the PR

Current status: waiting for scoring

We're waiting for maintainer to score this pull request with @race-of-sloths score [0,1,2,3,5,8,13] command. Alternatively, autoscoring [1,2] will be applied for this pull request

What is the Race of Sloths

Race of Sloths is a friendly competition where you can participate in challenges and compete with other open-source contributors within your normal workflow

For contributors:

  • Tag @race-of-sloths inside your pull requests
  • Wait for the maintainer to review and score your pull request
  • Check out your position in the Leaderboard
  • Keep weekly and monthly streaks to reach higher positions
  • Boast your contributions with a dynamic picture of your Profile

For maintainers:

  • Score pull requests that participate in the Race of Sloths
  • Engage contributors with fair scoring and fast responses so they keep their streaks
  • Promote the Race to the point where the Race starts promoting you
  • Grow the community of your contributors

Feel free to check our website for additional details!

Bot commands
  • For contributors
    • Include a PR: @race-of-sloths include to enter the Race with your PR
  • For maintainers:
    • Invite contributor @race-of-sloths invite to invite the contributor to participate in a race or include it, if it's already a runner.
    • Assign points: @race-of-sloths score [1/2/3/5/8/13] to award points based on your assessment.
    • Reject this PR: @race-of-sloths exclude to send this PR back to the drawing board.
    • Exclude repo: @race-of-sloths pause to stop bot activity in this repo until @race-of-sloths unpause command is called

@FroVolod FroVolod marked this pull request as draft October 7, 2024 12:49
@FroVolod
Copy link
Collaborator Author

FroVolod commented Oct 7, 2024

Screenshot 2024-10-07 at 15 04 42

@FroVolod
Copy link
Collaborator Author

FroVolod commented Oct 11, 2024

Three alternative commands were tested:

cargo near --teach-me new test
./cargo-near  near --teach-me new test
./cargo-near --teach-me near new test

The execution of the program is the same:
Screenshot 2024-10-11 at 19 29 09

@FroVolod
Copy link
Collaborator Author

Screen.Recording.2024-11-10.at.23.06.23.mov

@FroVolod FroVolod marked this pull request as ready for review November 11, 2024 06:24
dj8yfo
dj8yfo previously approved these changes Nov 12, 2024
cargo-near-build/src/types/cargo/metadata.rs Outdated Show resolved Hide resolved
cargo-near/src/lib.rs Outdated Show resolved Hide resolved
cargo-near/src/main.rs Outdated Show resolved Hide resolved
cargo-near-build/src/cargo_native/compile.rs Outdated Show resolved Hide resolved
cargo-near/src/main.rs Show resolved Hide resolved
cargo-near-build/src/types/cargo/metadata.rs Outdated Show resolved Hide resolved
Comment on lines 42 to 106
if env::var("RUST_LOG").is_ok() {
let environment = if std::env::var(env_keys::nep330::BUILD_ENVIRONMENT).is_ok() {
"container".cyan()
} else {
"host".purple()
};
let my_formatter =
cargo_near::types::my_formatter::MyFormatter::from_environment(environment);

let env_filter = EnvFilter::from_default_env();
let format = format::debug_fn(move |writer, _field, value| write!(writer, "{:?}", value));

tracing_subscriber::registry()
.with(
tracing_subscriber::fmt::layer()
.event_format(my_formatter)
.fmt_fields(format)
.with_filter(env_filter),
)
.init();
tracing_subscriber::registry()
.with(
tracing_subscriber::fmt::layer()
.event_format(my_formatter)
.fmt_fields(format)
.with_filter(EnvFilter::from_default_env()),
)
.init();
} else if cli_cmd.teach_me || cli_near_args.teach_me {
let env_filter = EnvFilter::from_default_env()
.add_directive(tracing::Level::WARN.into())
.add_directive("near_teach_me=info".parse()?)
.add_directive("near_cli_rs=info".parse()?)
.add_directive("tracing_instrument=info".parse()?);
tracing_subscriber::registry()
.with(
tracing_subscriber::fmt::layer()
.without_time()
.with_target(false),
)
.with(env_filter)
.init();
} else {
let indicatif_layer = IndicatifLayer::new()
.with_progress_style(
ProgressStyle::with_template(
"{spinner:.blue}{span_child_prefix} {span_name} {msg} {span_fields}",
)
.unwrap()
.tick_strings(&[
"▹▹▹▹▹",
"▸▹▹▹▹",
"▹▸▹▹▹",
"▹▹▸▹▹",
"▹▹▹▸▹",
"▹▹▹▹▸",
"▪▪▪▪▪",
]),
)
.with_span_child_prefix_symbol("↳ ");
let env_filter = EnvFilter::from_default_env()
.add_directive(tracing::Level::WARN.into())
.add_directive("near_cli_rs=info".parse()?)
.add_directive("tracing_instrument=info".parse()?);
tracing_subscriber::registry()
.with(
tracing_subscriber::fmt::layer()
.without_time()
.with_writer(indicatif_layer.get_stderr_writer()),
)
.with(indicatif_layer)
.with(env_filter)
.init();
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

i strongly suggest

  1. making these blocks a function with following signature
pub fn setup_tracing(rust_log_env_is_set: bool, teach_me_flag_is_set: bool) {
	....
}
  1. putting it and related tracing-* imports into cargo-near/src/lib.rs
  2. then this function https://github.com/near/cargo-near/blob/main/integration-tests/src/lib.rs#L11-L32 can be replaced with
pub fn setup_tracing() {
	cargo_near::setup_tracing(true, false);
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

skip_all
)]
fn execute_git_commands(project_dir: &std::path::Path) -> near_cli_rs::CliResult {
tracing::Span::current().pb_set_message("`git` commands ...");
Copy link
Collaborator

Choose a reason for hiding this comment

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

this one doesn't get displayed on --teach-me, but we probably can figure this out in subsequent prs

cargo-near-build/src/env_keys.rs Outdated Show resolved Hide resolved
@dj8yfo
Copy link
Collaborator

dj8yfo commented Nov 12, 2024

@race-of-sloths score 13

@race-of-sloths
Copy link

race-of-sloths commented Nov 12, 2024

@FroVolod Thank you for your contribution! Your pull request is now a part of the Race of Sloths!

Shows inviting banner with latest news.

Shows profile picture for the author of the PR

Current status: executed
Reviewer Score
@dj8yfo 13

Your contribution is much appreciated with a final score of 13!
You have received 147 (130 base + 10 weekly bonus + 5% lifetime bonus) Sloth points for this contribution

@dj8yfo received 25 Sloth Points for reviewing and scoring this pull request.

Another weekly streak completed, well done @FroVolod! To keep your weekly streak and get another bonus make pull request next week! Looking forward to see you in race-of-sloths

What is the Race of Sloths

Race of Sloths is a friendly competition where you can participate in challenges and compete with other open-source contributors within your normal workflow

For contributors:

  • Tag @race-of-sloths inside your pull requests
  • Wait for the maintainer to review and score your pull request
  • Check out your position in the Leaderboard
  • Keep weekly and monthly streaks to reach higher positions
  • Boast your contributions with a dynamic picture of your Profile

For maintainers:

  • Score pull requests that participate in the Race of Sloths and receive a reward
  • Engage contributors with fair scoring and fast responses so they keep their streaks
  • Promote the Race to the point where the Race starts promoting you
  • Grow the community of your contributors

Feel free to check our website for additional details!

Bot commands
  • For contributors
    • Include a PR: @race-of-sloths include to enter the Race with your PR
  • For maintainers:
    • Invite contributor @race-of-sloths invite to invite the contributor to participate in a race or include it, if it's already a runner.
    • Assign points: @race-of-sloths score [1/2/3/5/8/13] to award points based on your assessment.
    • Reject this PR: @race-of-sloths exclude to send this PR back to the drawing board.
    • Exclude repo: @race-of-sloths pause to stop bot activity in this repo until @race-of-sloths unpause command is called

@dj8yfo dj8yfo merged commit 175aaeb into main Nov 14, 2024
17 checks passed
@dj8yfo dj8yfo deleted the teach-me branch November 14, 2024 12:33
@frol frol mentioned this pull request Nov 8, 2024
dj8yfo pushed a commit that referenced this pull request Nov 14, 2024
## 🤖 New release
* `cargo-near`: 0.11.0 -> 0.12.0 (⚠️ API breaking changes)
* `cargo-near-build`: 0.3.0 -> 0.3.1 (✓ API compatible changes)

### ⚠️ `cargo-near` breaking changes

```
--- failure constructible_struct_adds_field: externally-constructible struct adds field ---

Description:
A pub struct constructible with a struct literal has a new pub field. Existing struct literals must be updated to include the new field.
        ref: https://doc.rust-lang.org/reference/expressions/struct-expr.html
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.36.0/src/lints/constructible_struct_adds_field.ron

Failed in:
  field CliNearArgs.teach_me in /tmp/.tmp06Ielo/cargo-near/cargo-near/src/lib.rs:30
  field InteractiveClapContextScopeForNearArgs.teach_me in /tmp/.tmp06Ielo/cargo-near/cargo-near/src/lib.rs:30

--- failure constructible_struct_adds_private_field: struct no longer constructible due to new private field ---

Description:
A struct constructible with a struct literal has a new non-public field. It can no longer be constructed using a struct literal outside of its crate.
        ref: https://doc.rust-lang.org/reference/expressions/struct-expr.html
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.36.0/src/lints/constructible_struct_adds_private_field.ron

Failed in:
  field NearArgs.teach_me in /tmp/.tmp06Ielo/cargo-near/cargo-near/src/lib.rs:35
```

<details><summary><i><b>Changelog</b></i></summary><p>

## `cargo-near`
<blockquote>

##
[0.12.0](cargo-near-v0.11.0...cargo-near-v0.12.0)
- 2024-11-14

### Added

- Added the ability to use the TEACH-ME mode
([#221](#221))

### Other

- Gracefully handle missing `git` on `cargo near new`
([#246](#246))
- update `cargo near new` template `image` and `image_digest`
([#244](#244))
</blockquote>

## `cargo-near-build`
<blockquote>

##
[0.3.1](cargo-near-build-v0.3.0...cargo-near-build-v0.3.1)
- 2024-11-14

### Added

- Added the ability to use the TEACH-ME mode
([#221](#221))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/MarcoIeni/release-plz/).
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