Switch to GitHub Actions (#188)
This PR switches to use GitHub Actions instead of Travis, and updates the analysis options to use the recommended Dart lints from the lints packages.
diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml
deleted file mode 100644
index bd08b2f..0000000
--- a/.github/workflows/dart.yml
+++ /dev/null
@@ -1,42 +0,0 @@
-# This workflow uses actions that are not certified by GitHub.
-# They are provided by a third-party and are governed by
-# separate terms of service, privacy policy, and support
-# documentation.
-
-name: Dart
-
-on:
- push:
- branches: [ master ]
- pull_request:
- branches: [ master ]
-
-jobs:
- build:
- runs-on: ubuntu-latest
-
- steps:
- - uses: actions/checkout@v2
-
- # 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/setup-dart@v1
- - uses: dart-lang/setup-dart@9a04e6d73cca37bd455e0608d7e5092f881fd603
-
- - name: Install dependencies
- run: dart pub get
-
- # Uncomment this step to verify the use of 'dart format' on each commit.
- # - name: Verify formatting
- # run: dart format --output=none --set-exit-if-changed .
-
- # Consider passing '--fatal-infos' for slightly stricter analysis.
- - name: Analyze project source
- run: dart analyze
-
- # Your project will need to have tests in test/ and a dependency on
- # package:test for this step to succeed. Note that Flutter projects will
- # want to change this to 'flutter test'.
- - name: Run tests
- run: dart test
diff --git a/.github/workflows/file.yml b/.github/workflows/file.yml
new file mode 100644
index 0000000..581e9df
--- /dev/null
+++ b/.github/workflows/file.yml
@@ -0,0 +1,52 @@
+name: File Package
+
+on:
+ push:
+ branches: [ master ]
+ pull_request:
+ branches: [ master ]
+ workflow_dispatch:
+
+jobs:
+ correctness:
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ package: [file, file_testing]
+ steps:
+ - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
+ - uses: dart-lang/setup-dart@9a04e6d73cca37bd455e0608d7e5092f881fd603
+ with:
+ sdk: dev
+ - name: Install ${{ matrix.package }} dependencies
+ run: |
+ cd packages/${{ matrix.package }}
+ dart pub upgrade
+ - name: Verify formatting in ${{ matrix.package }}
+ run: |
+ cd packages/${{ matrix.package }}
+ dart format --output=none --set-exit-if-changed .
+ - name: Analyze package ${{ matrix.package }} source
+ run: |
+ cd packages/${{ matrix.package }}
+ dart analyze --fatal-infos
+ test:
+ runs-on: ${{ matrix.os }}
+ strategy:
+ matrix:
+ package: [file]
+ os: [ubuntu-latest, macos-latest, windows-latest]
+ sdk: [stable, beta, dev]
+ steps:
+ - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
+ - uses: dart-lang/setup-dart@9a04e6d73cca37bd455e0608d7e5092f881fd603
+ with:
+ sdk: ${{ matrix.sdk }}
+ - name: Install ${{ matrix.package }} dependencies
+ run: |
+ cd packages/${{ matrix.package }}
+ dart pub upgrade
+ - name: Run ${{ matrix.package }} Tests
+ run: |
+ cd packages/${{ matrix.package }}
+ dart pub run test -j1 -rexpanded
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 0b16974..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-env:
- - SHARD=dartfmt
- - SHARD=analyze
- - SHARD=tests
-install:
- - ./dev/bots/travis_install.sh
-script:
- - ./dev/bots/travis_script.sh
diff --git a/analysis_options.yaml b/analysis_options.yaml
index ee1a01b..8fbd2e4 100644
--- a/analysis_options.yaml
+++ b/analysis_options.yaml
@@ -1,165 +1,6 @@
-analyzer:
- enable-experiment:
- - non-nullable
- strong-mode:
- implicit-casts: false
- implicit-dynamic: false
- errors:
- # treat missing required parameters as a warning (not a hint)
- missing_required_param: warning
- # treat missing returns as a warning (not a hint)
- missing_return: warning
- # allow having TODOs in the code
- todo: ignore
+include: package:lints/recommended.yaml
-linter:
- rules:
- # these rules are documented on and in the same order as
- # the Dart Lint rules page to make maintenance easier
- # https://github.com/dart-lang/linter/blob/master/example/all.yaml
- - always_declare_return_types
- - always_put_control_body_on_new_line
- # - always_put_required_named_parameters_first # we prefer having parameters in the same order as fields https://github.com/flutter/flutter/issues/10219
- - always_require_non_null_named_parameters
- - always_specify_types
- - annotate_overrides
- # - avoid_annotating_with_dynamic # conflicts with always_specify_types
- # - avoid_as
- - avoid_bool_literals_in_conditional_expressions
- # - avoid_catches_without_on_clauses # we do this commonly
- # - avoid_catching_errors # we do this commonly
- - avoid_classes_with_only_static_members
- # - avoid_double_and_int_checks # only useful when targeting JS runtime
- - avoid_empty_else
- - avoid_field_initializers_in_const_classes
- - avoid_function_literals_in_foreach_calls
- # - avoid_implementing_value_types # not yet tested
- - avoid_init_to_null
- # - avoid_js_rounded_ints # only useful when targeting JS runtime
- - avoid_null_checks_in_equality_operators
- # - avoid_positional_boolean_parameters # not yet tested
- # - avoid_private_typedef_functions # we prefer having typedef (discussion in https://github.com/flutter/flutter/pull/16356)
- - avoid_relative_lib_imports
- - avoid_renaming_method_parameters
- - avoid_return_types_on_setters
- # - avoid_returning_null # there are plenty of valid reasons to return null
- # - avoid_returning_null_for_future # not yet tested
- - avoid_returning_null_for_void
- # - avoid_returning_this # there are plenty of valid reasons to return this
- # - avoid_setters_without_getters # not yet tested
- # - avoid_shadowing_type_parameters # not yet tested
- # - avoid_single_cascade_in_expression_statements # not yet tested
- # - avoid_slow_async_io
- - avoid_types_as_parameter_names
- # - avoid_types_on_closure_parameters # conflicts with always_specify_types
- - avoid_unused_constructor_parameters
- - avoid_void_async
- - await_only_futures
- - camel_case_types
- - cancel_subscriptions
- # - cascade_invocations # not yet tested
- # - close_sinks # not reliable enough
- # - comment_references # blocked on https://github.com/flutter/flutter/issues/20765
- # - constant_identifier_names # needs an opt-out https://github.com/dart-lang/linter/issues/204
- - control_flow_in_finally
- # - curly_braces_in_flow_control_structures # not yet tested
- # - diagnostic_describe_all_properties # not yet tested
- - directives_ordering
- - empty_catches
- - empty_constructor_bodies
- - empty_statements
- # - file_names # not yet tested
- - flutter_style_todos
- - hash_and_equals
- - implementation_imports
- # - invariant_booleans # too many false positives: https://github.com/dart-lang/linter/issues/811
- - iterable_contains_unrelated_type
- # - join_return_with_assignment # not yet tested
- - library_names
- - library_prefixes
- # - lines_longer_than_80_chars # not yet tested
- - list_remove_unrelated_type
- # - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/sdk/issues/34181
- - no_adjacent_strings_in_list
- - no_duplicate_case_values
- - non_constant_identifier_names
- # - null_closures # not yet tested
- # - omit_local_variable_types # opposite of always_specify_types
- # - one_member_abstracts # too many false positives
- # - only_throw_errors # https://github.com/flutter/flutter/issues/5792
- - overridden_fields
- - package_api_docs
- - package_names
- - package_prefixed_library_names
- # - parameter_assignments # we do this commonly
- - prefer_adjacent_string_concatenation
- - prefer_asserts_in_initializer_lists
- # - prefer_asserts_with_message # not yet tested
- # - prefer_collection_literals
- - prefer_conditional_assignment
- - prefer_const_constructors
- - prefer_const_constructors_in_immutables
- - prefer_const_declarations
- - prefer_const_literals_to_create_immutables
- # - prefer_constructors_over_static_methods # not yet tested
- - prefer_contains
- # - prefer_double_quotes # opposite of prefer_single_quotes
- - prefer_equal_for_default_values
- # - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods
- - prefer_final_fields
- # - prefer_final_in_for_each # not yet tested
- # - prefer_final_locals
- # - prefer_for_elements_to_map_fromIterable # not yet tested
- - prefer_foreach
- # - prefer_function_declarations_over_variables # not yet tested
- - prefer_generic_function_type_aliases
- # - prefer_if_elements_to_conditional_expressions # not yet tested
- - prefer_if_null_operators
- - prefer_initializing_formals
- - prefer_inlined_adds
- # - prefer_int_literals # not yet tested
- # - prefer_interpolation_to_compose_strings # not yet tested
- - prefer_is_empty
- - prefer_is_not_empty
- - prefer_iterable_whereType
- # - prefer_mixin # https://github.com/dart-lang/language/issues/32
- # - prefer_null_aware_operators # disable until NNBD, see https://github.com/flutter/flutter/pull/32711#issuecomment-492930932
- - prefer_single_quotes
- - prefer_spread_collections
- - prefer_typing_uninitialized_variables
- # - prefer_void_to_null
- # - provide_deprecation_message # not yet tested
- - public_member_api_docs
- - recursive_getters
- - slash_for_doc_comments
- # - sort_child_properties_last # not yet tested
- - sort_constructors_first
- - sort_pub_dependencies
- - sort_unnamed_constructors_first
- - test_types_in_equals
- - throw_in_finally
- # - type_annotate_public_apis # subset of always_specify_types
- - type_init_formals
- - unawaited_futures
- # - unnecessary_await_in_return # not yet tested
- - unnecessary_brace_in_string_interps
- - unnecessary_const
- - unnecessary_getters_setters
- # - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498
- - unnecessary_new
- - unnecessary_null_aware_assignments
- - unnecessary_null_in_if_null_operators
- - unnecessary_overrides
- - unnecessary_parenthesis
- - unnecessary_statements
- - unnecessary_this
- - unrelated_type_equality_checks
- # - unsafe_html # not yet tested
- - use_full_hex_values_for_flutter_colors
- # - use_function_type_syntax_for_parameters # not yet tested
- - use_rethrow_when_possible
- # - use_setters_to_change_properties # not yet tested
- # - use_string_buffers # has false positives: https://github.com/dart-lang/sdk/issues/34182
- # - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review
- - valid_regexps
- # - void_checks # not yet tested
+analyzer:
+ errors:
+ # Allow having TODOs in the code
+ todo: ignore
diff --git a/dev/bots/travis_install.sh b/dev/bots/travis_install.sh
deleted file mode 100755
index ff2f932..0000000
--- a/dev/bots/travis_install.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/bash
-set -ex
-
-echo "$PWD"
-
-export PATH="$HOME/dart-sdk/bin:$PATH"
-export ROOT="$PWD"
-export PACKAGES=("file" "file_testing")
-
-wget \
- --tries=3 \
- --output-document=dart-sdk.zip \
- https://storage.googleapis.com/dart-archive/channels/dev/release/latest/sdk/dartsdk-linux-x64-release.zip
-echo "Unzipping dart-sdk..."
-unzip dart-sdk.zip -d "$HOME" > /dev/null
-
-for package in "${PACKAGES[@]}"; do
- cd $ROOT/packages/$package
- pub get
-done
diff --git a/dev/bots/travis_script.sh b/dev/bots/travis_script.sh
deleted file mode 100755
index fe55e57..0000000
--- a/dev/bots/travis_script.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/bash
-set -ex
-
-export PATH="$HOME/dart-sdk/bin:$PATH"
-export ROOT="$PWD"
-export PACKAGES=("file" "file_testing")
-
-if [[ "$SHARD" == "dartfmt" ]]; then
- dartfmt --dry-run --set-exit-if-changed packages || exit $?
-elif [[ "$SHARD" == "analyze" ]]; then
- for package in "${PACKAGES[@]}"; do
- echo "Analyzing packages/$package"
- cd $ROOT/packages/$package
- dartanalyzer --options=$ROOT/analysis_options.yaml . || exit $?
- done
-else
- # tests shard
- cd $ROOT/packages/file
- pub run test -j1 -rexpanded || exit $?
-fi
diff --git a/packages/file/lib/src/backends/chroot/chroot_file_system.dart b/packages/file/lib/src/backends/chroot/chroot_file_system.dart
index ddf752e..6889c98 100644
--- a/packages/file/lib/src/backends/chroot/chroot_file_system.dart
+++ b/packages/file/lib/src/backends/chroot/chroot_file_system.dart
@@ -277,7 +277,7 @@
}
String getCurrentPath() => root + ctx.joinAll(ledger);
- Set<String> breadcrumbs = Set<String>();
+ Set<String> breadcrumbs = <String>{};
while (parts.isNotEmpty) {
String segment = parts.removeAt(0);
if (segment == _thisDir) {
diff --git a/packages/file/lib/src/backends/memory/memory_directory.dart b/packages/file/lib/src/backends/memory/memory_directory.dart
index 9288f7e..ec8ad45 100644
--- a/packages/file/lib/src/backends/memory/memory_directory.dart
+++ b/packages/file/lib/src/backends/memory/memory_directory.dart
@@ -136,7 +136,7 @@
path.endsWith(fileSystem.path.separator)
? path.substring(0, path.length - 1)
: path,
- Set<LinkNode>(),
+ <LinkNode>{},
),
];
while (tasks.isNotEmpty) {
diff --git a/packages/file/lib/src/backends/memory/memory_file_system_entity.dart b/packages/file/lib/src/backends/memory/memory_file_system_entity.dart
index c2f9c4d..ad987d7 100644
--- a/packages/file/lib/src/backends/memory/memory_file_system_entity.dart
+++ b/packages/file/lib/src/backends/memory/memory_file_system_entity.dart
@@ -181,7 +181,8 @@
/// resolve it to its target prior to returning it.
@protected
Node? internalCreateSync({
- required Node? createChild(DirectoryNode parent, bool isFinalSegment),
+ required Node? Function(DirectoryNode parent, bool isFinalSegment)
+ createChild,
bool followTailLink = false,
bool visitLinks = false,
}) {
diff --git a/packages/file/lib/src/backends/memory/node.dart b/packages/file/lib/src/backends/memory/node.dart
index 4cbb25c..ae4d3f7 100644
--- a/packages/file/lib/src/backends/memory/node.dart
+++ b/packages/file/lib/src/backends/memory/node.dart
@@ -306,7 +306,8 @@
/// target cannot be traversed into, a [FileSystemException] will be thrown,
/// and [tailVisitor] will not be invoked.
Node getReferent({
- Node? tailVisitor(DirectoryNode parent, String childName, Node? child)?,
+ Node? Function(DirectoryNode parent, String childName, Node? child)?
+ tailVisitor,
}) {
Node? referent = fs.findNode(
target,
diff --git a/packages/file/lib/src/backends/memory/utils.dart b/packages/file/lib/src/backends/memory/utils.dart
index 109baed..eec9980 100644
--- a/packages/file/lib/src/backends/memory/utils.dart
+++ b/packages/file/lib/src/backends/memory/utils.dart
@@ -82,10 +82,11 @@
LinkNode link,
PathGenerator path, {
List<String>? ledger,
- Node? tailVisitor(DirectoryNode parent, String childName, Node? child)?,
+ Node? Function(DirectoryNode parent, String childName, Node? child)?
+ tailVisitor,
}) {
// Record a breadcrumb trail to guard against symlink loops.
- Set<LinkNode> breadcrumbs = Set<LinkNode>();
+ Set<LinkNode> breadcrumbs = <LinkNode>{};
Node node = link;
while (isLink(node)) {
diff --git a/packages/file/lib/src/interface/error_codes.dart b/packages/file/lib/src/interface/error_codes.dart
index 2629a5d..8943538 100644
--- a/packages/file/lib/src/interface/error_codes.dart
+++ b/packages/file/lib/src/interface/error_codes.dart
@@ -167,7 +167,7 @@
// ignore: non_constant_identifier_names
static int get EXDEV => _platform((_Codes codes) => codes.exdev);
- static int _platform(int getCode(_Codes codes)) {
+ static int _platform(int Function(_Codes codes) getCode) {
_Codes codes = (_platforms[operatingSystem] ?? _platforms['linux'])!;
return getCode(codes);
}
diff --git a/packages/file/pubspec.yaml b/packages/file/pubspec.yaml
index 3037f3a..f6d82de 100644
--- a/packages/file/pubspec.yaml
+++ b/packages/file/pubspec.yaml
@@ -15,4 +15,5 @@
dev_dependencies:
file_testing: '>=3.0.0 <4.0.0'
+ lints: ^1.0.1
test: '^1.16.0'
diff --git a/packages/file/test/common_tests.dart b/packages/file/test/common_tests.dart
index 207c082..9e97c15 100644
--- a/packages/file/test/common_tests.dart
+++ b/packages/file/test/common_tests.dart
@@ -64,7 +64,7 @@
late String root;
List<String> stack = <String>[];
- void skipIfNecessary(String description, void callback()) {
+ void skipIfNecessary(String description, void Function() callback) {
stack.add(description);
bool matchesCurrentFrame(String input) =>
RegExp('^$input\$').hasMatch(stack.join(' > '));
@@ -80,11 +80,11 @@
tearDowns = <SetUpTearDown>[];
});
- void setUp(FutureOr<void> callback()) {
+ void setUp(FutureOr<void> Function() callback) {
testpkg.setUp(replay == null ? callback : () => setUps.add(callback));
}
- void tearDown(FutureOr<void> callback()) {
+ void tearDown(FutureOr<void> Function() callback) {
if (replay == null) {
testpkg.tearDown(callback);
} else {
@@ -92,10 +92,11 @@
}
}
- void group(String description, void body()) =>
+ void group(String description, void Function() body) =>
skipIfNecessary(description, () => testpkg.group(description, body));
- void test(String description, FutureOr<void> body(), {dynamic skip}) =>
+ void test(String description, FutureOr<void> Function() body,
+ {dynamic skip}) =>
skipIfNecessary(description, () {
if (replay == null) {
testpkg.test(description, body, skip: skip);
@@ -866,7 +867,7 @@
test('throwsIfLoopInLinkChain', () {
fs.link(ns('/foo')).createSync(ns('/bar'));
fs.link(ns('/bar')).createSync(ns('/baz'));
- fs.link(ns('/baz'))..createSync(ns('/foo'));
+ fs.link(ns('/baz')).createSync(ns('/foo'));
expectFileSystemException(
anyOf(ErrorCodes.EMLINK, ErrorCodes.ELOOP),
() {
@@ -1433,7 +1434,7 @@
FileSystemEntityType.link);
expect(fs.file(ns('/foo')).readAsStringSync(), 'foo');
expect(fs.file(ns('/bar')).readAsStringSync(), 'foo');
- });
+ }, skip: io.Platform.isWindows /* No links on Windows */);
test('throwsIfDestinationExistsAsLinkToDirectory', () {
File f = fs.file(ns('/foo'))..createSync();
@@ -1518,7 +1519,7 @@
FileSystemEntityType.link);
expect(fs.file(ns('/foo/bar')).readAsStringSync(), 'qux');
expect(fs.file(ns('/baz/qux')).readAsStringSync(), 'qux');
- });
+ }, skip: io.Platform.isWindows /* No links on Windows */);
});
group('length', () {
@@ -3093,7 +3094,7 @@
test('unlinksIfTargetIsLinkLoop', () {
Link l = fs.link(ns('/foo'))..createSync(ns('/bar'));
- fs.link(ns('/bar'))..createSync(ns('/foo'));
+ fs.link(ns('/bar')).createSync(ns('/foo'));
l.deleteSync();
expect(fs.typeSync(ns('/foo'), followLinks: false),
FileSystemEntityType.notFound);
diff --git a/packages/file_testing/lib/src/testing/core_matchers.dart b/packages/file_testing/lib/src/testing/core_matchers.dart
index 70765c4..f58539f 100644
--- a/packages/file_testing/lib/src/testing/core_matchers.dart
+++ b/packages/file_testing/lib/src/testing/core_matchers.dart
@@ -61,7 +61,7 @@
///
/// See also:
/// - [ErrorCodes]
-void expectFileSystemException(dynamic osErrorCode, void callback()) {
+void expectFileSystemException(dynamic osErrorCode, void Function() callback) {
expect(callback, throwsFileSystemException(osErrorCode));
}
diff --git a/packages/file_testing/pubspec.yaml b/packages/file_testing/pubspec.yaml
index 85b6de4..e4c6ca1 100644
--- a/packages/file_testing/pubspec.yaml
+++ b/packages/file_testing/pubspec.yaml
@@ -8,3 +8,5 @@
dependencies:
test: ^1.16.0
+dev_dependencies:
+ lints: ^1.0.1
diff --git a/pubspec.yaml b/pubspec.yaml
new file mode 100644
index 0000000..2269e8f
--- /dev/null
+++ b/pubspec.yaml
@@ -0,0 +1,10 @@
+name: file_dart_repository
+version: 0.1.0
+description: The repository for the file.dart package
+publish_to: none
+
+environment:
+ sdk: '>=2.12.0 <3.0.0'
+
+dev_dependencies:
+ lints: ^1.0.1