Skip to content

Commit

Permalink
feat: confirm 1.6 and 1.7 artifacts naming scheme co-exist
Browse files Browse the repository at this point in the history
  • Loading branch information
chickenandpork authored and nicowilliams committed Nov 6, 2023
1 parent e3cbb5b commit fb5b14d
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 4 deletions.
4 changes: 2 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion example/genrule/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
25 changes: 25 additions & 0 deletions full-examples/basic-1.6/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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",
)
27 changes: 27 additions & 0 deletions full-examples/basic-1.6/WORKSPACE
Original file line number Diff line number Diff line change
@@ -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",
)
1 change: 1 addition & 0 deletions full-examples/basic-1.6/sample.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "a": { "b": "123" } }
2 changes: 1 addition & 1 deletion full-examples/basic/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ rules_jq_dependencies()

jq_register_toolchains(
name = "jq",
jq_version = "1.6",
jq_version = "1.7",
)
8 changes: 8 additions & 0 deletions jq/private/toolchains_repo.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit fb5b14d

Please sign in to comment.