Roku’s deployment process is pretty straightforward: you just upload a zip archive of the source, and you’re finished. It’s that simple, which is great, but when deploying to a device 50 times a day, there can be a better way.

Android TV and tvOS are built upon their respective mobile platforms, and have all the features you’d expected from modern build tools: flavor support, command line interface, automation, unit testing, and build server support.

These elements improve development efficiency with better organization, speed, and test coverage. By virtue of their deployment process, Roku doesn’t have build tools. So we made our own. Here’s how.

divider 600

Flavor Support

Borrowing from the Android ideology, we developed a tool that allows us to define different flavors for a specific Roku channel. Flavors are essentially different versions of the same channel (or app), which share a single code base. For example, you might keep these three flavors of your app:

  • Release, which is the ready-for-production instance.
  • Debug, where the backend is switched out for a development environment, and possibly other parameters
  • MockDebug, where even more environments are switched out for mocked APIs or services that make it easier for the QA team.

Flavor support also makes it easy to build multiple channels based on the same features with different designs. BrightScript lacks a dependency manager, which causes developers to struggle to create a maintainable code base.

To solve this challenge of the platform, we added the ability to define the location of third party SDKs. By separating the third party code, this helps developers better maintain the channel’s core code.

Directory structure:

└── project-root
    ├── build.properties
    └── src
        ├── blueTheme
        ├── debug
        ├── main
        ├── release
        ├── test
        └── yellowTheme

Constants

Borrowing from Android’s ecosystem again, we added a compile-time step by inserting strings into the source code (defined by an ID). Incorporating our version of Android’s resources was an important step in the development process because it allowed developers to change a value (i.e. url or file path) from a single point in the app and define all uses of that particular value. These constants, defined in a file used only by our build tools, can be established as different values for different flavors. This ultimately optimizes processes involved with debugging, refactoring, and testing.

Xml:

<Label text="@{strings.title}" color="@{colors.primary}"/>
<Poster
  id="backgroundPoster"
  uri="@{images.background}"
  opacity="@{values.background.opacity}" />

Brightscript:

sub init()
  ...
  m.title.text = ”@{strings.title}”
  m.titleFont.uri = “@{fonts.roboto.regular}”
  m.background.color = “@{colors.primary}”
  m.button.focusedTextColor = “@{colors.accent}”
end sub

Efficiency

Intricate user interfaces can be aesthetically appealing, but the command line should be fast and flexible. With the adoption of our build tools, developers can define and configure a list of Roku devices to test on.

One command can compile and install the channel on the Roku device of choice (defined by name, serial number, or IP address), skipping the use of the Roku device’s web interface.

By streamlining the development process, we are able to keep deployment consistent and simplify the build process for developers.

Install blueTheme in debug:

roku-build-tool install blueThemeDebug

Install to a specific device:

Roku-build-tool install yellowThemeRelease --roku=roku-premiere

Unit Tests

Testing is central to all of our build processes at WillowTree. Among the most important features of our newly adopted Roku build tools is the Roku Unit Test Framework.

WillowTree modified and improved this framework to meet our team’s needs. Similar to installation, with a single command, developers are able to run unit tests and return the results on screen. The framework also outputs to a file that follows the JUnit XML schema.

Test a flavor:
roku-build-tool test yellowTheme

Build Server Integration

All of this comes together on the build server when bringing Roku development tools up to par with Android TV and tvOS. As mentioned before, the command line tool allows us to automate our processes. Every change that is committed to a code base is built on our build servers, which compiles and runs unit tests for the channel.

Similar to other platforms, if tests fail, the builds fail, and we are able to fix any issues before they even reach QA. Our test results are even compatible with our project dashboards. We’re also in the process of integrating these build tools with our BrightScript linter, which will keep our code clean and following best practices.

divider 600

With these in-house tools, we are able to approach Roku builds with flexibility and versatility comparable to other major platforms. Refined build tools keep our code, teamwork, and processes top quality. Additionally, we have the benefit of being able to add or improve features as we see fit. These tools save valuable time and effort, which is better spent delivering the best product possible.