Skip to content
This repository was archived by the owner on Feb 13, 2023. It is now read-only.

Commit d01309b

Browse files
committed
Add basic CI workflow
1 parent 34b8be2 commit d01309b

9 files changed

+121
-16
lines changed

.github/dependabot.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"

.github/workflows/integration.yml

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Integration
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- develop
8+
pull_request:
9+
branches:
10+
- main
11+
- develop
12+
13+
jobs:
14+
analyze:
15+
name: Analyze
16+
runs-on: ubuntu-latest
17+
defaults:
18+
run:
19+
working-directory: dio
20+
steps:
21+
- uses: actions/checkout@v2
22+
- uses: dart-lang/setup-dart@v1
23+
with:
24+
sdk: stable
25+
- run: pub get
26+
- run: dart analyze
27+
28+
format:
29+
name: Check formatting
30+
runs-on: ubuntu-latest
31+
defaults:
32+
run:
33+
working-directory: dio
34+
steps:
35+
- uses: actions/checkout@v2
36+
- uses: dart-lang/setup-dart@v1
37+
with:
38+
sdk: stable
39+
- run: dart format --set-exit-if-changed .
40+
41+
tests:
42+
name: Unit tests
43+
runs-on: ubuntu-latest
44+
strategy:
45+
matrix:
46+
sdk: [ stable, beta, dev, 2.12.0 ]
47+
defaults:
48+
run:
49+
working-directory: dio
50+
steps:
51+
- uses: actions/checkout@v2
52+
- uses: dart-lang/setup-dart@v1
53+
with:
54+
sdk: ${{ matrix.sdk }}
55+
- run: pub get
56+
- run: dart test
57+
- name: Upload test report
58+
uses: actions/upload-artifact@v2
59+
if: always() && matrix.sdk == 'stable'
60+
with:
61+
name: test-results
62+
path: dio/build/reports/test-results.json
63+
64+
publish-dry-run:
65+
name: Publish dry-run
66+
runs-on: ubuntu-latest
67+
defaults:
68+
run:
69+
working-directory: dio
70+
steps:
71+
- uses: actions/checkout@v2
72+
- uses: dart-lang/setup-dart@v1
73+
with:
74+
sdk: stable
75+
- run: pub get
76+
- run: pub publish --dry-run

.github/workflows/test-report.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Test Report
2+
3+
on:
4+
workflow_run:
5+
workflows:
6+
- Integration
7+
types:
8+
- completed
9+
10+
jobs:
11+
report:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Publish test reports
15+
uses: dorny/test-reporter@v1
16+
with:
17+
name: Test results
18+
artifact: test-results
19+
path: '**/*.json'
20+
reporter: dart-json

dio/analysis_options.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
include: package:lints/recommended.yaml
2+
3+
analyzer:
4+
errors:
5+
deprecated_member_use_from_same_package: ignore
6+
todo: ignore

dio/dart_test.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
file_reporters:
2+
json: build/reports/test-results.json

dio/pubspec.yaml

+2-5
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ dependencies:
1111
path: ^1.8.0
1212

1313
dev_dependencies:
14+
lints: ^1.0.1
1415
test: ^1.5.1
15-
lint: ^1.0.0
16-
pedantic: ^1.10.0
17-
test_coverage: ^0.5.0
18-
# flutter_test:
19-
# sdk: flutter
16+
coverage: ^1.0.3

dio/test/readtimeout_test.dart

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'dart:async';
22
import 'dart:io';
3-
import 'package:pedantic/pedantic.dart';
43
import 'package:dio/dio.dart';
54
import 'package:test/test.dart';
65

@@ -16,7 +15,7 @@ Future<int> getUnusedPort() async {
1615
server = await HttpServer.bind('localhost', 0);
1716
return server.port;
1817
} finally {
19-
unawaited(server?.close());
18+
server?.close();
2019
}
2120
}
2221

dio/test/utils.dart

+6-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import 'dart:async';
66
import 'dart:convert';
77
import 'dart:io';
88
import 'dart:typed_data';
9-
import 'package:pedantic/pedantic.dart';
109
import 'package:test/test.dart';
1110

1211
/// The current server instance.
@@ -32,7 +31,7 @@ Future<void> startServer() async {
3231
..statusCode = 400
3332
..contentLength = content.length
3433
..write(content);
35-
unawaited(response.close());
34+
response.close();
3635
return;
3736
}
3837

@@ -43,7 +42,7 @@ Future<void> startServer() async {
4342
..headers
4443
.set('location', serverUrl.resolve('/loop?${n + 1}').toString())
4544
..contentLength = 0;
46-
unawaited(response.close());
45+
response.close();
4746
return;
4847
}
4948

@@ -52,7 +51,7 @@ Future<void> startServer() async {
5251
..statusCode = 302
5352
..headers.set('location', serverUrl.resolve('/').toString())
5453
..contentLength = 0;
55-
unawaited(response.close());
54+
response.close();
5655
return;
5756
}
5857

@@ -61,7 +60,7 @@ Future<void> startServer() async {
6160
..statusCode = 200
6261
..contentLength = -1
6362
..write('body');
64-
unawaited(response.close());
63+
response.close();
6564
return;
6665
}
6766

@@ -71,7 +70,7 @@ Future<void> startServer() async {
7170
..statusCode = 200
7271
..contentLength = -1
7372
..write('[1,2,3]');
74-
unawaited(response.close());
73+
response.close();
7574
return;
7675
}
7776

@@ -129,7 +128,7 @@ Future<void> startServer() async {
129128
response
130129
..contentLength = body.length
131130
..write(body);
132-
unawaited(response.close());
131+
response.close();
133132
});
134133
}
135134

test.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cd dio
2-
flutter test --coverage .
2+
dart test --coverage=coverage .
3+
pub run coverage:format_coverage --packages=.packages -i coverage -o coverage/lcov.info --lcov
34
genhtml -o coverage coverage/lcov.info
45
# Open in the default browser (mac):
56
open coverage/index.html
6-

0 commit comments

Comments
 (0)