Api to Domain Mapping
Overview
Since there are a lot of transformations happening from the github api to our
internal domain
model, here is a quick overview of it. The intermediary layer
in the github-adapter
serves to map the response json directly to java classes
which then know how to transform themselves into actual domain
classes. Aside
from the whole classes, we are also mapping things like possible statuses. We do
this because it reduces the cardinality of the resulting prometheus metric. Look
below for more details.
Workflow Run
Both the conclusion as well as the status are grouped into the WorkflowRunStatus
enum. This leads to some dataloss which is acceptable for the better decoupleing.
First the conclusion
is queried for what the final status should be but if it
does not give a clear response then the status
determines the final WorkflowRunStatus
.
Conclusion
github status strings | WorkflowRunStatus enum |
---|---|
"failure"
"cancelled"
"startup_failure"
|
FAILED |
"success"
|
DONE |
"neutral"
"in_progress"
null
|
passed on to status |
Status
github status strings | WorkflowRunStatus enum |
---|---|
"completed"
"success"
|
DONE |
"action_required"
"cancelled"
"failure"
"neutral"
"skipped"
"stale"
"timed_out"
|
FAILED |
"in_progress"
|
IN_PROGRESS |
"queued"
"requested"
"waiting"
"pending"
|
PENDING |
Build Times
Although a separate query, there is no separate object on the domain. Insead the adapter sets the build time parameter on the domain after having done the query to the timing endpoint.
Jobs
Unlike Workflow Runs, Jobs has the conclusion
and status
split up into two
different enums. This should be changed in the future into one status to reduce
complexity and coupling.
Conclusion
github conclusion strings | JobConclusion enum |
---|---|
"success"
|
SUCCESS |
"neutral"
"skipped"
"null"
|
NEUTRAL |
"action_required"
|
ACTION_REQUIRED |
"failure"
"cancelled"
"timed_out"
"action_required"
|
FAILURE |
Status
github status strings | JobStatus enum |
---|---|
"requested"
"queued"
"pending"
|
PENDING |
"in_progress"
|
IN_PROGRESS |
"completed"
|
DONE |
Pull Request
The Pull Requests endpoint is currently the only endpoint that returns an array on the root level which makes it a little different from the other response objects.
Repository
Self Hosted Runner
As displayed by the grafic below, self hosted runners can be present on both the organization as well as each repository. The response json is still the same in both cases simplifying the mapping quite a lot.