aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2017-11-22Increase version v0.0.2 -> v0.0.3HEADv0.0.3masterTeddy Wing
2017-11-22Merge branch 'listen-on-0.0.0.0'Teddy Wing
2017-11-22main(): Change server from `127.0.0.1` to `0.0.0.0`Teddy Wing
Make the default server address `0.0.0.0` to make the server accessible from inside a Docker container.
2017-11-17Add CHANGELOGv0.0.2Teddy Wing
2017-11-17Increase version v0.0.1 -> v0.0.2Teddy Wing
2017-11-17Merge branch 'send-Jenkins-build-console-link-as-status-URL'Teddy Wing
2017-11-17find_and_track_build_and_update_status(): Send Jenkins console URLTeddy Wing
When adding a GitHub commit status, instead of using the job "home" URL, use the URL of its "Console" page. This page shows the build log and is much more useful than the other one. If there's a build failure in particular, you'd be going to this page anyway to see what the problem was, so using this `target_url` saves a click.
2017-11-17jenkins.rs: Add `jenkins_console_url_path()`Teddy Wing
A new function that will return the URL to the Jenkins "Console" page given the URL of a Jenkins job. We'll be using this to pass with the GitHub status request as the `target_url`.
2017-11-17Merge branch ↵Teddy Wing
'only-update-status-when-pull-request-is-opened-or-new-commits-are-pushed'
2017-11-17main(): Don't update commit status unless commits were pushedTeddy Wing
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.
2017-11-17CommitRef::new(): Take a `JsonValue` instead of an `&str`Teddy Wing
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.
2017-11-17pull_request.rs: Add `pull_request_opened_or_synchronized()`Teddy Wing
A new function that, given the parsed JSON from a pull request webhook, tells us whether the pull request was "opened" or "synchronize"d with a boolean. This will enable us to only update commit statuses when actions on the pull request result in new commits being available. Otherwise, we don't want to set a commit status that we've already set before.
2017-11-17main(): Move `body` var definition to where it's usedTeddy Wing
Don't bother creating the variable if we don't receive any data. Instead, initialise the variable right where we need it.
2017-11-17Merge branch 'remove-unnecessary-commented-code'Teddy Wing
2017-11-17pull_request.rs: Remove old comments from testTeddy Wing
These are no longer relevant.
2017-11-17Remove commented log calls from Jenkins requestsTeddy Wing
We're not using these any more, so they can be removed.
2017-11-17Merge remote-tracking branch 'origin/fix-final-status-update-call'Teddy Wing
Conflicts: src/jenkins.rs
2017-11-17Merge branch 'lower-logging-verbosity'Teddy Wing
2017-11-17main(): Lower log verbosity to 'info'Teddy Wing
Make the logs less noisy and don't output 'debug' or 'trace' logs.
2017-11-16find_and_track_build_and_update_status(): Make `info` logs `debug`Teddy Wing
These were useful during development and in bug hunting, but I get the sense that they'd be more annoying in production. Change these to `debug` log messages.
2017-11-16Merge branch 'sleep-before-talking-to-Jenkins'Teddy Wing
2017-11-16main(): Remove commented `return`Teddy Wing
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.
2017-11-16find_and_track_build_and_update_status(): Remove commented thread::spawnTeddy Wing
This `thread::spawn()` call was moved outside the function and into `main()`. We can remove it now.
2017-11-16find_and_track_build_and_update_status(): Restore old arg typesTeddy Wing
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.
2017-11-16main(): Add comment above cloned command line variablesTeddy Wing
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.
2017-11-16Merge branch 'better-logging'Teddy Wing
2017-11-16find_and_track_build_and_update_status(): Fix final GitHub callTeddy Wing
I had mistakenly (stupidly) used the wrong `job` variable. Duh, that's why it was sending a "pending" status when the job was finished! Use the correct variable, `updated_job`, to update the correct GitHub status.
2017-11-14find_and_track_build_and_update_status(): Move thread outside functionTeddy Wing
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.
2017-11-14find_and_track_build_and_update_status(): Try to wrap the fn in a threadTeddy Wing
Try to put the whole function inside a thread. This doesn't work because of move problems. The reason for wrapping things in a thread is so I can add a `sleep` at the top of the function. We want to sleep before even making our first request to Jenkins because it seems like we're making the request too early, before the job has been created. This prevents the GitHub status from being set.
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-13main(): Increase log verbosity to `Trace`Teddy Wing
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.
2017-11-13README: Use typographer's quotesTeddy Wing
2017-11-13README: Update wording of webhook settings configurationTeddy Wing
This sentence was unclear.
2017-11-13Add READMEv0.0.1Teddy Wing
Add a little information about the project, some brief (probably incomplete) setup instructions, installation, and license information.
2017-11-12Add license (GNU GPLv3+)Teddy Wing
Add COPYING file and license notices to sources.
2017-11-12main(): Print message to inform users that the server is runningTeddy Wing
2017-11-12main(): Use "127.0.0.1" instead of "localhost"Teddy Wing
Make it clear that we want to run on local localhost (and not "0.0.0.0").
2017-11-12main(): Add loggingTeddy Wing
Initialise a new 'stderrlog' and log all errors to the log.
2017-11-12Add 'log' & 'stderrlog' cratesTeddy Wing
For logging capabilities. 'stderrlog' seemed like a reasonable option to go with, even though it only logs to STDERR, given that I only feel the need to log to STDERR.
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-12request_job(): Use `Job::new()`Teddy Wing
Realised that the reason why I was getting a dead code warning from `Job::new` was not just because I wasn't using it, but because I was meant to use it somewhere. Remove the duplicate work going on in `request_job()` and replace it with a call to `Job::new()` instead.
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 tests for Jenkins mock URLTeddy Wing
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.
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-12Take Jenkins URL from command line optionsTeddy Wing
Get rid of the static, global `API_URL`, and replace it with the Jenkins URL that gets passed into `find_and_track_build_and_update_status()`. This necessitated adding a new URL argument to `get_jobs()` and `request_job()`. Starting to wonder if I should be creating a struct to hold the URL and client that I can attach these functions to as methods, but for now I'll leave them alone.
2017-11-12Update tests to pass a `jenkins_request_client()`Teddy Wing
Now that `get_jobs()` and `request_job()` take a `jenkins_request_client()`, update the tests to ensure we're calling them properly.
2017-11-12auth_credentials(): Get credentials from argumentsTeddy Wing
Remove the hard-coded user ID and token values. Instead, take these from arguments to the function. In order to not have to pass those arguments through to both `get_jobs()` and `request_job()`, make a new private function that builds a 'reqwest' client with the required auth header.
2017-11-12find_and_track_build_and_update_status(): Pass in configurationTeddy Wing
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.
2017-11-12main(): Use user-supplied portTeddy Wing
Remove the hard-coded port and use the one passed in via command line option (or the default one).