Age | Commit message (Collapse) | Author |
|
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.
|
|
Log the HTTP response bodies to see if there's something we can gather
from our connected services' API responses.
|
|
Add COPYING file and license notices to sources.
|
|
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
|
|
Now that `update_commit_status()` takes the GitHub API token as an
argument, pass in a fake one in our test.
|
|
Take the GitHub API token as a parameter and pass it through from
`find_and_track_build_and_update_status()`.
|
|
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.
|
|
Return a `Result` from `update_commit_status()` to eliminate our
`.unwrap()` calls.
|
|
Authenticate our GitHub request with an `Authorization` header and API
token.
|
|
|
|
Now that a bunch of function signatures have been rewritten to take
references, update the tests to pass the correct arguments.
|
|
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
|
|
Now that the organisation name (rather, owner of a GitHub project) is
stored in `CommitRef`, we don't need to pass it in explicitly.
|
|
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.
|
|
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`.
|
|
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.
|
|
* 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
|
|
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.
|