From 5fae8228d9a7a8e70085bfd227d3fe6251ba8eaf Mon Sep 17 00:00:00 2001 From: Jace Hensley Date: Fri, 21 Oct 2016 15:27:43 -0700 Subject: [PATCH 1/5] Set up CI and coverage Also add .analysis_options with lints and excludes. --- .analysis_options | 24 ++++++++++++++++++++++++ .travis.yml | 14 ++++++++++++++ lib/src/component/resize_sensor.dart | 6 +----- pubspec.yaml | 1 - tool/dev.dart | 1 - tool/generate_coverage.sh | 4 ++++ 6 files changed, 43 insertions(+), 7 deletions(-) create mode 100644 .analysis_options create mode 100644 .travis.yml create mode 100644 tool/generate_coverage.sh diff --git a/.analysis_options b/.analysis_options new file mode 100644 index 000000000..b73a3daac --- /dev/null +++ b/.analysis_options @@ -0,0 +1,24 @@ +analyzer: + exclude: + - integrate/** +linter: + rules: + - annotate_overrides + - avoid_empty_else + - avoid_init_to_null + - avoid_return_types_on_setters + - camel_case_types + - empty_constructor_bodies + - hash_and_equals + - library_names + - library_prefixes + - package_api_docs + - package_names + - package_prefixed_library_names + - prefer_is_not_empty + - slash_for_doc_comments + - sort_constructors_first + - sort_unnamed_constructors_first + - type_init_formals + - unnecessary_brace_in_string_interp + - unnecessary_getters_setters diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..b128a5c72 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,14 @@ +language: dart +dart: + - stable +with_content_shell: true +before_install: + - export DISPLAY=:99.0 + - ./tool/setup_dartium.sh + - export PATH=$PATH":$PWD" + - sh -e /etc/init.d/xvfb start +script: + - pub run dart_dev analyze + - pub run dart_dev test + - ./generate_coverage.sh + - bash <(curl -s https://codecov.io/bash) -f coverage/coverage.lcov diff --git a/lib/src/component/resize_sensor.dart b/lib/src/component/resize_sensor.dart index fb176fbab..99f90c83b 100644 --- a/lib/src/component/resize_sensor.dart +++ b/lib/src/component/resize_sensor.dart @@ -82,7 +82,6 @@ class ResizeSensorComponent extends UiComponent { Element _expandSensorChildRef; Element _expandSensorRef; - Element _collapseSensorChildRef; Element _collapseSensorRef; @override @@ -115,10 +114,7 @@ class ResizeSensorComponent extends UiComponent { ..key = 'expandSensor' )(expandSensorChild); - var collapseSensorChild = (Dom.div() - ..ref = (ref) { _collapseSensorChildRef = ref; } - ..style = _collapseSensorChildStyle - )(); + var collapseSensorChild = (Dom.div()..style = _collapseSensorChildStyle)(); var collapseSensor = (Dom.div() ..className = 'resize-sensor-collapse' diff --git a/pubspec.yaml b/pubspec.yaml index 7adcf9f2f..146936734 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,4 @@ name: over_react -publish_to: https://pub.workiva.org version: 1.0.0 description: A library for building statically-typed React UI components using Dart. homepage: https://github.com/Workiva/over_react/ diff --git a/tool/dev.dart b/tool/dev.dart index 17fefd0d8..e3f9d88f0 100644 --- a/tool/dev.dart +++ b/tool/dev.dart @@ -19,7 +19,6 @@ import 'package:dart_dev/dart_dev.dart' show dev, config; main(List args) async { const directories = const [ 'lib/', - 'example/', 'test/', 'tool/', ]; diff --git a/tool/generate_coverage.sh b/tool/generate_coverage.sh new file mode 100644 index 000000000..0cf7e4411 --- /dev/null +++ b/tool/generate_coverage.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +# DART_FLAGS has to be set to `--checked` because dart_dev does not run tests in checked mode. +DART_FLAGS=--checked pub run dart_dev coverage --no-html --no-open From 206adc3bd5d9f7dd1793442d205c4c831c1e10c5 Mon Sep 17 00:00:00 2001 From: Jace Hensley Date: Mon, 24 Oct 2016 10:17:17 -0700 Subject: [PATCH 2/5] Add missing imports The imports are not used by the non-transformed code but they are needed for the transformed code. --- lib/src/component/aria_mixin.dart | 3 +++ lib/src/component/prop_mixins.dart | 3 +++ lib/src/util/class_names.dart | 3 +++ 3 files changed, 9 insertions(+) diff --git a/lib/src/component/aria_mixin.dart b/lib/src/component/aria_mixin.dart index 1b4413c33..126ee5891 100644 --- a/lib/src/component/aria_mixin.dart +++ b/lib/src/component/aria_mixin.dart @@ -16,6 +16,9 @@ library over_react.aria_mixin; import 'dart:collection'; +// Must import these consts because they are used in the transformed code. +// ignore: unused_import +import 'package:over_react/over_react.dart' show PropDescriptor, ConsumedProps; import 'package:over_react/src/component_declaration/annotations.dart'; /// Typed getters/setters for accessibility props. diff --git a/lib/src/component/prop_mixins.dart b/lib/src/component/prop_mixins.dart index a4a387107..a5b979b4d 100644 --- a/lib/src/component/prop_mixins.dart +++ b/lib/src/component/prop_mixins.dart @@ -15,6 +15,9 @@ /// Various prop related mixins to be used with [UiComponent] descendants. library over_react.prop_mixins; +// Must import these consts because they are used in the transformed code. +// ignore: unused_import +import 'package:over_react/over_react.dart' show PropDescriptor, ConsumedProps; import 'package:over_react/src/component/callback_typedefs.dart'; import 'package:over_react/src/component_declaration/annotations.dart'; diff --git a/lib/src/util/class_names.dart b/lib/src/util/class_names.dart index ae9746592..02a455152 100644 --- a/lib/src/util/class_names.dart +++ b/lib/src/util/class_names.dart @@ -17,6 +17,9 @@ library over_react.class_names; import 'dart:collection'; +// Must import these consts because they are used in the transformed code. +// ignore: unused_import +import 'package:over_react/over_react.dart' show PropDescriptor, ConsumedProps; import 'package:over_react/src/component_declaration/annotations.dart'; /// Typed getters/setters for props related to CSS class manipulation, and used by all UIP components. From 4b1de37716f8b44aaa0a215ef9bc8a3a5d35cfb8 Mon Sep 17 00:00:00 2001 From: Jace Hensley Date: Mon, 24 Oct 2016 10:23:35 -0700 Subject: [PATCH 3/5] Add necessary setup script for dartium --- tool/setup_dartium.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tool/setup_dartium.sh diff --git a/tool/setup_dartium.sh b/tool/setup_dartium.sh new file mode 100644 index 000000000..1895fa8fe --- /dev/null +++ b/tool/setup_dartium.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +set -e + +DARTIUM_DIST="dartium-linux-x64-release.zip"; +echo "Installing Dartium
" +curl "http://storage.googleapis.com/dart-archive/channels/stable/raw/latest/dartium/$DARTIUM_DIST" > $DARTIUM_DIST +unzip -u $DARTIUM_DIST > /dev/null +rm $DARTIUM_DIST +mv dartium-* dartiumdir +export DARTIUM_BIN="$PWD/dartiumdir/chrome" + +SELENIUM_JAR="selenium-server.jar"; +echo "Installing Selenium" +curl "http://selenium-release.storage.googleapis.com/2.48/selenium-server-standalone-2.48.2.jar" > $SELENIUM_JAR +echo "#!/usr/bin/env bash" | tee -a selenium-server +echo "exec java -jar $PWD/$SELENIUM_JAR \"$@\"" | tee -a selenium-server +chmod +x selenium-server + +CHROMEDRIVER="chromedriver.zip"; +echo "Installing Chromedriver" +curl "http://chromedriver.storage.googleapis.com/2.14/chromedriver_linux64.zip" > $CHROMEDRIVER +unzip $CHROMEDRIVER +chmod +x chromedriver +ln -s "$PWD/dartiumdir/chrome" "$PWD/dartium" + +export PATH=$PATH":$PWD" From 710d3bb2bf6b0fc4eefe20b6f5f8ca7a2b84015b Mon Sep 17 00:00:00 2001 From: Jace Hensley Date: Mon, 24 Oct 2016 10:32:40 -0700 Subject: [PATCH 4/5] Fix permissions on scripts --- .travis.yml | 2 +- tool/generate_coverage.sh | 0 tool/setup_dartium.sh | 0 3 files changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 tool/generate_coverage.sh mode change 100644 => 100755 tool/setup_dartium.sh diff --git a/.travis.yml b/.travis.yml index b128a5c72..92376d053 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,5 +10,5 @@ before_install: script: - pub run dart_dev analyze - pub run dart_dev test - - ./generate_coverage.sh + - ./tool/generate_coverage.sh - bash <(curl -s https://codecov.io/bash) -f coverage/coverage.lcov diff --git a/tool/generate_coverage.sh b/tool/generate_coverage.sh old mode 100644 new mode 100755 diff --git a/tool/setup_dartium.sh b/tool/setup_dartium.sh old mode 100644 new mode 100755 From b71148bf90f161c2ef684b23489175a03970fedf Mon Sep 17 00:00:00 2001 From: Jace Hensley Date: Mon, 24 Oct 2016 10:53:09 -0700 Subject: [PATCH 5/5] Switch to testing on minimum supported dart version --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 92376d053..8098fc9ab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: dart dart: - - stable + - "1.17.1" with_content_shell: true before_install: - export DISPLAY=:99.0