openssh-rust / openssh

Scriptable SSH through OpenSSH in Rust
Apache License 2.0
232 stars 37 forks source link

Attempt at providing an owned version of command #136

Closed masklinn closed 1 year ago

masklinn commented 1 year ago

Pushing this to run the tests as getting things to work locally on a mac seems like a bit of a bear.

Hopefully will eventually fix #117

jonhoo commented 1 year ago

This change is Reviewable

masklinn commented 1 year ago

@NobodyXu can you approve workflow runs? Also maybe comment on this early starting point.

codecov-commenter commented 1 year ago

Codecov Report

Merging #136 (bbe309a) into master (499c672) will increase coverage by 0.00%. The diff coverage is 83.33%.

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files | [Files](https://app.codecov.io/gh/openssh-rust/openssh/pull/136?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | Coverage Δ | | |---|---|---| | [src/child.rs](https://app.codecov.io/gh/openssh-rust/openssh/pull/136?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL2NoaWxkLnJz) | `89.74% <100.00%> (ø)` | | | [src/command.rs](https://app.codecov.io/gh/openssh-rust/openssh/pull/136?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL2NvbW1hbmQucnM=) | `89.92% <76.00%> (ø)` | | | [src/session.rs](https://app.codecov.io/gh/openssh-rust/openssh/pull/136?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL3Nlc3Npb24ucnM=) | `77.19% <86.04%> (+1.88%)` | :arrow_up: |
NobodyXu commented 1 year ago

P.S. I don't think implementing Command<Session> is a good idea, since it's never designed to be taken by value.

Command<Arc<Session>> or Command<Rc<Session>> is more similar to Command<&Session> and I'd like to see support for them.

masklinn commented 1 year ago

P.S. I don't think implementing Command<Session> is a good idea, since it's never designed to be taken by value.

I was mostly thinking of the case where a user might want to run a single command on the session, but didn't want to bother with borrowing. However as I wrote up it doesn't work without changing the Command API entirely so that's moot.

masklinn commented 1 year ago
NobodyXu commented 1 year ago

BTW, you need to fix the CI before I can merge this PR.

masklinn commented 1 year ago

BTW, you need to fix the CI before I can merge this PR.

Yep but since I can't run the tests locally I can only push and wait for CI approval. I'll get on that.

NobodyXu commented 1 year ago

@masklinn There's a run_ci_tests.sh in the repository that can be used to run some of the tests.

For linting, it's just cargo-clippy and cargo-fmt.

masklinn commented 1 year ago

There's a run_ci_tests.sh in the repository that can be used to run some of the tests.

Yeah but it requires docker, and I'm on a mac and not super willing to install docker desktop. It's nbd as far as I'm concerned just a bit more latency but I'm not replying within seconds anyway. Unless you have to approve every CI run I can imagine that gets old.

For linting, it's just cargo-clippy and cargo-fmt.

Yeah I ran fmt but it changed imports I had not touched so I figured the repo had strange configuration and reverted them, and they show up as lint errors so I guess it's just that they were last fmt'd before a change in configuration or something.

masklinn commented 1 year ago

Hopefully CI is good now, I broke one of the existing doc comments by mistake, and the new arc_command example had a few brainfarts.

NobodyXu commented 1 year ago

Yeah but it requires docker, and I'm on a mac and not super willing to install docker desktop.

You can use OrbStack, an alternative to docker desktop that claims to be faster than docker desktop and uses less energy.

I use it for docker desktop now and it indeed startup quickly.

It's nbd as far as I'm concerned just a bit more latency but I'm not replying within seconds anyway. Unless you have to approve every CI run I can imagine that gets old.

Yes, I do need to approve every CI run.

Once this PR lands in main, any new PR from you will have CI run automatically without having me to approve.

so I guess it's just that they were last fmt'd before a change in configuration or something.

It's probably because new lints are added to newer cargo.

NobodyXu commented 1 year ago

The coverage failure is probably due to CI setup (e.g. GHA does not allow PRs from non-member to use secrets) or whatever, I can bypass that and merge the PR once you address my review.

NobodyXu commented 1 year ago

Thank you @masklinn !

NobodyXu commented 1 year ago

Released in v0.10.1