Skip to content

Commit

Permalink
Merge pull request #1 from osociety/pub_to_dev
Browse files Browse the repository at this point in the history
Preparing release v1.0.0 for network_tools_flutter
  • Loading branch information
git-elliot authored Aug 31, 2023
2 parents cc00dea + 42708f5 commit 433afdd
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 43 deletions.
69 changes: 47 additions & 22 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,53 @@ jobs:
publish:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

# Note: This workflow uses the latest stable version of the Dart SDK.
# You can specify other versions if desired, see documentation here:
# https://github.com/dart-lang/setup-dart/blob/main/README.md
- uses: dart-lang/[email protected]
# - uses: dart-lang/setup-dart@9a04e6d73cca37bd455e0608d7e5092f881fd603

- name: Analyze project source
run: dart analyze --fatal-infos

- name: Run tests
run: dart test --coverage="coverage"

- name: Install dependencies
run: dart pub get
steps:
- uses: actions/checkout@v3
- name: Setup Java JDK
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: '17'
- name: Flutter action
uses: subosito/[email protected]
with:
channel: stable
- name: Flutter version
run: flutter --version
- name: Cache pubspec dependencies
uses: actions/[email protected]
with:
path: |
${{ env.FLUTTER_HOME }}/.pub-cache
**/.packages
**/.flutter-plugins
**/.flutter-plugin-dependencies
**/.dart_tool/package_config.json
key: build-pubspec-${{ hashFiles('**/pubspec.lock') }}
restore-keys: |
build-pubspec-
- name: Cache build runner
uses: actions/cache@v2
with:
path: |
**/.dart_tool
**/*.g.dart
**/*.mocks.dart
**/*.config.dart
key: build-runner-${{ hashFiles('**/asset_graph.json', '**/*.dart', '**/pubspec.lock', '**/outputs.json') }}
restore-keys: |
build-runner-
- name: Download pub dependencies
run: flutter pub get
- name: Run analyzer
run: flutter analyze --fatal-infos

- name: Install coverage tools
run: dart pub global activate coverage
run: flutter pub global activate coverage

- name: Run tests
run: flutter test --coverage-path="coverage"

- name: Format Coverage
run: $HOME/.pub-cache/bin/format_coverage --lcov --in=coverage --out=coverage/coverage.lcov --report-on=lib

Expand All @@ -44,14 +69,14 @@ jobs:
sh ./pub_login.sh
- name: Check Publish Warnings
run: dart pub publish --dry-run
run: flutter pub publish --dry-run

- name: Publish Package
run: dart pub publish -f
run: flutter pub publish -f

- name: Upload Coverage to CodeCov
uses: codecov/codecov-action@v3
with:
token: ${{secrets.CODECOV_TOKEN}}
file: ./network_tools/coverage/coverage.lcov
file: ./coverage/coverage.lcov

2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Change Log

## 0.0.1
## 1.0.0

* Initial support added for ping_ios_dart in network_tools
15 changes: 5 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
# Network Tools Flutter

[![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)

## Features

This package will add support for flutter only features in network_tools, network_tools will still be required to be added in pubspec.yaml.
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.

## Getting started

```dart
import 'package:network_tools_flutter/network_tools.dart';
```

## Usage

```dart
main() {
NetworkToolsFlutter.init();
}
import 'package:network_tools_flutter/network_tools_flutter.dart';
```

## Additional information

Currently getAllPingableDevicesAsync() is not working on ios because of plugin registration
You can use same methods but need to import from network_tools_flutter.
36 changes: 36 additions & 0 deletions pub_login.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This script creates/updates credentials.json file which is used
# to authorize publisher when publishing packages to pub.dev

# Checking whether the secrets are available as environment
# variables or not.
if [ -z "${PUB_DEV_PUBLISH_ACCESS_TOKEN}" ]; then
echo "Missing PUB_DEV_PUBLISH_ACCESS_TOKEN environment variable"
exit 1
fi

if [ -z "${PUB_DEV_PUBLISH_REFRESH_TOKEN}" ]; then
echo "Missing PUB_DEV_PUBLISH_REFRESH_TOKEN environment variable"
exit 1
fi

if [ -z "${PUB_DEV_PUBLISH_TOKEN_ENDPOINT}" ]; then
echo "Missing PUB_DEV_PUBLISH_TOKEN_ENDPOINT environment variable"
exit 1
fi

if [ -z "${PUB_DEV_PUBLISH_EXPIRATION}" ]; then
echo "Missing PUB_DEV_PUBLISH_EXPIRATION environment variable"
exit 1
fi
mkdir -p $HOME/.config/dart
# Create credentials.json file.
cat <<EOF > $HOME/.config/dart/pub-credentials.json
{
"accessToken":"${PUB_DEV_PUBLISH_ACCESS_TOKEN}",
"refreshToken":"${PUB_DEV_PUBLISH_REFRESH_TOKEN}",
"tokenEndpoint":"${PUB_DEV_PUBLISH_TOKEN_ENDPOINT}",
"idToken": "${PUB_DEV_PUBLISH_ID_TOKEN}",
"scopes":["openid","https://www.googleapis.com/auth/userinfo.email"],
"expiration":${PUB_DEV_PUBLISH_EXPIRATION}
}
EOF
7 changes: 3 additions & 4 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
name: network_tools_flutter
description: Extended features of network_tools for flutter framework.
version: 1.0.0
issue_tracker: https://github.com/osociety/network_tools/issues
repository: https://github.com/osociety/network_tools/tree/main/network_tools_flutter
publish_to: none
issue_tracker: https://github.com/osociety/network_tools_flutter/issues
repository: https://github.com/osociety/network_tools_flutter.git

environment:
sdk: ">=2.17.6 <3.0.0"
sdk: ">=2.17.6 <4.0.0"
flutter: ">=1.17.0"

dependencies:
Expand Down
21 changes: 15 additions & 6 deletions test/host_scan_flutter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:universal_io/io.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
int port = 0;
int hostId = 0;
String myOwnHost = "0.0.0.0";
String interfaceIp = myOwnHost.substring(0, myOwnHost.lastIndexOf('.'));
late ServerSocket server;
Expand All @@ -27,25 +28,33 @@ void main() {
.address; //gives IP address of GHA local machine.
myOwnHost = address;
interfaceIp = address.substring(0, address.lastIndexOf('.'));
hostId = int.parse(
address.substring(address.lastIndexOf('.') + 1, address.length));
}
}
});

group('Testing Host Scanner', () {
test('Running getAllPingableDevicesAsync tests', () async {
group('Testing Host Scanner emits', () {
test('Running getAllPingableDevices emits tests', () async {
expectLater(
//There should be at least one device pingable in network
HostScannerFlutter.getAllPingableDevices(
HostScannerFlutter.getAllPingableDevices(
interfaceIp,
timeoutInSeconds: 3,
// Better to restrict to scan from hostId - 1 to hostId + 1 to prevent GHA timeouts
firstHostId: hostId - 1,
lastHostId: hostId + 1,
),
emits(isA<ActiveHost>()),
);
});
test('Running getAllPingableDevices emitsThrough tests', () async {
expectLater(
//Should emit at least our own local machine when pinging all hosts.
HostScannerFlutter.getAllPingableDevices(
HostScannerFlutter.getAllPingableDevices(
interfaceIp,
timeoutInSeconds: 3,
// Better to restrict to scan from hostId - 1 to hostId + 1 to prevent GHA timeouts
firstHostId: hostId - 1,
lastHostId: hostId + 1,
),
emitsThrough(ActiveHost(internetAddress: InternetAddress(myOwnHost))),
);
Expand Down

0 comments on commit 433afdd

Please sign in to comment.