Over the past couple of weeks I've been working on migrating Spidermonkey builds to a new platform that Mozilla's teams have access to called TaskCluster.
When I started out initially I saw quite a lot of documentation and code, but I still had to go ask people for how to go about certain things, for lack of a 'tutorial' of sorts that made all the pieces fit together.
Given that a lot of the people might like to leverage TaskCluster in the future, I figured it might be a good idea to walk through how I went about it, which should give a better over picture of what taskcluster can do and how the pieces fit together.
This won't be a tutorial or anything of the sort, but if starting out, should still serve as a decent example-oriented 'guide' of how one might go about things.
If you already know the what, why and when of taskcluster, skip to the 'My Process' section for the how.
What is it?
This is not an easy question to answer. In essence it's a task automation system. All it's functionality is exposed via APIs documented at http://docs.taskcluster.net. You can use it to define and launch arbitrary tasks. For example, anything that you can run on a Linux box can most likely be run on taskcluster as a stand alone task. There's already work in progress to get thing running on Windows, with OSX and possibly physical devices such as phones follow in the future.
The important thing to note is that taskcluster is an API based service, which means you can use TaskCluster Tools which is a front end for most of the API end points, or write your own. You can also use curl or wget if you're feeling really old-school or hardcore. But ideally if you're writing anything serious, please consider using the taskcluster client libraries written for node, python or golang.
What can I use it for?
Builds, Tests, automation tasks, one-off tasks, pretty much everything. There's work underway to allow one to run security critical tasks safely as well.
Where do I go looking for help?
I've found to be helpful, but it takes a little getting used to the navigation and lookup style. Looking at existing examples of how things work in-tree is also a great to way to figure out how things are done. These is also a taskcluster Youtube channel with tutorials being uploaded to it.
If everything else fails, #taskcluster is your friend.
TaskCluster accepts docker images to run tasks in. You create a docker image with your environment and then pass taskcluster the command you want to run inside a container with that image. How this is done, I'll come to shortly, but I'd like to point out that docker-worker, the one that I used for this particular piece is one of two currently available types, the other being generic-worker.
In theory, automation by taskcluster is not limited to any of these and anyone can write their own worker that could run on any platform.
If you want to automate on anything other than Linux, you'll probably need generic-worker at the time of writing and it's near future.
Migrating Spidermonkey Builds to Taskcluster and getting them in a state that people could use them was a two step process (only in hindsight, bah agile).
This is what it looks like:
Phase I (See Bug 1164656)
- Figure out how to run a Spidermonkey build in a docker container
- Create Dockerfile for said container
- Create a script with the commands you want to run inside the container.
- Test Docker image and script
- Create the task payload.
- Test payload and image + container by manually triggering a task using Task-Creator
- Iterate until satisfaction
Phase II (See Bug 1174376)
- Figure out the different possible combinations of variables (platform, type, etc.) that spidermonkey builds can take. See this comment(Add these to [Try](https://hg.mozilla.org/try)/[Treeherder](https://treeherder.mozilla.org) by
- Adding job flags [here](https://dxr.mozilla.org/mozilla-central/source/testing/taskcluster/tasks/job_flags.yml)
- Also adding them in a slightly different format [here](https://dxr.mozilla.org/mozilla-central/source/testing/taskcluster/tasks/branches/try/job_flags.yml)
- Finally create job configurations under [here](https://dxr.mozilla.org/mozilla-central/source/testing/taskcluster/tasks/builds)
- Run ./mach taskcluster-graph with the newly added try flags, make sure the output looks about right and is close to that from Phase 1
- Push to try with the newly added flags, watch treeherder for your push to show up correctly
- It probably didn't show up correctly on the first go, investigate, fix, iterate.
- Figure out what artifacts need to go out of the build and then add put them in the right place (most likely $HOME/artifacts)