Tuesday, December 9, 2014

Continuous Integration Testing Polymer (Dart) Elements


Tonight, I place a Polymer.dart project under continuous integration. I have done similar work with some of the tests in the Patterns in Polymer book, but that is running on a custom install Jenkins server. This time, I am going to install on a standard CI service—Drone.io.

Last night I got a command-line build script ready for the AFormInput class/mixin. I hope that getting that test running on the service will be similar to "regular" Dart projects, but there is only one way to be sure. The only difference between these tests and regular Dart CI that I can foresee causing trouble is the need to fire up a Dart Pub server during the tests. The test script from last night should take care of this—it is more a question of if the CI service will allow it.

I start by publishing the project to GitHub at: https://github.com/eee-c/a-form-input-dart. With that, I am ready to create a new project in Drone, which is done by selecting a project from the list of GitHub projects associated with my account:



The choice of project template is easy:



And the initial test setup looks great (I created test/run.sh last night):



With that, I think I'm ready to test:



Or not. The first build fails with:
$ test/run.sh
Analyzing [lib/a_form_input.dart]...
No issues found
Looks good!

Loading source assets...
Loading polymer transformers...
Serving a-form-input test on http://localhost:8080
Build completed successfully
test/run.sh: line 20: content_shell: command not found
That's a solved problem, so I solve it again by adding a step in test/run.sh to install content_shell:
#!/bin/bash

# Static type analysis...

# Install content_shell if not already present
which content_shell
if [[ $? -ne 0 ]]; then
  $DART_SDK/../chromium/download_contentshell.sh
  unzip content_shell-linux-x64-release.zip

  cs_path=$(ls -d drt-*)
  PATH=$cs_path:$PATH
fi

# Run tests...
With that... the build still fails. I was not sure it would be necessary, but indeed, I do need to start xvfb to provide the X windowing environment for content_shell:
sudo start xvfb
pub install
test/test_runner.sh
And with that, I have a passing build—pub server and all:
Loading source assets...
Loading polymer transformers...
Serving a-form-input test on http://localhost:8080
Build completed successfully
....
CONSOLE MESSAGE: PASS: AFormInputMixin mixed into <x-double> has a shadowRoot
CONSOLE MESSAGE: PASS: AFormInputMixin mixed into <x-double> acts like <input> - value property is updated when internal state changes
CONSOLE MESSAGE: PASS: AFormInputMixin mixed into <x-double> acts like <input> - value attribute is updated when internal state changes
CONSOLE MESSAGE: PASS: AFormInputMixin mixed into <x-double> acts like <input> - form value attribute is updated when internal state changes
CONSOLE MESSAGE: PASS: AFormInputMixin mixed into <x-double> acts like <input> - containing form includes input with supplied name attribute
CONSOLE MESSAGE: PASS: AFormInputMixin mixed into <x-double> acts like <input> - setting the name property updates the name attribute
CONSOLE MESSAGE: 
CONSOLE MESSAGE: All 6 tests passed.
With the build passing:



All that is left is to copy the badge code:



Into the project README:



And that is all there is to it! So my worries were unfounded—Drone.io makes it just as easy to test a Polymer.dart project as it does to test any other Dart project. That is great news. Up tomorrow, I will push my luck by attempting to do the same with a JavaScript Polymer project.


Day #19

1 comment: