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: branch support in installation #224

Closed
wants to merge 18 commits into from

Conversation

royalpinto007
Copy link
Contributor

Enables users to specify a branch during plugin installation in Coffee. This PR is a work in progress and not yet completed.

Reference- #205

Copy link

netlify bot commented Dec 31, 2023

Deploy Preview for coffee-docs canceled.

Name Link
🔨 Latest commit 070e6d7
🔍 Latest deploy log https://app.netlify.com/sites/coffee-docs/deploys/65c36f4919cc910008bbc7e8

Copy link
Contributor

@vincenzopalazzo vincenzopalazzo left a comment

Choose a reason for hiding this comment

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

I do not see the code that does really this, but as a first set up code

coffee_cmd/src/cmd.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@vincenzopalazzo vincenzopalazzo left a comment

Choose a reason for hiding this comment

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

Some API upgrade is missing inside the test, make check should help to to upgrade

coffee_1  |    Compiling tests v0.1.0 (/workdir/tests)
coffee_1  | error[E0061]: this method takes 4 arguments but 3 arguments were supplied
coffee_1  |    --> tests/src/coffee_integration_tests.rs:115:10
coffee_1  |     |
coffee_1  | 115 |         .install("summary", true, true)
coffee_1  |     |          ^^^^^^^----------------------- an argument of type `Option<std::string::String>` is missing
coffee_1  |     |
coffee_1  | note: method defined here
coffee_1  |    --> /workdir/coffee_lib/src/plugin_manager.rs:14:14
coffee_1  |     |
coffee_1  | 14  |     async fn install(
coffee_1  |     |              ^^^^^^^
coffee_1  | help: provide the argument
coffee_1  |     |
coffee_1  | 115 |         .install("summary", true, true, /* Option<std::string::String> */)
coffee_1  |     |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
coffee_1  | 
coffee_1  | error[E0061]: this method takes 4 arguments but 3 arguments were supplied
coffee_1  |    --> tests/src/coffee_integration_tests.rs:170:35
coffee_1  |     |
coffee_1  | 170 |     let result = manager.coffee().install("summary", true, false).await;
coffee_1  |     |                                   ^^^^^^^------------------------ an argument of type `Option<std::string::String>` is missing
coffee_1  |     |
coffee_1  | note: method defined here
coffee_1  |    --> /workdir/coffee_lib/src/plugin_manager.rs:14:14
coffee_1  |     |
coffee_1  | 14  |     async fn install(
coffee_1  |     |              ^^^^^^^
coffee_1  | help: provide the argument
coffee_1  |     |
coffee_1  | 170 |     let result = manager.coffee().install("summary", true, false, /* Option<std::string::String> */).await;
coffee_1  |     |                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
coffee_1  | 
coffee_1  | error[E0061]: this method takes 4 arguments but 3 arguments were supplied
coffee_1  |    --> tests/src/coffee_integration_tests.rs:176:10
coffee_1  |     |
coffee_1  | 176 |         .install("helpme", true, false)
coffee_1  |     |          ^^^^^^^----------------------- an argument of type `Option<std::string::String>` is missing
coffee_1  |     |
coffee_1  | note: method defined here
coffee_1  |    --> /workdir/coffee_lib/src/plugin_manager.rs:14:14
coffee_1  |     |
coffee_1  | 14  |     async fn install(
coffee_1  |     |              ^^^^^^^
coffee_1  | help: provide the argument
coffee_1  |     |
coffee_1  | 176 |         .install("helpme", true, false, /* Option<std::string::String> */)
coffee_1  |     |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
coffee_1  | 
coffee_1  | error[E0061]: this method takes 4 arguments but 3 arguments were supplied
coffee_1  |    --> tests/src/coffee_integration_tests.rs:279:35
coffee_1  |     |
coffee_1  | 279 |     let result = manager.coffee().install("summary", true, false).await;
coffee_1  |     |                                   ^^^^^^^------------------------ an argument of type `Option<std::string::String>` is missing
coffee_1  |     |
coffee_1  | note: method defined here
coffee_1  |    --> /workdir/coffee_lib/src/plugin_manager.rs:14:14
coffee_1  |     |
coffee_1  | 14  |     async fn install(
coffee_1  |     |              ^^^^^^^
coffee_1  | help: provide the argument
coffee_1  |     |
coffee_1  | 279 |     let result = manager.coffee().install("summary", true, false, /* Option<std::string::String> */).await;
coffee_1  |     |                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
coffee_1  | 
coffee_1  | error[E0061]: this method takes 4 arguments but 3 arguments were supplied
coffee_1  |    --> tests/src/coffee_integration_tests.rs:288:35
coffee_1  |     |
coffee_1  | 288 |     let result = manager.coffee().install("x", true, false).await;
coffee_1  |     |                                   ^^^^^^^------------------ an argument of type `Option<std::string::String>` is missing
coffee_1  |     |
coffee_1  | note: method defined here
coffee_1  |    --> /workdir/coffee_lib/src/plugin_manager.rs:14:14
coffee_1  |     |
coffee_1  | 14  |     async fn install(
coffee_1  |     |              ^^^^^^^
coffee_1  | help: provide the argument
coffee_1  |     |
coffee_1  | 288 |     let result = manager.coffee().install("x", true, false, /* Option<std::string::String> */).await;
coffee_1  |     |                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
coffee_1  | 
coffee_1  | error[E0061]: this method takes 4 arguments but 3 arguments were supplied
coffee_1  |    --> tests/src/coffee_integration_tests.rs:356:10
coffee_1  |     |
coffee_1  | 356 |         .install("summary", true, true)
coffee_1  |     |          ^^^^^^^----------------------- an argument of type `Option<std::string::String>` is missing
coffee_1  |     |
coffee_1  | note: method defined here
coffee_1  |    --> /workdir/coffee_lib/src/plugin_manager.rs:14:14
coffee_1  |     |
coffee_1  | 14  |     async fn install(
coffee_1  |     |              ^^^^^^^
coffee_1  | help: provide the argument
coffee_1  |     |
coffee_1  | 356 |         .install("summary", true, true, /* Option<std::string::String> */)
coffee_1  |     |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
coffee_1  | 
coffee_1  | error[E0061]: this method takes 4 arguments but 3 arguments were supplied
coffee_1  |    --> tests/src/coffee_integration_tests.rs:396:10
coffee_1  |     |
coffee_1  | 396 |         .install("summary", true, true)
coffee_1  |     |          ^^^^^^^----------------------- an argument of type `Option<std::string::String>` is missing
coffee_1  |     |
coffee_1  | note: method defined here
coffee_1  |    --> /workdir/coffee_lib/src/plugin_manager.rs:14:14
coffee_1  |     |
coffee_1  | 14  |     async fn install(
coffee_1  |     |              ^^^^^^^
coffee_1  | help: provide the argument
coffee_1  |     |
coffee_1  | 396 |         .install("summary", true, true, /* Option<std::string::String> */)
coffee_1  |     |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
coffee_1  | 
coffee_1  | error[E0061]: this method takes 4 arguments but 3 arguments were supplied
coffee_1  |    --> tests/src/coffee_integration_tests.rs:431:35
coffee_1  |     |
coffee_1  | 431 |     let result = manager.coffee().install("summary", true, false).await;
coffee_1  |     |                                   ^^^^^^^------------------------ an argument of type `Option<std::string::String>` is missing
coffee_1  |     |
coffee_1  | note: method defined here
coffee_1  |    --> /workdir/coffee_lib/src/plugin_manager.rs:14:14
coffee_1  |     |
coffee_1  | 14  |     async fn install(
coffee_1  |     |              ^^^^^^^
coffee_1  | help: provide the argument
coffee_1  |     |
coffee_1  | 431 |     let result = manager.coffee().install("summary", true, false, /* Option<std::string::String> */).await;
coffee_1  |     |                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
coffee_1  | 
coffee_1  | error[E0061]: this method takes 4 arguments but 3 arguments were supplied
coffee_1  |    --> tests/src/coffee_integration_tests.rs:437:10
coffee_1  |     |
coffee_1  | 437 |         .install("helpme", true, false)
coffee_1  |     |          ^^^^^^^----------------------- an argument of type `Option<std::string::String>` is missing
coffee_1  |     |
coffee_1  | note: method defined here
coffee_1  |    --> /workdir/coffee_lib/src/plugin_manager.rs:14:14
coffee_1  |     |
coffee_1  | 14  |     async fn install(
coffee_1  |     |              ^^^^^^^
coffee_1  | help: provide the argument
coffee_1  |     |
coffee_1  | 437 |         .install("helpme", true, false, /* Option<std::string::String> */)
coffee_1  |     |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
coffee_1  | 
coffee_1  | error[E0061]: this method takes 4 arguments but 3 arguments were supplied
coffee_1  |    --> tests/src/coffee_integration_tests.rs:496:10
coffee_1  |     |
coffee_1  | 496 |         .install("summary", true, false)
coffee_1  |     |          ^^^^^^^------------------------ an argument of type `Option<std::string::String>` is missing
coffee_1  |     |
coffee_1  | note: method defined here
coffee_1  |    --> /workdir/coffee_lib/src/plugin_manager.rs:14:14
coffee_1  |     |
coffee_1  | 14  |     async fn install(
coffee_1  |     |              ^^^^^^^
coffee_1  | help: provide the argument
coffee_1  |     |
coffee_1  | 496 |         .install("summary", true, false, /* Option<std::string::String> */)
coffee_1  |     |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
coffee_1  | 
coffee_1  | For more information about this error, try `rustc --explain E0061`.
coffee_1  | error: could not compile `tests` (lib test) due to 10 previous errors
coffee_1  | make: *** [Makefile:35: integration] Error 101

@royalpinto007
Copy link
Contributor Author

I don't see any issue with make check as it gives positive result, but integration testing fails.

For your reference-

royalpinto007@royalpinto007:~/coffee-dev$ make check
cargo test ""
    Finished test [unoptimized + debuginfo] target(s) in 1.46s
     Running unittests src/main.rs (target/debug/deps/coffee-a289af62a1ab4e5a)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running unittests src/lib.rs (target/debug/deps/coffee_core-1e57aab876cba5b9)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running unittests src/lib.rs (target/debug/deps/coffee_github-e12265faf851f5bf)

running 1 test
test tests::repository_is_initialized_ok ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 47.67s

     Running unittests src/lib.rs (target/debug/deps/coffee_httpd-9e02626a42513cf1)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running unittests src/main.rs (target/debug/deps/coffee_httpd-7b9b9d4b60a3f65c)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running unittests src/lib.rs (target/debug/deps/coffee_lib-e5e59cccfc42ee14)

running 3 tests
test plugin_conf::tests::test_remote ... ok
test url::tests::test_remote ... ok
test utils::tests::test_create_dir_in_home ... ok

test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.02s

     Running unittests src/main.rs (target/debug/deps/coffee_plugin-9a4709cab5419a40)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running unittests src/lib.rs (target/debug/deps/coffee_storage-1e89ec4f4e859c18)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running unittests src/lib.rs (target/debug/deps/coffee_testing-f5b11179a6057c76)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

@vincenzopalazzo
Copy link
Contributor

Sorry It is my bad I give you the wrong information, this is the command that the CI runs https://github.com/coffee-tools/coffee/blob/master/docker/entrypoint.sh#L2

@royalpinto007 royalpinto007 marked this pull request as draft January 6, 2024 16:28
@royalpinto007 royalpinto007 marked this pull request as ready for review January 26, 2024 12:37
Copy link
Collaborator

@tareknaser tareknaser left a comment

Choose a reason for hiding this comment

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

Great progress! I've left some comments. Keep up the good work!

@@ -247,6 +247,7 @@ impl PluginManager for CoffeeManager {
plugin: &str,
verbose: bool,
try_dynamic: bool,
_branch: Option<String>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This value isn't used anywhere

@@ -91,7 +91,7 @@ async fn coffee_install(
let try_dynamic = body.try_dynamic;

let mut coffee = data.coffee.lock().await;
let result = coffee.install(plugin, false, try_dynamic).await;
let result = coffee.install(plugin, false, try_dynamic, None).await;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Idealy, you should also handle changing the httpd request to coffee.install() method
You can add the field to Install struct in coffee_lib/src/types/mod.rs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe you meant this, but I am not sure if this is correct- d726c11

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe you meant this, but I am not sure if this is correct- d726c11

Correct, but why you are not passing the branch variable down the function call? I am really confused

It is easy, use the following code

Suggested change
let result = coffee.install(plugin, false, try_dynamic, None).await;
let branch = body.branch;
let result = coffee.install(plugin, false, try_dynamic, branch).await;

coffee_github/src/repository.rs Outdated Show resolved Hide resolved
coffee_github/src/repository.rs Outdated Show resolved Hide resolved
@vincenzopalazzo vincenzopalazzo added this to the 0.1-rc1 milestone Feb 4, 2024
@vincenzopalazzo
Copy link
Contributor

adding this to the milestone, but would love to have a summary of the status of this before starting review it

@royalpinto007
Copy link
Contributor Author

@vincenzopalazzo
I initially created a starter code for implementing the branch functionality. Upon @tareknaser's suggestions, I developed a switch_branch function, as shown in this commit: c664c66. After receiving some comments on it, I am currently at a standstill, as seen here: #224 (review).

Copy link
Contributor

@vincenzopalazzo vincenzopalazzo left a comment

Choose a reason for hiding this comment

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

Left some review, but the sentiments is the one of few months ago

looks like the real code it is missing :/ and this PR is just moving coding around

coffee_core/src/coffee.rs Outdated Show resolved Hide resolved
coffee_core/src/coffee.rs Outdated Show resolved Hide resolved
coffee_github/src/repository.rs Show resolved Hide resolved
@@ -91,7 +91,7 @@ async fn coffee_install(
let try_dynamic = body.try_dynamic;

let mut coffee = data.coffee.lock().await;
let result = coffee.install(plugin, false, try_dynamic).await;
let result = coffee.install(plugin, false, try_dynamic, None).await;
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe you meant this, but I am not sure if this is correct- d726c11

Correct, but why you are not passing the branch variable down the function call? I am really confused

It is easy, use the following code

Suggested change
let result = coffee.install(plugin, false, try_dynamic, None).await;
let branch = body.branch;
let result = coffee.install(plugin, false, try_dynamic, branch).await;

Comment on lines +33 to +34
/// switch to the specified branch.
async fn switch_branch(&mut self, branch_name: &str) -> Result<(), CoffeeError>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// switch to the specified branch.
async fn switch_branch(&mut self, branch_name: &str) -> Result<(), CoffeeError>;

Does not maske sense have the switch_branch inside the repository interface, it can be just an util. For example look at the repository.upgrade code

coffee_plugin/src/plugin/plugin_mod.rs Outdated Show resolved Hide resolved
.install("summary", true, false)
.install("summary", true, false, None)
Copy link
Contributor

Choose a reason for hiding this comment

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

Try to write a test also where you specify the branch.

@royalpinto007 royalpinto007 deleted the branch-install branch February 7, 2024 12:12
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