drone.io has really proven to be useful for dart projects. One common pattern I find my self doing with projects these days is running the dart_analyzer before running unit tests. Had a discussion with Kevin Moore about having a dart_analyzer task included in hop, part of the bot.dart framework. We both agreed it would be nice to automate that task and not have shell scripts running the show. Thus createDartAnalyzerTask was born. createDartAnalyzerTask allows you to add dart scripts that are libraries or main entry points to be analyzed by dart_analyzer, this allows for a first step of safety, so that code you have passes the static checker. It does not mean your code is perfect but can help you find warnings and errors. A great combination for this is pairing it up with drone.io, that way when a new sdk comes out drone can let you know automatically if it passes static checker.
libraryhop_runner;import'dart:async';import'dart:io';import'package:bot/bot.dart';import'package:bot/hop.dart';import'package:bot/hop_tasks.dart';voidmain(){//// Analyzer//addTask('analyze_lib',createDartAnalyzerTask(['lib/stats.dart']));//// Hop away!//runHopCore();}
Add a bin/hop script to your project, bin/hop script is not required but does help manage some flags you might be interested in having.
Now we have a warning, but since dart is a dynamic langauge we should not treat that as an error (at some point we might provide the option of making warnings fail drone.io).
If we introduce a real error, the task runner should yell at us.
The exit code will let drone.io know that we did not exit cleanly. I love drone.io for this reason, it’s simple to get setup right away with little fuss.
A complete run on drone.io might look something as follows