-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure go versions are synced between MODULE.bazel and go.mod.
- Loading branch information
Showing
14 changed files
with
409 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
load("//bzl:rules.bzl", "bazel_lint") | ||
|
||
exports_files( | ||
["binary_with_args.sh"], | ||
visibility = ["//:__subpackages__"], | ||
) | ||
|
||
bazel_lint( | ||
name = "bazel_lint", | ||
srcs = [ | ||
"BUILD.bazel", | ||
"binary_with_args.bzl", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
def binary_with_args(name, binary, args, data = [], **kwargs): | ||
native.sh_binary( | ||
name = name, | ||
srcs = ["//bzl/binary_with_args:binary_with_args.sh"], | ||
data = [ | ||
binary, | ||
] + data, | ||
args = [ | ||
"$(rlocationpath " + binary + ")", | ||
] + args, | ||
deps = [ | ||
"@bazel_tools//tools/bash/runfiles", | ||
], | ||
**kwargs | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
|
||
# --- begin runfiles.bash initialization v3 --- | ||
# Copy-pasted from the Bazel Bash runfiles library v3. | ||
set -uo pipefail; set +e; f=bazel_tools/tools/bash/runfiles/runfiles.bash | ||
# shellcheck disable=SC1090 | ||
source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ | ||
source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \ | ||
source "$0.runfiles/$f" 2>/dev/null || \ | ||
source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ | ||
source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ | ||
{ echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e | ||
# --- end runfiles.bash initialization v3 --- | ||
|
||
BINARY="$(rlocation $1)" | ||
shift | ||
|
||
$BINARY $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
load("@aspect_bazel_lib//lib:diff_test.bzl", "diff_test") | ||
load("//py/copy_to_workspace:copy_to_workspace.bzl", "copy_to_workspace") | ||
|
||
def golden_test( | ||
name, | ||
src, | ||
golden, # must be a file in this package. | ||
**kwargs): | ||
diff_test( | ||
name = name, | ||
file1 = src, | ||
file2 = golden, | ||
**kwargs | ||
) | ||
|
||
package = native.package_name() | ||
|
||
if package != "": | ||
package += "/" | ||
|
||
copy_to_workspace( | ||
name = name + ".fix", | ||
src = golden, | ||
dst = package + src, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
load("//bzl:golden_test.bzl", "golden_test") | ||
|
||
|
||
def go_version_sync(name): | ||
native.genrule( | ||
name = name + "_gen_goldens", | ||
tools = [ | ||
"//go/cmd/version_sync" | ||
], | ||
cmd_bash = """ | ||
$(execpath //go/cmd/version_sync) \\ | ||
-go-mod $(rootpath go.mod) \\ | ||
-module-bazel $(rootpath MODULE.bazel) \\ | ||
-output-go-mod $(location go.mod.golden) \\ | ||
-output-module-bazel $(location MODULE.bazel.golden) \\ | ||
-fix | ||
""", | ||
srcs = [ | ||
"MODULE.bazel", | ||
"go.mod" | ||
], | ||
outs = ["go.mod.golden", "MODULE.bazel.golden"], | ||
) | ||
|
||
golden_test( | ||
name = name + "_go_mod_test", | ||
src = "go.mod", | ||
golden = "go.mod.golden" | ||
) | ||
|
||
golden_test( | ||
name = name + "_bazel_mod_test", | ||
src = "MODULE.bazel", | ||
golden = "MODULE.bazel.golden" | ||
) | ||
|
||
native.test_suite( | ||
name = name, | ||
tests = [ | ||
name + "_go_mod_test", | ||
name + "_bazel_mod_test" | ||
] | ||
) |
Oops, something went wrong.