From 96b7eafd8ede10165e9d74d02cbfbc29576c0211 Mon Sep 17 00:00:00 2001 From: Allan Clark Date: Sun, 5 Nov 2023 00:23:49 -0700 Subject: [PATCH] feat: confirm 1.6 and 1.7 artifacts naming scheme co-exist --- WORKSPACE | 4 ++-- example/genrule/BUILD.bazel | 2 +- full-examples/basic-1.6/BUILD.bazel | 25 +++++++++++++++++++++++++ full-examples/basic-1.6/WORKSPACE | 27 +++++++++++++++++++++++++++ full-examples/basic-1.6/sample.yaml | 1 + full-examples/basic/WORKSPACE | 2 +- jq/private/toolchains_repo.bzl | 8 ++++++++ 7 files changed, 65 insertions(+), 4 deletions(-) create mode 100644 full-examples/basic-1.6/BUILD.bazel create mode 100644 full-examples/basic-1.6/WORKSPACE create mode 100644 full-examples/basic-1.6/sample.yaml diff --git a/WORKSPACE b/WORKSPACE index f7cd77c..85f16f8 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -15,8 +15,8 @@ load("//jq:repositories.bzl", "jq_register_toolchains", "rules_jq_dependencies") rules_jq_dependencies() jq_register_toolchains( - name = "jq1_6", - jq_version = "1.6", + name = "jq", + jq_version = "1.7", ) load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") diff --git a/example/genrule/BUILD.bazel b/example/genrule/BUILD.bazel index e53fce6..6d0bece 100644 --- a/example/genrule/BUILD.bazel +++ b/example/genrule/BUILD.bazel @@ -5,7 +5,7 @@ genrule( name = "actual", outs = ["actual.yaml"], cmd = "$(JQ_BIN) '.one = 1' --null-input --compact-output > $@", - toolchains = ["@jq1_6_toolchains//:resolved_toolchain"], + toolchains = ["@jq_toolchains//:resolved_toolchain"], ) write_file( diff --git a/full-examples/basic-1.6/BUILD.bazel b/full-examples/basic-1.6/BUILD.bazel new file mode 100644 index 0000000..d8af603 --- /dev/null +++ b/full-examples/basic-1.6/BUILD.bazel @@ -0,0 +1,25 @@ +load("@bazel_skylib//rules:diff_test.bzl", "diff_test") +load("@bazel_skylib//rules:write_file.bzl", "write_file") +load("@rules_jq//jq:defs.bzl", "jq_eval") + +jq_eval( + name = "actual", + srcs = ["sample.yaml"], + filter = ".a.b", + raw_output = True, +) + +write_file( + name = "expected", + out = "out.yaml", + content = [ + "123", + "", + ], +) + +diff_test( + name = "check_eval", + file1 = ":expected", + file2 = ":actual", +) diff --git a/full-examples/basic-1.6/WORKSPACE b/full-examples/basic-1.6/WORKSPACE new file mode 100644 index 0000000..7ddfe8e --- /dev/null +++ b/full-examples/basic-1.6/WORKSPACE @@ -0,0 +1,27 @@ +workspace(name = "basic-1.6") + +# When using in your project, this can be a direct cut-n-paste, however you should replace the +# local_repository with a http_archive() block similar to the following, using the version and +# sha256 matching your desired release +# +# load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +# +# http_archive( +# name = "rules_jq", +# sha256 = "52771b5f7fb5017b0f5a3816b46624d2b9a336ddc178b261de988d969cd329d8", +# url = "https://github.com/jqlang/bazel_rules_jq/releases/download/0.0.1/bazel_rules_jq-v0.0.1.tar.gz", +#) + +local_repository( + name = "rules_jq", + path = "../..", +) + +load("@rules_jq//jq:repositories.bzl", "jq_register_toolchains", "rules_jq_dependencies") + +rules_jq_dependencies() + +jq_register_toolchains( + name = "jq", + jq_version = "1.6", +) diff --git a/full-examples/basic-1.6/sample.yaml b/full-examples/basic-1.6/sample.yaml new file mode 100644 index 0000000..f53823a --- /dev/null +++ b/full-examples/basic-1.6/sample.yaml @@ -0,0 +1 @@ +{ "a": { "b": "123" } } diff --git a/full-examples/basic/WORKSPACE b/full-examples/basic/WORKSPACE index 6c75f91..9266cc6 100644 --- a/full-examples/basic/WORKSPACE +++ b/full-examples/basic/WORKSPACE @@ -23,5 +23,5 @@ rules_jq_dependencies() jq_register_toolchains( name = "jq", - jq_version = "1.6", + jq_version = "1.7", ) diff --git a/jq/private/toolchains_repo.bzl b/jq/private/toolchains_repo.bzl index 52fea58..c274342 100644 --- a/jq/private/toolchains_repo.bzl +++ b/jq/private/toolchains_repo.bzl @@ -20,12 +20,20 @@ with only the toolchain attribute pointing into the platform-specific repositori # Add more platforms as needed to mirror all the binaries # published by the upstream project. PLATFORMS = { + # This artifact exists in pre-1.7 and post-1.6; JQ may drop the osx- moniker but until then, we + # don't need to do any tricky logic "osx-amd64": struct( compatible_with = [ "@platforms//os:macos", "@platforms//cpu:x86_64", ], ), + "macos-arm64": struct( + compatible_with = [ + "@platforms//os:macos", + "@platforms//cpu:aarch64", + ], + ), "linux64": struct( compatible_with = [ "@platforms//os:linux",