Import gazelle

This patch imports gazelle as a linter. It automatically generates
BUILD file entries for Go code and at the same time keeps BUILD files
formatted.

The `tools/lint:run-ci` target is set up to automatically add new Go
repositories as well.

I added a tool at `//tools/go:mirror_go_repos` that needs to be run
before anyone can merge code that uses third-party Go libraries.

Change-Id: I1fbf6761439d45893f5be88d294ccc3c567840ca
Signed-off-by: Philipp Schrader <philipp.schrader@gmail.com>
diff --git a/tools/ci/repo_defs.bzl b/tools/ci/repo_defs.bzl
new file mode 100644
index 0000000..b490f79
--- /dev/null
+++ b/tools/ci/repo_defs.bzl
@@ -0,0 +1,19 @@
+def _ci_configure_impl(repository_ctx):
+    """This repository rule tells other rules whether we're running in CI.
+
+    Other rules can use this knowledge to make decisions about enforcing certain
+    things on buildkite while relaxing restrictions during local development.
+    """
+    running_in_ci = repository_ctx.os.environ.get("FRC971_RUNNING_IN_CI", "0") == "1"
+    repository_ctx.file("ci.bzl", """\
+RUNNING_IN_CI = {}
+""".format(running_in_ci))
+    repository_ctx.file("BUILD", "")
+
+ci_configure = repository_rule(
+    implementation = _ci_configure_impl,
+    environ = [
+        # This is set in CI via tools/ci/buildkite.yaml.
+        "FRC971_RUNNING_IN_CI",
+    ],
+)