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/BUILD b/tools/ci/BUILD
new file mode 100644
index 0000000..7fa13d5
--- /dev/null
+++ b/tools/ci/BUILD
@@ -0,0 +1,17 @@
+load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
+
+go_library(
+ name = "buildkite_gerrit_trigger_lib",
+ srcs = ["buildkite_gerrit_trigger.go"],
+ importpath = "github.com/frc971/971-Robot-Code/tools/ci",
+ target_compatible_with = ["@platforms//cpu:x86_64"],
+ visibility = ["//visibility:private"],
+ deps = ["@com_github_buildkite_go_buildkite//buildkite:go_default_library"],
+)
+
+go_binary(
+ name = "buildkite_gerrit_trigger",
+ embed = [":buildkite_gerrit_trigger_lib"],
+ target_compatible_with = ["@platforms//cpu:x86_64"],
+ visibility = ["//visibility:public"],
+)
diff --git a/tools/ci/buildkite.yaml b/tools/ci/buildkite.yaml
index 55288f9..9ccb606 100644
--- a/tools/ci/buildkite.yaml
+++ b/tools/ci/buildkite.yaml
@@ -1,6 +1,6 @@
env:
STARTUP: --max_idle_secs=0 --watchfs
- COMMON: -c opt --stamp=no --curses=yes --symlink_prefix=/ --disk_cache=~/.cache/bazel/disk_cache/
+ COMMON: -c opt --stamp=no --curses=yes --symlink_prefix=/ --disk_cache=~/.cache/bazel/disk_cache/ --repo_env=FRC971_RUNNING_IN_CI=1
TARGETS: //... @com_github_google_glog//... @com_google_ceres_solver//... @com_github_rawrtc_rawrtc//... @com_google_googletest//...
M4F_TARGETS: //...
# Sanity check that we are able to build the y2020 roborio code, which confirms
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",
+ ],
+)