Building a Dart Project
What This Guide Covers
Travis CI support for Dart is contributed by the community and may be removed
or altered at any time. If you run into any problems, please report them in the
Travis CI issue tracker
Choosing Dart versions to test against
Dart workers on travis-ci.org download and install the Dart SDK archives. See
the Dart Download Archive for the list of
available archives. By default, the latest stable SDK version is downloaded. To
explicitly select one or more versions, use the
dart key. For example:
language: dart dart: # Install the latest stable release - stable # Install the latest dev release - dev # Install a specific stable release - 1.15.0 - "1.15.0" # Install a specific dev release, using a partial download URL - 1.16.0-dev.3.0 - "dev/release/1.16.0-dev.3.0"
This creates a separate Travis job for each Dart version. It can be used in
env or similar fields to create a build matrix.
If your Dart package has a
pubspec.yaml file, then
pub get will be run
before your tests to install any dependencies of the package.
You can also customize the arguments Travis passes to the test runner using the
dart_task field in
language: dart dart_task: - test: --platform vm - test: --platform chrome
Each task creates a separate Travis job. It can be used in conjunction with
dart, or similar fields to create a build matrix.
Travis comes with Firefox and Chrome installed by default on Linux, and Safari
on OS X. However, if you want to run your tests on Dartium, you’ll need to
install it by adding
install_dartium: true either at the top level or for a
language: dart dart_task: - test: --platform vm - test: --platform dartium install_dartium: true
On Linux, the test runner uses XVFB by default so that it can use browsers
like Chrome that require a display. However, this may interfere with certain
applications, so you can turn it off by setting
xvfb: false either at the top
level or for a particular task.
language: dart dart_task: - test: --exclude-tags no-xvfb - test: --tags no-xvfb xvfb: false
XVFB is never used on OS X, since it doesn’t use the X windows system.
Several tasks are available in addition to running tests.
To run the Dart analyzer to verify that your code doesn’t have any static
errors, add a task with
dartanalyzer: true. By default it analyzes all Dart
files in your repository, but you can configure it by providing arguments
language: dart dart_task: # As long as you don't want any other configuration, you can just use the name # of a task instead of "name: true". - test # Warnings are fatal, but we only analyze the lib/ directory. - dartanalyzer: --fatal-warnings lib
To run the Dart formatter to verify that all your files are correctly
formatted, add a task with
dartfmt: true. If your package depends on the
dart_style package, it’ll use that package’s formatter version; otherwise,
it’ll use the
dartfmt that comes with your Dart SDK.
language: dart dart_task: - test: --platform vm - test: --platform chrome - dartfmt
The version of Dart a job is using is available as