Skip to content

Commit ed3c915

Browse files
committed
Initial support for creating Check Runs
1 parent 00c4518 commit ed3c915

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,11 @@ GitHub.jl implements a bunch of methods that make REST requests to GitHub's API.
218218
| `installations(auth)` | `Vector{Installation}` | [get the installations for the GitHub app authenticated by the corresponding `auth`](https://developer.github.com/v3/apps/#find-installations) |
219219
| `repos(i::Installation)` | `Tuple{Vector{Repo}, Dict}` | [get the active repositories for this installation](https://developer.github.com/v3/apps/#find-installations) |
220220

221+
#### GitHub Check Runs
222+
| method | return type | documentation |
223+
|------------------------------------------|------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
224+
| `create_check_run(repo; params=...)` | `CheckRun` | [Create a new check run](https://developer.github.com/v3/checks/runs/#create-a-check-run) |
225+
221226

222227
#### Miscellaneous
223228

src/GitHub.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ export # events/listeners.jl
242242

243243
include("apps/apps.jl")
244244
include("apps/installations.jl")
245+
include("apps/checks/runs.jl")
245246

246247
# export -------
247248

@@ -254,6 +255,10 @@ export # installations.jl
254255
create_access_token,
255256
installations
256257

258+
export # runs.jl
259+
Checks,
260+
create_check_run
261+
257262
#######
258263
# Git #
259264
#######

src/apps/checks/runs.jl

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
module Checks
2+
export Action, Image, Annotation, Output
3+
4+
struct Action
5+
label::String
6+
description::String
7+
identifier::String
8+
end
9+
10+
struct Image
11+
alt::String
12+
image_url::String
13+
caption::Nullable{String}
14+
end
15+
16+
struct Annotation
17+
filename::String
18+
blob_href::String
19+
start_line::Int
20+
end_line::Int
21+
warning_level::String
22+
message::String
23+
title::Nullable{String}
24+
raw_details::String # Documented as Nullable{String}, but that errors
25+
end
26+
27+
struct Output
28+
title::String
29+
summary::String
30+
text::String # Documented as Nullable{String}, but that errors
31+
annotations::Vector{Annotation}
32+
images::Vector{Image}
33+
end
34+
35+
end
36+
using .Checks
37+
38+
struct CheckRun <: GitHubType
39+
id::Nullable{Int}
40+
head_sha::Nullable{String}
41+
external_id::Nullable{String}
42+
status::Nullable{String}
43+
conclusion::Nullable{String}
44+
started_at::Nullable{DateTime}
45+
completed_at::Nullable{DateTime}
46+
app::Nullable{App}
47+
pull_requests::Vector{PullRequest}
48+
end
49+
CheckRun(data::Dict) = json2github(CheckRun, data)
50+
namefield(cr::CheckRun) = cr.id
51+
52+
@api_default function create_check_run(api::GitHubAPI, repo::Repo; headers = Dict(), kwargs...)
53+
headers["Accept"] = "application/vnd.github.antiope-preview+json"
54+
result = gh_post_json(api, "/repos/$(name(repo))/check-runs"; headers=headers, kwargs...)
55+
return CheckRun(result)
56+
end

0 commit comments

Comments
 (0)