Age | Commit message (Collapse) | Author |
|
Make the default server address `0.0.0.0` to make the server accessible
from inside a Docker container.
|
|
There are a bunch of events that can trigger the `pull_request` webhook.
These are:
"assigned", "unassigned", "review_requested",
"review_request_removed", "labeled", "unlabeled", "opened",
"edited", "closed", or "reopened". And "synchronize".
We only care about "opened" and "synchronize" because those are the only
two where new commits can come through. Since we don't set commit
statuses unless that commit is part of a pull request, we need a way to
update the status the first time a pull request is opened, thus the
"opened" action. When new commits are added we also want to update
statuses, so "synchronize". But for the others, we don't want to be
duplicating work and adding duplicate unnecessary statuses to PR
commits.
|
|
We expect to have pre-parsed the JSON as this function will get called
after `pull_request_opened_or_synchronized()`. To avoid doing the same
JSON parsing work twice, take a `JsonValue` argument in both functions.
|
|
Don't bother creating the variable if we don't receive any data.
Instead, initialise the variable right where we need it.
|
|
Make the logs less noisy and don't output 'debug' or 'trace' logs.
|
|
This error handler now lives inside a `thread::spawn()` rather than
inside the HTTP request handler, so we shouldn't return an HTTP response
here.
|
|
I had changed these when I was having trouble passing the values through
my double-closure, but now that that's settles, we can revert these
types to the way they were before and get rid of the unnecessary
`to_owned()` transformations.
|
|
Turns out the easiest way to share these variables between both closures
really is to clone them.
Thanks to 'durka42' on Mozilla#rust-beginners for explaining the problem
to me. In durka's words:
> both closures are required to be 'static
> so you can't send references across
> and the router handler has to be callable multiple times so you can't consume anything (that's the error you got)
It's also possible to share references using Arc, but that seems more
complicated than it's worth here. Just do the copy and be done with it.
|
|
Instead of wrapping the inside of the function in a thread, put the
thread on the outside, in `main()`. This is an effort to try to get
around the `move`/lifetime issues I was having with the previous
version.
Add some extra logging so we have a better idea what's going on when.
Remove the `expects` I had added and put the `Result` returns back.
In `main()`, wrap the call to `find_and_track_build_and_update_status()`
in a thread and sleep before calling it. This allows us to give Jenkins
some time to warm up and create a job for our commit before we go ahead
and try to request it from its API. Otherwise, if we kick off the
Jenkins fetch too soon, our statuses aren't going to get updated because
the job won't have been created and thus won't have been found on the
`get_jobs()` call.
Had to add some ugly `clone()`s to get around `move` compiler errors
here. Next step is figuring out how to clean that up.
|
|
By default, 'stderrlog' uses the `Error` level (which I found out by
inspecting the source here:
https://docs.rs/stderrlog/0.2.3/src/stderrlog/lib.rs.html#242-253).
Increase the log verbosity to `Trace` to hopefully give us more
information to act on. Bug hunting.
|
|
Add COPYING file and license notices to sources.
|
|
|
|
Make it clear that we want to run on local localhost (and not
"0.0.0.0").
|
|
Initialise a new 'stderrlog' and log all errors to the log.
|
|
Now that the Jenkins API URL is getting passed in via command line and
function argument, update the tests to pass it in directly.
Remove the test/non-test versions of `jenkins_url` from
`find_and_track_build_and_update_status()` because we can pass in the
mock URL directly to the `get_jobs()` and `request_job()` functions in
tests.
Make the `jenkins_url` argument to
`find_and_track_build_and_update_status()` not a reference so that we
don't have to reset it in the function to a `to_owned()` version.
|
|
Take the GitHub API token as a parameter and pass it through from
`find_and_track_build_and_update_status()`.
|
|
Pass logins & tokens for API communication into this function. Since
this is the entry point into everything else, it seemed to make sense to
have it be the thing that took the config.
Ended up not making a Config struct to be simple. I guess.
|
|
Remove the hard-coded port and use the one passed in via command line
option (or the default one).
|
|
Add options for:
* Jenkins URL
* Jenkins username
* Jenkins token
* GitHub token
* Port
Add a help option for usage information. All options except "port" are
required. Didn't use `reqopt` because that panics when you try to ask
for help without the required options. Now, when trying to run without a
required option, the usage help is printed. Maybe we should have an
error message instead.
|
|
Now that our functions return `Result`s for errors instead of panicking,
we need to handle these errors. For now, just respond with a 500. We'll
also want to log the errors though.
|
|
Convert our dummy test route to a real one that will handle webhooks
coming from GitHub. It will parse the POST body data and create a
`CommitRef` from it. That `CommitRef` then gets passed to
`find_and_track_build_and_update_status()` to update the pull request
status based on Jenkins' build results.
A 202 response seemed apt here. Quoting
https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html:
> 10.2.3 202 Accepted
>
> The request has been accepted for processing, but the processing has
> not been completed. The request might or might not eventually be acted
> upon, as it might be disallowed when processing actually takes place.
> There is no facility for re-sending a status code from an asynchronous
> operation such as this.
|
|
Print a simple text message on 404 for human consumption. Makes it more
obvious than finding out the response status code in a browser.
|
|
Basic web server and dummy response using 'rouille'.
|
|
Initialised new project with:
$ cargo init --bin kipper
Rust 1.16.0. (I know, it's super old, but that's what I have on my
machine right now without going out to get the latest version.)
|