aboutsummaryrefslogtreecommitdiffstats
path: root/src/github.rs
AgeCommit message (Collapse)Author
2017-11-13Focus HTTP response logging on `update_commit_status()`Teddy Wing
Comment out HTTP response logging from Jenkins because those may be coming back all right. Actually I might want to leave the log from `request_job()` now that I think about it. Add some additional logging on `update_commit_status()` to hopefully try to see why it's not getting called all the time.
2017-11-13Log response body of HTTP callsTeddy Wing
Log the HTTP response bodies to see if there's something we can gather from our connected services' API responses.
2017-11-12Add license (GNU GPLv3+)Teddy Wing
Add COPYING file and license notices to sources.
2017-11-12Convert a bunch of `to_string()`s to `to_owned()`Teddy Wing
I had used `to_owned()` previously in other projects, but after looking up the difference (again probably), I decided that it seems better to use `to_owned()`. References: https://users.rust-lang.org/t/to-string-vs-to-owned-for-string-literals/1441/6 http://www.lowlevelmanager.com/2016/02/rust-tostring-vs-toowned-for-string.html
2017-11-12github.rs: Update tests to pass GitHub tokenTeddy Wing
Now that `update_commit_status()` takes the GitHub API token as an argument, pass in a fake one in our test.
2017-11-12update_commit_status(): Pass GitHub token from command line argumentTeddy Wing
Take the GitHub API token as a parameter and pass it through from `find_and_track_build_and_update_status()`.
2017-11-11Handle `Result` return values in testsTeddy Wing
Update our failing test suite to work with our new return types now that many of our functions return `Result`s. Since these are tests, we handle them by panicking with error messages.
2017-11-11github.rs: Add error handling with `Result`Teddy Wing
Return a `Result` from `update_commit_status()` to eliminate our `.unwrap()` calls.
2017-11-10update_commit_status(): Pass authorization header with requestTeddy Wing
Authenticate our GitHub request with an `Authorization` header and API token.
2017-11-10Get rid of unused variablesTeddy Wing
2017-11-09Correct tests after 69b930565a118f1f9890492e9f3130e23091b398Teddy Wing
Now that a bunch of function signatures have been rewritten to take references, update the tests to pass the correct arguments.
2017-11-09Fix move compilation errors in `find_and_track_build_and_update_status`Teddy Wing
I had a bunch of compilation errors in this function because I wasn't borrowing correctly. Fix the errors with borrows by reference, and copying strings. Here are the errors for reference: error[E0373]: closure may outlive the current function, but it borrows `job`, which is owned by the current function --> src/jenkins.rs:89:27 | 89 | thread::spawn(|| { | ^^ may outlive borrowed value `job` ... 94 | job.result.commit_status(), | --- `job` is borrowed here | help: to force the closure to take ownership of `job` (and any other referenced variables), use the `move` keyword | 89 | thread::spawn(move || { | ^^^^^^^ error[E0373]: closure may outlive the current function, but it borrows `job_url`, which is owned by the current function --> src/jenkins.rs:89:27 | 89 | thread::spawn(|| { | ^^ may outlive borrowed value `job_url` ... 96 | job_url.clone(), | ------- `job_url` is borrowed here | help: to force the closure to take ownership of `job_url` (and any other referenced variables), use the `move` keyword | 89 | thread::spawn(move || { | ^^^^^^^ error[E0382]: use of moved value: `commit_ref` --> src/jenkins.rs:88:32 | 88 | if job_for_commit(job, commit_ref) { | ^^^^^^^^^^ value moved here in previous iteration of loop | = note: move occurs because `commit_ref` has type `pull_request::CommitRef`, which does not implement the `Copy` trait error[E0382]: capture of moved value: `commit_ref` --> src/jenkins.rs:93:21 | 88 | if job_for_commit(job, commit_ref) { | ---------- value moved here ... 93 | commit_ref, | ^^^^^^^^^^ value captured here after move | = note: move occurs because `commit_ref` has type `pull_request::CommitRef`, which does not implement the `Copy` trait error[E0382]: capture of moved value: `job` --> src/jenkins.rs:89:27 | 88 | if job_for_commit(job, commit_ref) { | --- value moved here 89 | thread::spawn(|| { | ^^ value captured here after move | = note: move occurs because `job` has type `jenkins::Job`, which does not implement the `Copy` trait error[E0382]: capture of moved value: `job_url` --> src/jenkins.rs:89:27 | 85 | let job = request_job(job_url); | ------- value moved here ... 89 | thread::spawn(|| { | ^^ value captured here after move | = note: move occurs because `job_url` has type `std::string::String`, which does not implement the `Copy` trait
2017-11-09`update_commit_status`: Remove `organization_name` argumentTeddy Wing
Now that the organisation name (rather, owner of a GitHub project) is stored in `CommitRef`, we don't need to pass it in explicitly.
2017-11-09CommitRef: Add `owner` fieldTeddy Wing
This field stores the "owner" of the commit on GitHub, in other words, a user or organisation. Storing that information in this struct makes it easier to pass around.
2017-11-09github.rs: `update_commit_status` needs organisation nameTeddy Wing
I wasn't thinking straight in 26b74edece4546378c8a853cc70f7388f20ff0c6. Instead of taking a repo name, we need to take an organisation/user name. The repo name we already have from `commit_ref.repo`. We were missing the org to be able to properly construct the GitHub API URL. Pass `organization_name` name around from `find_and_track_build_and_update_status`.
2017-11-09github.rs: `update_commit_status` should take a repo nameTeddy Wing
Pass a repo name explicitly in an argument to the function. We now have the values we need to be able to properly construct a URL to POST to. Update our HTTP request to send the params as JSON and include the "Accept" header that GitHub recommends adding (https://developer.github.com/v3/#current-version) based on the code examples in https://docs.rs/reqwest/0.8.1/reqwest/header/struct.Accept.html#examples.
2017-11-08github.rs: Fix compilation errors from e0dca75f9b2de9023ecb978a0f9c8a11bTeddy Wing
* Import 'reqwest' * Import `HashMap` * Insert `state` as string instead of `CommitStatus` (implement `fmt::Display` in order to do this) * Insert `description` as string instead of `Option` * Make test string arguments owned strings
2017-11-08Add rough code for `update_commit_status`Teddy Wing
This new function will make a request to the GitHub REST API to update the status of a commit using the given arguments. * Create a new `github` module for this to live in. * Uses `mockito` to check that the request was made. * The `API_URL` is necessary in order to set up 'mockito' to work properly. That pattern is lifted from an example in the crate's docs: http://lipanski.github.io/mockito/generated/mockito/index.html#example * Sort of make a POST request to the GitHub API to update the status. This doesn't actually work, though, of course, as it's incomplete. For one thing, we haven't even included the 'reqwest' library, and for another we need a way to get the GitHub owner name to build the API URL.