Skip to content

Commit e007efd

Browse files
authored
Merge pull request #5 from osociety/dev
Dev
2 parents 68bdc84 + 66f86e4 commit e007efd

File tree

8 files changed

+130
-48
lines changed

8 files changed

+130
-48
lines changed

.github/workflows/flutter.yml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,39 @@ name: Flutter
77

88
on:
99
push:
10-
branches: [ "main" ]
10+
branches: ["main"]
1111
pull_request:
12-
branches: [ "main", "dev" ]
12+
branches: ["main", "dev"]
1313

14-
concurrency:
14+
concurrency:
1515
group: ${{ github.head_ref || github.run_id }}
1616
cancel-in-progress: true
17-
17+
1818
jobs:
1919
build:
2020
runs-on: ${{ matrix.os }}
2121
strategy:
22-
matrix:
23-
os: [ubuntu-latest, windows-latest, macos-latest]
22+
matrix:
23+
os: [ubuntu-latest, windows-latest, macos-latest]
2424

2525
steps:
26-
- uses: actions/checkout@v3
26+
- name: Checkout
27+
uses: actions/checkout@v3
28+
2729
- name: Setup Java JDK
2830
uses: actions/setup-java@v3
2931
with:
3032
distribution: temurin
31-
java-version: '17'
33+
java-version: "17"
34+
3235
- name: Flutter action
3336
uses: subosito/flutter-action@v2.8.0
3437
with:
3538
channel: stable
39+
3640
- name: Flutter version
3741
run: flutter --version
42+
3843
- name: Cache pubspec dependencies
3944
uses: actions/cache@v3.0.7
4045
with:
@@ -47,6 +52,7 @@ jobs:
4752
key: build-pubspec-${{ hashFiles('**/pubspec.lock') }}
4853
restore-keys: |
4954
build-pubspec-
55+
5056
- name: Cache build runner
5157
uses: actions/cache@v2
5258
with:
@@ -58,9 +64,12 @@ jobs:
5864
key: build-runner-${{ hashFiles('**/asset_graph.json', '**/*.dart', '**/pubspec.lock', '**/outputs.json') }}
5965
restore-keys: |
6066
build-runner-
67+
6168
- name: Download pub dependencies
6269
run: flutter pub get
70+
6371
- name: Run analyzer
6472
run: flutter analyze
73+
6574
- name: Run tests
66-
run: flutter test
75+
run: flutter test

.github/workflows/publish.yml

Lines changed: 50 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,56 @@ jobs:
1212
- name: Checkout
1313
uses: actions/checkout@v3
1414

15-
# Note: This workflow uses the latest stable version of the Dart SDK.
16-
# You can specify other versions if desired, see documentation here:
17-
# https://github.com/dart-lang/setup-dart/blob/main/README.md
18-
- uses: dart-lang/setup-dart@v1.4
19-
# - uses: dart-lang/setup-dart@9a04e6d73cca37bd455e0608d7e5092f881fd603
20-
21-
- name: Analyze project source
22-
run: dart analyze --fatal-infos
15+
- name: Setup Java JDK
16+
uses: actions/setup-java@v3
17+
with:
18+
distribution: temurin
19+
java-version: "17"
2320

24-
- name: Run tests
25-
run: dart test --coverage="coverage"
21+
- name: Flutter action
22+
uses: subosito/flutter-action@v2.8.0
23+
with:
24+
channel: stable
25+
26+
- name: Flutter version
27+
run: flutter --version
28+
29+
- name: Cache pubspec dependencies
30+
uses: actions/cache@v3.0.7
31+
with:
32+
path: |
33+
${{ env.FLUTTER_HOME }}/.pub-cache
34+
**/.packages
35+
**/.flutter-plugins
36+
**/.flutter-plugin-dependencies
37+
**/.dart_tool/package_config.json
38+
key: build-pubspec-${{ hashFiles('**/pubspec.lock') }}
39+
restore-keys: |
40+
build-pubspec-
2641
27-
- name: Install dependencies
28-
run: dart pub get
42+
- name: Cache build runner
43+
uses: actions/cache@v2
44+
with:
45+
path: |
46+
**/.dart_tool
47+
**/*.g.dart
48+
**/*.mocks.dart
49+
**/*.config.dart
50+
key: build-runner-${{ hashFiles('**/asset_graph.json', '**/*.dart', '**/pubspec.lock', '**/outputs.json') }}
51+
restore-keys: |
52+
build-runner-
53+
54+
- name: Download pub dependencies
55+
run: flutter pub get
56+
57+
- name: Run analyzer
58+
run: flutter analyze --fatal-infos
2959

3060
- name: Install coverage tools
31-
run: dart pub global activate coverage
61+
run: flutter pub global activate coverage
62+
63+
- name: Run tests
64+
run: flutter test --coverage-path="coverage"
3265

3366
- name: Format Coverage
3467
run: $HOME/.pub-cache/bin/format_coverage --lcov --in=coverage --out=coverage/coverage.lcov --report-on=lib
@@ -44,14 +77,13 @@ jobs:
4477
sh ./pub_login.sh
4578
4679
- name: Check Publish Warnings
47-
run: dart pub publish --dry-run
80+
run: flutter pub publish --dry-run
4881

4982
- name: Publish Package
50-
run: dart pub publish -f
51-
83+
run: flutter pub publish -f
84+
5285
- name: Upload Coverage to CodeCov
5386
uses: codecov/codecov-action@v3
5487
with:
5588
token: ${{secrets.CODECOV_TOKEN}}
56-
file: ./network_tools/coverage/coverage.lcov
57-
89+
file: ./coverage/coverage.lcov

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ migrate_working_dir/
2828
.dart_tool/
2929
.packages
3030
build/
31+
coverage/
32+
**.flutter-plugins**

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Change Log
22

3-
## 0.0.1
3+
## 1.0.0
44

55
* Initial support added for ping_ios_dart in network_tools

README.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
11
# Network Tools Flutter
22

3+
[![pub package](https://img.shields.io/pub/v/network_tools_flutter.svg)](https://pub.dev/packages/network_tools_flutter) [![Dart](https://github.com/osociety/network_tools_flutter/actions/workflows/flutter.yml/badge.svg)](https://github.com/osociety/network_tools_flutter/actions/workflows/flutter.yml) [![codecov](https://codecov.io/gh/git-elliot/network_tools_flutter/branch/main/graph/badge.svg?token=J9G2472GQZ)](https://codecov.io/gh/git-elliot/network_tools_flutter)
4+
35
## Features
46

5-
This package will add support for flutter only features in network_tools, network_tools will still be required to be added in pubspec.yaml.
7+
This package will add support for flutter features in network_tools and network_tools can be independently added whereas network_tools_flutter will internally use network_tools.
68

79
## Getting started
810

9-
```dart
10-
import 'package:network_tools_flutter/network_tools.dart';
11-
12-
```
13-
1411
## Usage
1512

1613
```dart
17-
main() {
18-
NetworkToolsFlutter.init();
19-
}
14+
import 'package:network_tools_flutter/network_tools_flutter.dart';
2015
```
2116

2217
## Additional information
2318

24-
Currently getAllPingableDevicesAsync() is not working on ios because of plugin registration
19+
You can use same methods but need to import from network_tools_flutter.

pub_login.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# This script creates/updates credentials.json file which is used
2+
# to authorize publisher when publishing packages to pub.dev
3+
4+
# Checking whether the secrets are available as environment
5+
# variables or not.
6+
if [ -z "${PUB_DEV_PUBLISH_ACCESS_TOKEN}" ]; then
7+
echo "Missing PUB_DEV_PUBLISH_ACCESS_TOKEN environment variable"
8+
exit 1
9+
fi
10+
11+
if [ -z "${PUB_DEV_PUBLISH_REFRESH_TOKEN}" ]; then
12+
echo "Missing PUB_DEV_PUBLISH_REFRESH_TOKEN environment variable"
13+
exit 1
14+
fi
15+
16+
if [ -z "${PUB_DEV_PUBLISH_TOKEN_ENDPOINT}" ]; then
17+
echo "Missing PUB_DEV_PUBLISH_TOKEN_ENDPOINT environment variable"
18+
exit 1
19+
fi
20+
21+
if [ -z "${PUB_DEV_PUBLISH_EXPIRATION}" ]; then
22+
echo "Missing PUB_DEV_PUBLISH_EXPIRATION environment variable"
23+
exit 1
24+
fi
25+
mkdir -p $HOME/.config/dart
26+
# Create credentials.json file.
27+
cat <<EOF > $HOME/.config/dart/pub-credentials.json
28+
{
29+
"accessToken":"${PUB_DEV_PUBLISH_ACCESS_TOKEN}",
30+
"refreshToken":"${PUB_DEV_PUBLISH_REFRESH_TOKEN}",
31+
"tokenEndpoint":"${PUB_DEV_PUBLISH_TOKEN_ENDPOINT}",
32+
"idToken": "${PUB_DEV_PUBLISH_ID_TOKEN}",
33+
"scopes":["openid","https://www.googleapis.com/auth/userinfo.email"],
34+
"expiration":${PUB_DEV_PUBLISH_EXPIRATION}
35+
}
36+
EOF

pubspec.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
name: network_tools_flutter
22
description: Extended features of network_tools for flutter framework.
33
version: 1.0.0
4-
issue_tracker: https://github.com/osociety/network_tools/issues
5-
repository: https://github.com/osociety/network_tools/tree/main/network_tools_flutter
6-
publish_to: none
4+
issue_tracker: https://github.com/osociety/network_tools_flutter/issues
5+
repository: https://github.com/osociety/network_tools_flutter.git
76

87
environment:
9-
sdk: ">=2.17.6 <3.0.0"
8+
sdk: ">=2.17.6 <4.0.0"
109
flutter: ">=1.17.0"
1110

1211
dependencies:

test/host_scan_flutter_test.dart

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import 'package:universal_io/io.dart';
66
void main() {
77
TestWidgetsFlutterBinding.ensureInitialized();
88
int port = 0;
9+
int hostId = 0;
910
String myOwnHost = "0.0.0.0";
1011
String interfaceIp = myOwnHost.substring(0, myOwnHost.lastIndexOf('.'));
1112
late ServerSocket server;
@@ -27,25 +28,33 @@ void main() {
2728
.address; //gives IP address of GHA local machine.
2829
myOwnHost = address;
2930
interfaceIp = address.substring(0, address.lastIndexOf('.'));
31+
hostId = int.parse(
32+
address.substring(address.lastIndexOf('.') + 1, address.length));
3033
}
3134
}
3235
});
3336

34-
group('Testing Host Scanner', () {
35-
test('Running getAllPingableDevicesAsync tests', () async {
37+
group('Testing Host Scanner emits', () {
38+
test('Running getAllPingableDevices emits tests', () async {
3639
expectLater(
3740
//There should be at least one device pingable in network
38-
HostScannerFlutter.getAllPingableDevices(
41+
HostScannerFlutter.getAllPingableDevices(
3942
interfaceIp,
40-
timeoutInSeconds: 3,
43+
// Better to restrict to scan from hostId - 1 to hostId + 1 to prevent GHA timeouts
44+
firstHostId: hostId - 1,
45+
lastHostId: hostId + 1,
4146
),
4247
emits(isA<ActiveHost>()),
4348
);
49+
});
50+
test('Running getAllPingableDevices emitsThrough tests', () async {
4451
expectLater(
4552
//Should emit at least our own local machine when pinging all hosts.
46-
HostScannerFlutter.getAllPingableDevices(
53+
HostScannerFlutter.getAllPingableDevices(
4754
interfaceIp,
48-
timeoutInSeconds: 3,
55+
// Better to restrict to scan from hostId - 1 to hostId + 1 to prevent GHA timeouts
56+
firstHostId: hostId - 1,
57+
lastHostId: hostId + 1,
4958
),
5059
emitsThrough(ActiveHost(internetAddress: InternetAddress(myOwnHost))),
5160
);

0 commit comments

Comments
 (0)