Kevin Burke | f9586dc | 2017-07-18 20:10:49 -0700 | [diff] [blame] | 1 | # Go Build Tools |
| 2 | |
Andrew Gerrand | 34bf450 | 2015-01-21 17:09:50 +1100 | [diff] [blame] | 3 | This subrepository holds the source for various packages and tools that support |
Kevin Burke | f9586dc | 2017-07-18 20:10:49 -0700 | [diff] [blame] | 4 | Go's build system and the development of the Go programming language. |
Chris Manghane | 7d85ae4 | 2013-08-01 13:23:51 +1000 | [diff] [blame] | 5 | |
Kevin Burke | f9586dc | 2017-07-18 20:10:49 -0700 | [diff] [blame] | 6 | ## Report Issues / Send Patches |
| 7 | |
Brad Fitzpatrick | 623b576 | 2017-07-26 18:23:57 +0000 | [diff] [blame] | 8 | This repository uses Gerrit for code changes. To contribute, see |
| 9 | https://golang.org/doc/contribute.html. |
Kevin Burke | f9586dc | 2017-07-18 20:10:49 -0700 | [diff] [blame] | 10 | |
| 11 | The main issue tracker for the blog is located at |
Brad Fitzpatrick | 623b576 | 2017-07-26 18:23:57 +0000 | [diff] [blame] | 12 | https://github.com/golang/go/issues. Prefix your issue with |
| 13 | "`x/build/DIR: `" in the subject line. |
Kevin Burke | f9586dc | 2017-07-18 20:10:49 -0700 | [diff] [blame] | 14 | |
Brad Fitzpatrick | 623b576 | 2017-07-26 18:23:57 +0000 | [diff] [blame] | 15 | ## Overview |
| 16 | |
| 17 | The main components of the Go build system are: |
Kevin Burke | f9586dc | 2017-07-18 20:10:49 -0700 | [diff] [blame] | 18 | |
Brad Fitzpatrick | 2c0b188 | 2017-07-26 19:45:04 +0000 | [diff] [blame] | 19 | * The **dashboard**, in [app/](https://dev.golang.org/dir/build/app), serves |
| 20 | https://build.golang.org/. It runs on App Engine and holds the state for |
| 21 | which builds passed or failed, and stores the build failure logs for |
| 22 | post-submit failures. (Trybot build failure logs are stored elsewhere). |
| 23 | The dashboard does not execute any builds on its own. |
Brad Fitzpatrick | 49f2395 | 2017-04-12 01:32:46 +0000 | [diff] [blame] | 24 | |
Brad Fitzpatrick | 4821e1d | 2015-01-14 17:24:45 -0800 | [diff] [blame] | 25 | |
Brad Fitzpatrick | 2c0b188 | 2017-07-26 19:45:04 +0000 | [diff] [blame] | 26 | * The **coordinator**, in |
| 27 | [cmd/coordinator/](https://dev.golang.org/dir/build/cmd/coordinator/), |
| 28 | serves https://farmer.golang.org/. It runs on GKE and coordinates the |
| 29 | whole build system. It finds work to do (both pre-submit "TryBot" work, |
| 30 | and post-submit work) and executes builds, allocating machines to run the |
| 31 | builds. It is the owner of all machines. |
Brad Fitzpatrick | 4821e1d | 2015-01-14 17:24:45 -0800 | [diff] [blame] | 32 | |
Brad Fitzpatrick | 2c0b188 | 2017-07-26 19:45:04 +0000 | [diff] [blame] | 33 | * The Go package in [buildenv/](https://dev.golang.org/dir/build/buildenv/) |
| 34 | contains constants for where the dashboard and coordinator run, for prod, |
| 35 | staging, and local development. |
Brad Fitzpatrick | 4821e1d | 2015-01-14 17:24:45 -0800 | [diff] [blame] | 36 | |
Brad Fitzpatrick | 2c0b188 | 2017-07-26 19:45:04 +0000 | [diff] [blame] | 37 | * The **buildlet**, in |
| 38 | [cmd/buildlet/](https://dev.golang.org/dir/build/cmd/buildlet/), is the |
| 39 | HTTP server that runs on each worker machine to execute builds on the |
| 40 | coordinator's behalf. This runs on every possible GOOS/GOARCH value. The |
| 41 | buildlet binaries are stored on Google Cloud Storage and fetched |
| 42 | per-build, so we can update the buildlet binary independently of the |
| 43 | underlying machine images. The buildlet is the most insecure server |
| 44 | possible: it has HTTP handlers to read & write arbitrary content to disk, |
| 45 | and to execute any file on disk. It also has an SSH tunnel handler. The |
| 46 | buildlet must never be exposed to the Internet. The coordinator provisions |
| 47 | buildlets in one of three ways: |
Brad Fitzpatrick | 4821e1d | 2015-01-14 17:24:45 -0800 | [diff] [blame] | 48 | |
Brad Fitzpatrick | 2c0b188 | 2017-07-26 19:45:04 +0000 | [diff] [blame] | 49 | 1. by creating VMs on Google Compute Engine (GCE) with custom images |
| 50 | configured to fetch & run the buildlet on boot, listening on port 80 in a |
| 51 | private network. |
| 52 | |
Brad Fitzpatrick | 6ae8750 | 2018-05-04 02:42:17 +0000 | [diff] [blame] | 53 | 2. by running Linux containers (on either Google Kubernetes Engine |
| 54 | or GCE with the Container-Optimized OS image), with the container |
| 55 | images configured to fetch & run the buildlet on start, also |
| 56 | listening on port 80 in a private network. |
Brad Fitzpatrick | 4821e1d | 2015-01-14 17:24:45 -0800 | [diff] [blame] | 57 | |
Brad Fitzpatrick | 2c0b188 | 2017-07-26 19:45:04 +0000 | [diff] [blame] | 58 | 3. by taking buildlets out of a pool of connected, dedicated machines. The |
| 59 | buildlet can run in either *listen mode* (as on GCE and GKE) or in |
| 60 | *reverse mode*. In reverse mode, the buildlet connects out to |
| 61 | https://farmer.golang.org/ and registers itself with the coordinator. The |
| 62 | TCP connection is then logically reversed (using |
| 63 | [revdial](https://dev.golang.org/dir/build/revdial/) and when the |
| 64 | coordinator needs to do a build, it makes HTTP requests to the coordinator |
| 65 | over the already-open TCP connection. |
Brad Fitzpatrick | 4821e1d | 2015-01-14 17:24:45 -0800 | [diff] [blame] | 66 | |
Brad Fitzpatrick | 2c0b188 | 2017-07-26 19:45:04 +0000 | [diff] [blame] | 67 | These three pools can be viewed at the coordinator's |
| 68 | http://farmer.golang.org/#pools |
Brad Fitzpatrick | 4821e1d | 2015-01-14 17:24:45 -0800 | [diff] [blame] | 69 | |
Brad Fitzpatrick | 49f2395 | 2017-04-12 01:32:46 +0000 | [diff] [blame] | 70 | |
Brad Fitzpatrick | 2c0b188 | 2017-07-26 19:45:04 +0000 | [diff] [blame] | 71 | * The [env/](https://dev.golang.org/dir/build/env/) directory describes |
| 72 | build environments. It contains scripts to create VM images, Dockerfiles |
| 73 | to create Kubernetes containers, and instructions and tools for dedicated |
| 74 | machines. |
Brad Fitzpatrick | 4821e1d | 2015-01-14 17:24:45 -0800 | [diff] [blame] | 75 | |
Brad Fitzpatrick | 4821e1d | 2015-01-14 17:24:45 -0800 | [diff] [blame] | 76 | |
Brad Fitzpatrick | 2c0b188 | 2017-07-26 19:45:04 +0000 | [diff] [blame] | 77 | * **maintner** in [maintner/](https://dev.golang.org/dir/build/maintner) is |
| 78 | a library for slurping all of Go's GitHub and Gerrit state into memory. |
| 79 | The daemon **maintnerd** in |
| 80 | [maintner/maintnerd/](https://dev.golang.org/dir/build/maintner/maintnerd) |
| 81 | runs on GKE and serves https://maintner.golang.org/. The daemon watches |
| 82 | GitHub and Gerrit and apps to a mutation log whenever it sees new |
| 83 | activity. The logs are stored on GCS and served to clients. |
| 84 | |
| 85 | |
| 86 | * The [godata package](https://godoc.org/golang.org/x/build/maintner/godata) |
| 87 | in [maintner/godata/](https://dev.golang.org/dir/build/maintner/godata) |
| 88 | provides a trivial API to let anybody write programs against |
| 89 | Go's maintner corpus (all of our GitHub and Gerrit history), live up |
| 90 | to the second. It takes a few seconds to load into memory and a few hundred |
| 91 | MB of RAM after it downloads the mutation log from the network. |
| 92 | |
| 93 | |
| 94 | * **pubsubhelper** in |
| 95 | [cmd/pubsubhelper/](https://dev.golang.org/dir/build/cmd/pubsubhelper/) is |
Brad Fitzpatrick | 4bd7ff5 | 2017-07-26 19:54:01 +0000 | [diff] [blame] | 96 | a dependency of maintnerd. It runs on GKE, is available at |
| 97 | https://pubsubhelper.golang.org/, and runs an HTTP server to receive |
| 98 | Webhook updates from GitHub on new activity and an SMTP server to receive |
| 99 | new activity emails from Gerrit. It then is a pubsub system for maintnerd |
| 100 | to subscribe to. |
Brad Fitzpatrick | 2c0b188 | 2017-07-26 19:45:04 +0000 | [diff] [blame] | 101 | |
| 102 | |
| 103 | * The **gitmirror** server in |
| 104 | [cmd/gitmirror/](https://dev.golang.org/dir/build/cmd/gitmirror) mirrors |
| 105 | Gerrit to GitHub, and also serves a mirror of the Gerrit code to the |
| 106 | coordinator for builds, so we don't overwhelm Gerrit and blow our quota. |
| 107 | |
| 108 | |
| 109 | * The Go **gopherbot** bot logic runs on GKE. The code is in |
| 110 | [cmd/gopherbot](https://dev.golang.org/dir/build/cmd/gopherbot). It |
| 111 | depends on maintner via the godata package. |
| 112 | |
| 113 | |
| 114 | * The **developer dashboard** at https://dev.golang.org/ runs on GKE. |
| 115 | Its code is in [devapp/](https://dev.golang.org/dir/build/devapp/). |
| 116 | It also depends on maintner via the godata package. |
| 117 | |
| 118 | |
| 119 | * **cmd/retrybuilds**: a Go client program to delete build results from the |
| 120 | dashboard |
| 121 | |
Brad Fitzpatrick | 4821e1d | 2015-01-14 17:24:45 -0800 | [diff] [blame] | 122 | |
Kevin Burke | f9586dc | 2017-07-18 20:10:49 -0700 | [diff] [blame] | 123 | ### Adding a Go Builder |
Chris Manghane | 7d85ae4 | 2013-08-01 13:23:51 +1000 | [diff] [blame] | 124 | |
Kevin Burke | f9586dc | 2017-07-18 20:10:49 -0700 | [diff] [blame] | 125 | If you wish to run a Go builder, please email |
| 126 | [golang-dev@googlegroups.com](mailto:golang-dev@googlegroups.com) first. There |
| 127 | is documentation at https://golang.org/wiki/DashboardBuilders, but depending |
| 128 | on the type of builder, we may want to run it ourselves, after you prepare an |
| 129 | environment description (resulting in a VM image) of it. See the env directory. |
Brad Fitzpatrick | 623b576 | 2017-07-26 18:23:57 +0000 | [diff] [blame] | 130 | |