Age | Commit message (Collapse) | Author |
|
Instead of just making a request to test out 'reqwest' and how to use
it, make this function actually do something useful.
It now requests a URL dynamically based on the `repo_name` passed in,
and returns a list of build job URLs from the JSON resulting from the
API response.
|
|
Instead of just calling the `get_jobs` function, make this a real test
and check its return value using a mocked response, now that we have
'mockito' at our disposition.
|
|
* 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.
|
|
Fill in this function, which returns a boolean whether a given job
matches a `CommitRef`. It does this based on the display name of the
job.
Needed to make the `Job` struct public in order to use it here.
|
|
Now we can parse the JSON payload in a single place and extract the
values from it into a new `Job`.
Change `Job.result`'s type to `JobStatus` because that makes more sense.
Now, `result_from_job` gets called in `Job::new` to give us the
`JobStatus` directly on the `Job`.
Modify `result_from_job` to fit into its new responsibility, working for
`Job::new`. Update the tests accordingly.
|
|
This will avoid having to parse a job JSON payload multiple times. We
should do the parsing once, extract the data we need, and pass the
resulting struct around instead.
|
|
Outline for the main function that will integrate everything here. It
carries out the algorithm described at the top of the file.
So far it's incomplete, but wanted to get the idea down in code
somewhere. Also, this method might make more sense in a different
module.
|
|
A new af83 module for non-general code.
The `job_name` function will turn a commit reference into a job name
string. This job name corresponds to the names of branch builds in
Jenkins, and is a custom format, specific to af83.
|
|
I had forgotten I needed to make the struct and its fields public. We
need this to be able to use it outside of the module.
|
|
This method will take a job JSON payload returned from the Jenkins API
(http://jenkins/job/:project/:id/api/json), and return its status,
success, failed, or pending.
A new `JobStatus` type represents the status of jobs.
|
|
Try making our first HTTP request to the Jenkins API. Use Basic
authentication with our name and access token.
The 'reqwest' format is based on
https://doc.rust-lang.org/stable/std/string/struct.String.html
Eventually this method should return a `Vec` of jobs, actually job URLs,
but at least we know it works and gives us a 200.
|
|
Comment and a rough interface definition describing how commit statuses
should be updated and how Jenkins should be queried.
|
|
Print a simple text message on 404 for human consumption. Makes it more
obvious than finding out the response status code in a browser.
|
|
The test now passes, and we create our `CommitRef` struct using actual
values from the parsed JSON.
In order to get the branch name, we need the part after the last "/" in
the "ref" key.
There are a ton of `unwrap`s here, but at least it's a start and it's
working now.
|
|
Non-working app code, but the test tries to check that we get a
structure with the right data given a JSON payload coming from the
GitHub PushEvent webhook (copied from
https://developer.github.com/v3/activity/events/types/#pushevent).
|
|
Empty stub modules that will be filled in with the communication code.
|
|
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.)
|