-
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.
feat: show a tested full end-to-end example
- Loading branch information
1 parent
fe98db2
commit 0927e66
Showing
17 changed files
with
137 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# see "Ignored" section in full-examples/README.md | ||
full-examples |
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
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
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
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 |
---|---|---|
@@ -1,5 +1 @@ | ||
{ | ||
"a": { | ||
"b": "123" | ||
} | ||
} | ||
{ "a": { "b": "123" } } |
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,27 @@ | ||
## Full Examples | ||
|
||
These examples are intended to show more completely how to use the `jq` rules: rather than just | ||
snippets of untested code that may bitrot over time, these examples are tested on each PR, and are | ||
nearly identical to what a consumer of the rules would use -- except that the local_repository() | ||
rule should be replaced with a http_archive() rule as documented in WORKSPACE (and MODULE.bazel if | ||
appropriate) | ||
|
||
Sure, the actual examples are those used as validation in the "example" directory, but I intend to | ||
add to them. ...and test on every PR (at least with a linux build on the latest bazel) | ||
|
||
## Running Full Examples | ||
|
||
with reference to the changes in ci.yaml, you can run a full-example as follows: | ||
|
||
``` | ||
(cd full-examples/basic && bazel build //...) | ||
``` | ||
|
||
Of course, if you have an HTTP cache or federated bazel cache, you can reuse the work done in a | ||
build at the root workspace. | ||
|
||
## Ignored | ||
|
||
NOTE that the `full-examples` directory is ignored from a wildcard build: the `bazel-*` softlinks, | ||
and the recursive nature of the resulting tree-transversal after a build is done, becomes a really | ||
problematic endless loop. Don't remove them. |
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("@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", | ||
) |
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,27 @@ | ||
workspace(name = "basic") | ||
|
||
# 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", | ||
) |
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 @@ | ||
{ "a": { "b": "123" } } |
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