switch hubcap away from fork
Artturin opened this issue · comments
the fork is 404 commits behind https://github.com/softprops/hubcaps and many of the commits are already merged in hubcaps
https://github.com/grahamc/hubcaps
this is as far as i got
cargo build
Compiling ofborg v0.1.9 (/home/artturin/nixgits/ofborg/ofborg)
error[E0107]: this struct takes 0 lifetime arguments but 1 lifetime argument was supplied
--> ofborg/src/commitstatus.rs:4:29
|
4 | api: hubcaps::statuses::Statuses<'a>,
| ^^^^^^^^---- help: remove these generics
| |
| expected 0 lifetime arguments
|
note: struct defined here, with 0 lifetime parameters
--> /home/artturin/.local/share/cargo/git/checkouts/hubcaps-0d4ef1dca85fd8b9/30bbb3a/src/statuses.rs:8:12
|
8 | pub struct Statuses {
| ^^^^^^^^
error[E0107]: this struct takes 0 lifetime arguments but 1 lifetime argument was supplied
--> ofborg/src/commitstatus.rs:13:33
|
13 | api: hubcaps::statuses::Statuses<'a>,
| ^^^^^^^^---- help: remove these generics
| |
| expected 0 lifetime arguments
|
note: struct defined here, with 0 lifetime parameters
--> /home/artturin/.local/share/cargo/git/checkouts/hubcaps-0d4ef1dca85fd8b9/30bbb3a/src/statuses.rs:8:12
|
8 | pub struct Statuses {
| ^^^^^^^^
diff --git a/ofborg/Cargo.toml b/ofborg/Cargo.toml
index 64e402e..b0fbfc8 100644
--- a/ofborg/Cargo.toml
+++ b/ofborg/Cargo.toml
@@ -11,8 +11,8 @@ chrono = "0.4.6"
either = "1.4.0"
fs2 = "0.4.2"
futures-util = "0.3.21"
-hubcaps = { git = "https://github.com/grahamc/hubcaps.git" }
-#hubcaps = { path = "../../../grahamc/hubcaps/" } # for testing patches
+#hubcaps = { git = "https://github.com/grahamc/hubcaps.git" }
+hubcaps = { git = "https://github.com/softprops/hubcaps.git" }
hyper = "0.10.*"
hyper-native-tls = "0.3.0"
lapin = "1.0.0"
diff --git a/ofborg/src/commitstatus.rs b/ofborg/src/commitstatus.rs
index 74d606b..ba5d0e5 100644
--- a/ofborg/src/commitstatus.rs
+++ b/ofborg/src/commitstatus.rs
@@ -81,13 +81,13 @@ pub enum CommitStatusError {
impl From<hubcaps::Error> for CommitStatusError {
fn from(e: hubcaps::Error) -> CommitStatusError {
use hyper::status::StatusCode;
- match e.kind() {
- hubcaps::ErrorKind::Fault { code, error }
+ match e {
+ hubcaps::errors::Error::Fault { code, error }
if code == &StatusCode::Unauthorized && error.message == "Bad credentials" =>
{
CommitStatusError::ExpiredCreds(e)
}
- hubcaps::ErrorKind::Fault { code, error }
+ hubcaps::errors::Error::Fault { code, error }
if code == &StatusCode::UnprocessableEntity
&& error.message.starts_with("No commit found for SHA:") =>
{
diff --git a/ofborg/src/tasks/eval/nixpkgs.rs b/ofborg/src/tasks/eval/nixpkgs.rs
index 7b0edaf..cac2d88 100644
--- a/ofborg/src/tasks/eval/nixpkgs.rs
+++ b/ofborg/src/tasks/eval/nixpkgs.rs
@@ -48,11 +48,11 @@ fn label_from_title(title: &str) -> Vec<String> {
pub struct NixpkgsStrategy<'a> {
job: &'a EvaluationJob,
- pull: &'a hubcaps::pulls::PullRequest<'a>,
+ pull: &'a hubcaps::pulls::PullRequest,
issue: &'a Issue,
- issue_ref: &'a IssueRef<'a>,
- repo: &'a Repository<'a>,
- gists: &'a Gists<'a>,
+ issue_ref: &'a IssueRef,
+ repo: &'a Repository,
+ gists: &'a Gists,
nix: Nix,
stdenv_diff: Option<Stdenvs>,
outpath_diff: Option<OutPathDiff>,
diff --git a/ofborg/src/tasks/evaluate.rs b/ofborg/src/tasks/evaluate.rs
index 083a609..4b25212 100644
--- a/ofborg/src/tasks/evaluate.rs
+++ b/ofborg/src/tasks/evaluate.rs
@@ -122,8 +122,8 @@ impl<E: stats::SysEvents + 'static> worker::SimpleWorker for EvaluationWorker<E>
struct OneEval<'a, E> {
client_app: &'a hubcaps::Github,
- repo: hubcaps::repositories::Repository<'a>,
- gists: Gists<'a>,
+ repo: hubcaps::repositories::Repository,
+ gists: Gists,
nix: &'a nix::Nix,
acl: &'a Acl,
events: &'a mut E,
@@ -524,7 +524,7 @@ fn schedule_builds(
}
pub fn make_gist<'a>(
- gists: &hubcaps::gists::Gists<'a>,
+ gists: &hubcaps::gists::Gists,
name: &str,
description: Option<String>,
contents: String,
once i remove those 2 errors then
diff --git a/ofborg/src/commitstatus.rs b/ofborg/src/commitstatus.rs
index ba5d0e5..47d2dd3 100644
--- a/ofborg/src/commitstatus.rs
+++ b/ofborg/src/commitstatus.rs
@@ -1,21 +1,21 @@
use tracing::warn;
-pub struct CommitStatus<'a> {
- api: hubcaps::statuses::Statuses<'a>,
+pub struct CommitStatus {
+ api: hubcaps::statuses::Statuses,
sha: String,
context: String,
description: String,
url: String,
}
-impl<'a> CommitStatus<'a> {
+impl<'a> CommitStatus {
pub fn new(
- api: hubcaps::statuses::Statuses<'a>,
+ api: hubcaps::statuses::Statuses,
sha: String,
context: String,
description: String,
url: Option<String>,
- ) -> CommitStatus<'a> {
+ ) -> CommitStatus {
let mut stat = CommitStatus {
api,
sha,
od.rs:564:8
|
564 | fn unwrap_or_else<F>(self, f: F) -> UnwrapOrElse<Self, F>
| -------------- the method is available for `Pin<Box<(dyn std::future::Future<Output = Result<Vec<Label>, hu
bcaps::Error>> + Send + 'static)>>` here
|
= help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
|
2 | use futures_util::future::try_future::TryFutureExt;
|
error[E0599]: no method named `unwrap_or_else` found for struct `Pin<Box<(dyn std::future::Future<Output = Result<(), hu
bcaps::Error>> + Send + 'static)>>` in the current scope
--> ofborg/src/tasks/evaluate.rs:584:26
|
584 | l.remove(&label).unwrap_or_else(|e| {
| ^^^^^^^^^^^^^^ method not found in `Pin<Box<(dyn std::future::Future<Output = Result<(),
hubcaps::Error>> + Send + 'static)>>`
|
::: /home/artturin/.local/share/cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.21/src/future/try_future/m
od.rs:564:8
|
564 | fn unwrap_or_else<F>(self, f: F) -> UnwrapOrElse<Self, F>
| -------------- the method is available for `Pin<Box<(dyn std::future::Future<Output = Result<(), hubcaps::E
rror>> + Send + 'static)>>` here
|
= help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
|
2 | use futures_util::future::try_future::TryFutureExt;
|
error[E0277]: the `?` operator can only be applied to values that implement `Try`
--> ofborg/src/tasks/evaluate.rs:630:8
|
630 | if statuses
| ________^
631 | | .list(&sha)?
| |____________________^ the `?` operator cannot be applied to type `Pin<Box<dyn std::future::Future<Output = Result
<Vec<hubcaps::statuses::Status>, hubcaps::Error>> + Send>>`
|
= help: the trait `Try` is not implemented for `Pin<Box<dyn std::future::Future<Output = Result<Vec<hubcaps::statuse
s::Status>, hubcaps::Error>> + Send>>`
error[E0308]: mismatched types
--> ofborg/src/tasks/githubcommentfilter.rs:78:16
|
78 | if let Err(x) = pr {
| ^^^^^^ -- this expression has type `Pin<Box<dyn std::future::Future<Output = Result<hubcaps::pulls
::Pull, hubcaps::Error>> + Send>>`
| |
| expected struct `Pin`, found enum `Result`
|
= note: expected struct `Pin<Box<dyn std::future::Future<Output = Result<hubcaps::pulls::Pull, hubcaps::Error>> + Sen
d>>`
found enum `Result<_, _>`
error[E0599]: no method named `unwrap` found for struct `Pin<Box<dyn std::future::Future<Output = Result<hubcaps::pulls:
:Pull, hubcaps::Error>> + Send>>` in the current scope
--> ofborg/src/tasks/githubcommentfilter.rs:86:21
|
86 | let pr = pr.unwrap();
| ^^^^^^ method not found in `Pin<Box<dyn std::future::Future<Output = Result<hubcaps::pulls::Pul
l, hubcaps::Error>> + Send>>`
error[E0308]: mismatched types
--> ofborg/src/tasks/githubcommentposter.rs:90:17
|
89 | match check_create_attempt {
| -------------------- this expression has type `Pin<Box<dyn std::future::Future<Output = Result<Ch
eckRun, hubcaps::Error>> + Send>>`
90 | Ok(_) => info!("Successfully sent."),
| ^^^^^ expected struct `Pin`, found enum `Result`
|
= note: expected struct `Pin<Box<dyn std::future::Future<Output = Result<CheckRun, hubcaps::Error>> + Send>>`
found enum `Result<_, _>`
error[E0308]: mismatched types
--> ofborg/src/tasks/githubcommentposter.rs:91:17
|
89 | match check_create_attempt {
| -------------------- this expression has type `Pin<Box<dyn std::future::Future<Output = Result<Ch
eckRun, hubcaps::Error>> + Send>>`
90 | Ok(_) => info!("Successfully sent."),
91 | Err(err) => info!("Failed to send check {:?}", err),
| ^^^^^^^^ expected struct `Pin`, found enum `Result`
|
= note: expected struct `Pin<Box<dyn std::future::Future<Output = Result<CheckRun, hubcaps::Error>> + Send>>`
found enum `Result<_, _>`
Graham was the one who originally implemented this, but the only real API incompatibility between the forks is that upstream's JWTCredentials
wants the raw bytes of the private key (https://github.com/softprops/hubcaps/blob/30bbb3a66bc85a062bab15bb10818395a387dcce/src/jwt.rs#L34), whereas Graham's fork reads it from a file (https://github.com/grahamc/hubcaps/blob/de1e1521ee78b5df5e1435619c8e1b90c932d36b/src/lib.rs#L228). Also, upstream uses async, so I just bodged it together with async_std::task::block_on
.
That aside, I've "ported" us (just fixed the errors as they appeared) to the latest upstream release in my branch here: https://github.com/cole-h/ofborg/tree/use-upstream.