How we made our own Roku build tools

September 19, 2017

SamHeavner

Platform Software Engineer

Platform Software Engineer

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 really have build tools. So we made our own:

We’ve also created an Atom plugin for seamless integration into your workflow. A VSCode plugin is coming soon.

Here’s some detail on how and why we made these tools.

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.

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.

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

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.

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.