Skip to content

Commit 57dd829

Browse files
author
Casey Hillers
authored
Run format and analyze on presubmit/postsubmit (#275)
1 parent 665fdaf commit 57dd829

File tree

11 files changed

+291
-10
lines changed

11 files changed

+291
-10
lines changed

.github/workflows/tests.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Tests
2+
on:
3+
push:
4+
branches: [ master ]
5+
pull_request:
6+
branches: [ master ]
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- uses: dart-lang/setup-dart@v1
13+
- name: Install dependencies
14+
run: dart pub get
15+
- name: Format
16+
run: dart format --output=none --set-exit-if-changed .
17+
- name: Analyze
18+
run: dart analyze
19+
# - name: Unit tests
20+
# run: dart test test
21+
# - name: Integration tests
22+
# run: dart test integration_test

example/languages.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ void reloadTable({int accuracy = 4}) {
3535
isReloadingTable = true;
3636
final md = generateMarkdown(accuracy);
3737
github.misc.renderMarkdown(md).then((html) {
38+
// ignore: unsafe_html
3839
tableDiv!.setInnerHtml(html, treeSanitizer: NodeTreeSanitizer.trusted);
3940
isReloadingTable = false;
4041
});

lib/browser_helper.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ void renderMarkdown(GitHub github, String selector, {int indent = 4}) {
2424
e.hidden = false;
2525
e.setAttribute('rendered', '');
2626
e.classes.add('markdown-body');
27+
// ignore: unsafe_html
2728
e.setInnerHtml(html, treeSanitizer: NodeTreeSanitizer.trusted);
2829
});
2930
}

lib/github.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export 'package:github/src/common.dart';
2+
23
/// Do a conditional export of the right cross platform pieces depending on
34
/// if dart.html or dart.io is available.
45
export 'package:github/src/common/xplat_common.dart'

lib/src/common/model/checks.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'package:github/src/common/model/pulls.dart';
12
import 'package:github/src/common/util/utils.dart';
23
import 'package:meta/meta.dart';
34

@@ -350,18 +351,26 @@ class CheckSuite {
350351
final int? id;
351352
final String? headSha;
352353
final CheckRunConclusion conclusion;
354+
final List<PullRequest> pullRequests;
353355

354356
const CheckSuite({
355357
required this.conclusion,
356358
required this.headSha,
357359
required this.id,
360+
required this.pullRequests,
358361
});
359362

360363
factory CheckSuite.fromJson(Map<String, dynamic> input) {
364+
var pullRequestsJson = input['pull_requests'] as List<dynamic>;
365+
var pullRequests = pullRequestsJson
366+
.map((dynamic json) =>
367+
PullRequest.fromJson(json as Map<String, dynamic>))
368+
.toList();
361369
return CheckSuite(
362370
conclusion: CheckRunConclusion._fromValue(input['conclusion']),
363371
headSha: input['head_sha'],
364372
id: input['id'],
373+
pullRequests: pullRequests,
365374
);
366375
}
367376

lib/src/common/util/utils.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ RepositorySlug slugFromAPIUrl(String url) {
6060
return RepositorySlug(parts[0], parts[1]);
6161
}
6262

63+
// ignore: avoid_classes_with_only_static_members
6364
abstract class StatusCodes {
6465
static const int OK = 200;
6566
static const int CREATED = 201;

test/experiment/generate_release_notes.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import 'package:github/github.dart';
33
Future<void> main() async {
44
final github = GitHub(auth: findAuthenticationFromEnvironment());
55

6-
var notes = await github.repositories.generateReleaseNotes(
7-
CreateReleaseNotes('Spinlocklabs', 'github.dart', '1.0.1',
6+
var notes = await github.repositories.generateReleaseNotes(CreateReleaseNotes(
7+
'Spinlocklabs', 'github.dart', '1.0.1',
88
targetCommitish: '1.0.1', previousTagName: '1.0.0'));
99
print(notes.name);
1010
print(notes.body);

test/git_test.dart

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import 'package:http/http.dart' as http;
66
import 'package:mockito/mockito.dart';
77
import 'package:test/test.dart';
88

9-
class MockGitHub extends Mock implements GitHub {}
9+
import 'src/mocks.mocks.dart';
1010

1111
void main() {
1212
late MockGitHub github;
@@ -137,7 +137,7 @@ void main() {
137137
// given
138138
final expectedResponse = http.Response('{}', 200);
139139

140-
when(github.request(any!, any!, body: any, headers: any))
140+
when(github.request(any, any, body: any, headers: any))
141141
.thenReturn(Future.value(expectedResponse));
142142

143143
// when
@@ -151,16 +151,16 @@ void main() {
151151
test('creates valid JSON body', () {
152152
// given
153153
final expectedResponse = http.Response('{}', 200);
154-
when(github.request(any!, any!, body: any, headers: any))
154+
when(github.request(any, any, body: any, headers: any))
155155
.thenReturn(Future.value(expectedResponse));
156156

157157
// when
158158
git.editReference(repo, 'heads/b', someSha, force: true);
159159

160160
// then
161161
final captured = verify(github.request(
162-
any!,
163-
any!,
162+
any,
163+
any,
164164
body: captureAny,
165165
headers: captureAny,
166166
)).captured;
@@ -178,8 +178,7 @@ void main() {
178178
test('constructs correct path', () {
179179
// given
180180
final expectedResponse = http.Response('{}', 200);
181-
when(github.request(any!, any!))
182-
.thenReturn(Future.value(expectedResponse));
181+
when(github.request(any, any)).thenReturn(Future.value(expectedResponse));
183182

184183
// when
185184
git.deleteReference(repo, 'heads/b');
@@ -300,7 +299,7 @@ void main() {
300299

301300
Map<String, dynamic>? captureSentBody(MockGitHub github) {
302301
final bodyString = verify(github.postJSON(
303-
any!,
302+
any,
304303
convert: any,
305304
statusCode: any,
306305
body: captureAny,

test/src/mocks.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import 'package:github/src/common.dart';
2+
import 'package:mockito/annotations.dart';
3+
4+
@GenerateMocks(<Type>[GitHub])
5+
void main() {}

0 commit comments

Comments
 (0)