Upgrade rules_go and gazelle
I want to use the new runfiles library that comes in rules_go.
Signed-off-by: Philipp Schrader <philipp.schrader@gmail.com>
Change-Id: I7c301ead2642fb2f172ad5a10824165a58d2d053
diff --git a/WORKSPACE b/WORKSPACE
index 6ef37e6..dd184d5 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -18,13 +18,17 @@
http_archive(
name = "bazel_skylib",
- sha256 = "1c531376ac7e5a180e0237938a2536de0c54d93f5c278634818e0efc952dd56c",
+ sha256 = "b8a1527901774180afc798aeb28c4634bdccf19c4d98e7bdd1ce79d1fe9aaad7",
urls = [
- "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz",
- "https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz",
+ "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.4.1/bazel-skylib-1.4.1.tar.gz",
+ "https://github.com/bazelbuild/bazel-skylib/releases/download/1.4.1/bazel-skylib-1.4.1.tar.gz",
],
)
+load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
+
+bazel_skylib_workspace()
+
http_archive(
name = "aspect_bazel_lib",
sha256 = "80897b673c2b506d21f861ae316689aa8abcc3e56947580a41bf9e68ff13af58",
@@ -1297,19 +1301,25 @@
patches = [
"@//third_party:rules_go/0001-Disable-warnings-for-external-repositories.patch",
],
- sha256 = "2b1641428dff9018f9e85c0384f03ec6c10660d935b750e3fa1492a281a53b0f",
+ sha256 = "dd926a88a564a9246713a9c00b35315f54cbd46b31a26d5d8fb264c07045f05d",
urls = [
- "https://www.frc971.org/Build-Dependencies/rules_go-v0.29.0.zip",
- "https://github.com/bazelbuild/rules_go/releases/download/v0.29.0/rules_go-v0.29.0.zip",
+ "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.38.1/rules_go-v0.38.1.zip",
+ "https://github.com/bazelbuild/rules_go/releases/download/v0.38.1/rules_go-v0.38.1.zip",
],
)
http_archive(
name = "bazel_gazelle",
- sha256 = "de69a09dc70417580aabf20a28619bb3ef60d038470c7cf8442fafcf627c21cb",
+ patch_args = [
+ "-p1",
+ ],
+ patches = [
+ "@//third_party:bazel-gazelle/0001-Fix-visibility-of-gazelle-runner.patch",
+ ],
+ sha256 = "ecba0f04f96b4960a5b250c8e8eeec42281035970aa8852dda73098274d14a1d",
urls = [
- "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.0.tar.gz",
- "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.0.tar.gz",
+ "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.29.0/bazel-gazelle-v0.29.0.tar.gz",
+ "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.29.0/bazel-gazelle-v0.29.0.tar.gz",
],
)
@@ -1317,7 +1327,7 @@
go_rules_dependencies()
-go_register_toolchains(version = "1.18")
+go_register_toolchains(version = "1.19.5")
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
load("//:go_deps.bzl", "go_dependencies")
diff --git a/scouting/scraping/scrape.go b/scouting/scraping/scrape.go
index b905465..9cb2336 100644
--- a/scouting/scraping/scrape.go
+++ b/scouting/scraping/scrape.go
@@ -23,9 +23,10 @@
// Also takes in a file path to the JSON config file that contains your TBA API key.
// It defaults to <workspace root>/config.json
// the config is expected to have the following contents:
-//{
-// api_key:"myTBAapiKey"
-//}
+//
+// {
+// api_key:"myTBAapiKey"
+// }
func getJson(year int32, eventCode, configPath, category string) ([]byte, error) {
if configPath == "" {
configPath = os.Getenv("BUILD_WORKSPACE_DIRECTORY") + "/scouting_config.json"
diff --git a/scouting/webserver/requests/requests.go b/scouting/webserver/requests/requests.go
index c59e7c5..bf24140 100644
--- a/scouting/webserver/requests/requests.go
+++ b/scouting/webserver/requests/requests.go
@@ -119,7 +119,7 @@
// Parses the authorization information that the browser inserts into the
// headers. The authorization follows this format:
//
-// req.Headers["Authorization"] = []string{"Basic <base64 encoded username:password>"}
+// req.Headers["Authorization"] = []string{"Basic <base64 encoded username:password>"}
func parseUsername(req *http.Request) string {
auth, ok := req.Header["Authorization"]
if !ok {
diff --git a/third_party/bazel-gazelle/0001-Fix-visibility-of-gazelle-runner.patch b/third_party/bazel-gazelle/0001-Fix-visibility-of-gazelle-runner.patch
new file mode 100644
index 0000000..2e460e4
--- /dev/null
+++ b/third_party/bazel-gazelle/0001-Fix-visibility-of-gazelle-runner.patch
@@ -0,0 +1,21 @@
+From 1b0b864a6900beeee83cadfcb596381ceb443b86 Mon Sep 17 00:00:00 2001
+From: Philipp Schrader <philipp.schrader@gmail.com>
+Date: Sun, 5 Mar 2023 13:51:11 -0800
+Subject: [PATCH] Fix visibility of gazelle-runner
+
+---
+ def.bzl | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/def.bzl b/def.bzl
+index c4d3c71..ce9a6f2 100644
+--- a/def.bzl
++++ b/def.bzl
+@@ -145,6 +145,7 @@ def gazelle(name, **kwargs):
+ _gazelle_runner(
+ name = runner_name,
+ tags = tags,
++ visibility = visibility,
+ **kwargs
+ )
+ native.sh_binary(
diff --git a/tools/dependency_rewrite b/tools/dependency_rewrite
index 23e5d14..7e9e1de 100644
--- a/tools/dependency_rewrite
+++ b/tools/dependency_rewrite
@@ -16,7 +16,7 @@
rewrite cdn.cypress.io/(.*) software.frc971.org/Build-Dependencies/cdn.cypress.io/$1
rewrite www.googleapis.com/(.*) software.frc971.org/Build-Dependencies/www.googleapis.com/$1
allow crates.io
-allow golang.org
+allow go.dev
allow registry.npmjs.org
allow software.frc971.org
diff --git a/tools/go/go_mirrors.bzl b/tools/go/go_mirrors.bzl
index 338cc95..7a8055a 100644
--- a/tools/go/go_mirrors.bzl
+++ b/tools/go/go_mirrors.bzl
@@ -17,6 +17,12 @@
"com_github_buildkite_go_buildkite": {
"filename": "com_github_buildkite_go_buildkite__v2.2.0+incompatible.zip",
"importpath": "github.com/buildkite/go-buildkite",
+ "kwargs": {
+ "build_directives": [
+ "gazelle:resolve go github.com/cenkalti/backoff @com_github_cenkalti_backoff//:go_default_library",
+ "gazelle:resolve go github.com/google/go-querystring/query @com_github_google_go_querystring//query:go_default_library",
+ ],
+ },
"sha256": "1871115c8c6db004e4b6e57cee927043bfc9ea0c56e7b8f8336021bd8bf588c4",
"strip_prefix": "github.com/buildkite/go-buildkite@v2.2.0+incompatible",
"version": "v2.2.0+incompatible",
diff --git a/tools/go/mirror_go_repos.py b/tools/go/mirror_go_repos.py
index 52d611f..a7cfe08 100644
--- a/tools/go/mirror_go_repos.py
+++ b/tools/go/mirror_go_repos.py
@@ -53,6 +53,7 @@
print(f"Downloading file for {repo['name']}")
importpath = repo["importpath"]
version = repo["version"]
+ repo_kwargs = repo.get("kwargs")
module = f"{importpath}@{version}"
download_result = subprocess.run(
@@ -84,6 +85,8 @@
"version": version,
"importpath": importpath,
}
+ if repo_kwargs:
+ cached_info[name]["kwargs"] = repo_kwargs
return cached_info
diff --git a/tools/go/mirrored_go_deps.bzl b/tools/go/mirrored_go_deps.bzl
index 7839f4d..adac994 100644
--- a/tools/go/mirrored_go_deps.bzl
+++ b/tools/go/mirrored_go_deps.bzl
@@ -2,7 +2,7 @@
load("@bazel_gazelle//:deps.bzl", "go_repository")
load("@ci_configure//:ci.bzl", "RUNNING_IN_CI")
-def maybe_override_go_dep(name, importpath, sum, version):
+def maybe_override_go_dep(name, importpath, sum, version, **kwargs):
"""This macro selects between our dependency mirrors and upstream sources.
We want to use the mirrored version whenever possible. In CI we are required
@@ -28,12 +28,14 @@
importpath = importpath,
sum = sum,
version = version,
+ **kwargs
)
def mirrored_go_dependencies():
"""Sets up the Go dependencies we've mirrored."""
for name in GO_MIRROR_INFO:
info = GO_MIRROR_INFO[name]
+ kwargs = info.get("kwargs", {})
go_repository(
name = name,
strip_prefix = info["strip_prefix"],
@@ -43,4 +45,5 @@
],
sha256 = info["sha256"],
importpath = info["importpath"],
+ **kwargs
)