Skip to content

Commit 7d811f1

Browse files
author
Casey Hillers
authored
Add conclusion property to CheckRun #298
2 parents 45df396 + 6595153 commit 7d811f1

File tree

4 files changed

+117
-1
lines changed

4 files changed

+117
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ Map<String, GistFile>? files;
1515

1616
**Full Changelog**: https://github.com/SpinlockLabs/github.dart/compare/8.5.0...9.0.0
1717

18+
## 9.0.1
19+
- Add `conclusion` property in class `CheckRun`
20+
1821
## 8.5.0
1922

2023
* Adds listing and creating PR Reviews, listing users in an org by @robrbecker in https://github.com/SpinlockLabs/github.dart/pull/287

lib/src/common/model/checks.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ class CheckRun {
9494
final int? checkSuiteId;
9595
final String? detailsUrl;
9696
final DateTime startedAt;
97+
final CheckRunConclusion conclusion;
9798

9899
const CheckRun._({
99100
required this.id,
@@ -104,6 +105,7 @@ class CheckRun {
104105
required this.name,
105106
required this.detailsUrl,
106107
required this.startedAt,
108+
required this.conclusion,
107109
});
108110

109111
factory CheckRun.fromJson(Map<String, dynamic> input) {
@@ -127,6 +129,7 @@ class CheckRun {
127129
checkSuiteId: input['check_suite']['id'],
128130
detailsUrl: input['details_url'],
129131
startedAt: DateTime.parse(input['started_at']),
132+
conclusion: CheckRunConclusion._fromValue(input['conclusion']),
130133
);
131134
}
132135

@@ -142,6 +145,7 @@ class CheckRun {
142145
},
143146
'details_url': detailsUrl,
144147
'started_at': startedAt.toIso8601String(),
148+
'conclusion': conclusion,
145149
};
146150
}
147151
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: github
2-
version: 9.0.0
2+
version: 9.0.1
33
description: A high-level GitHub API Client Library that uses Github's v3 API
44
homepage: https://github.com/SpinlockLabs/github.dart
55

test/unit/checks_test.dart

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
import 'dart:convert';
2+
3+
import 'package:github/src/common/model/checks.dart';
4+
import 'package:test/test.dart';
5+
6+
void main() {
7+
group('Check run', () {
8+
test('CheckRun fromJson', () {
9+
/// The checkRun Json is the official Github values
10+
///
11+
/// Github api url: https://docs.github.com/en/rest/reference/checks#get-a-check-run
12+
const checkRunJson = '''{
13+
"id": 4,
14+
"head_sha": "ce587453ced02b1526dfb4cb910479d431683101",
15+
"node_id": "MDg6Q2hlY2tSdW40",
16+
"external_id": "",
17+
"url": "https://api.github.com/repos/github/hello-world/check-runs/4",
18+
"html_url": "https://github.com/github/hello-world/runs/4",
19+
"details_url": "https://example.com",
20+
"status": "completed",
21+
"conclusion": "neutral",
22+
"started_at": "2018-05-04T01:14:52Z",
23+
"completed_at": "2018-05-04T01:14:52Z",
24+
"output": {
25+
"title": "Mighty Readme report",
26+
"summary": "There are 0 failures, 2 warnings, and 1 notice.",
27+
"text": "You may have some misspelled words on lines 2 and 4. You also may want to add a section in your README about how to install your app.",
28+
"annotations_count": 2,
29+
"annotations_url": "https://api.github.com/repos/github/hello-world/check-runs/4/annotations"
30+
},
31+
"name": "mighty_readme",
32+
"check_suite": {
33+
"id": 5
34+
},
35+
"app": {
36+
"id": 1,
37+
"slug": "octoapp",
38+
"node_id": "MDExOkludGVncmF0aW9uMQ==",
39+
"owner": {
40+
"login": "github",
41+
"id": 1,
42+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjE=",
43+
"url": "https://api.github.com/orgs/github",
44+
"repos_url": "https://api.github.com/orgs/github/repos",
45+
"events_url": "https://api.github.com/orgs/github/events",
46+
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
47+
"gravatar_id": "",
48+
"html_url": "https://github.com/octocat",
49+
"followers_url": "https://api.github.com/users/octocat/followers",
50+
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
51+
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
52+
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
53+
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
54+
"organizations_url": "https://api.github.com/users/octocat/orgs",
55+
"received_events_url": "https://api.github.com/users/octocat/received_events",
56+
"type": "User",
57+
"site_admin": true
58+
},
59+
"name": "Octocat App",
60+
"description": "",
61+
"external_url": "https://example.com",
62+
"html_url": "https://github.com/apps/octoapp",
63+
"created_at": "2017-07-08T16:18:44-04:00",
64+
"updated_at": "2017-07-08T16:18:44-04:00",
65+
"permissions": {
66+
"metadata": "read",
67+
"contents": "read",
68+
"issues": "write",
69+
"single_file": "write"
70+
},
71+
"events": [
72+
"push",
73+
"pull_request"
74+
]
75+
},
76+
"pull_requests": [
77+
{
78+
"url": "https://api.github.com/repos/github/hello-world/pulls/1",
79+
"id": 1934,
80+
"number": 3956,
81+
"head": {
82+
"ref": "say-hello",
83+
"sha": "3dca65fa3e8d4b3da3f3d056c59aee1c50f41390",
84+
"repo": {
85+
"id": 526,
86+
"url": "https://api.github.com/repos/github/hello-world",
87+
"name": "hello-world"
88+
}
89+
},
90+
"base": {
91+
"ref": "master",
92+
"sha": "e7fdf7640066d71ad16a86fbcbb9c6a10a18af4f",
93+
"repo": {
94+
"id": 526,
95+
"url": "https://api.github.com/repos/github/hello-world",
96+
"name": "hello-world"
97+
}
98+
}
99+
}
100+
]
101+
}''';
102+
final checkRun = CheckRun.fromJson(jsonDecode(checkRunJson));
103+
104+
expect(checkRun.id, 4);
105+
expect(checkRun.name, 'mighty_readme');
106+
expect(checkRun.conclusion, CheckRunConclusion.neutral);
107+
});
108+
});
109+
}

0 commit comments

Comments
 (0)