Skip to content

Commit

Permalink
Make it possible to set host jq via JQ env
Browse files Browse the repository at this point in the history
Also run invoke_client_jqjq with host jq
  • Loading branch information
wader committed Nov 19, 2024
1 parent 29b0f19 commit 2cc0093
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 14 deletions.
13 changes: 3 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,36 +22,29 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# does PATH tricks so that jq that runs invoke_client_jqjq is same jq
- run: |
curl -sOLJ 'https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-amd64'
mv jq-linux-amd64 jq
chmod a+x jq
PATH="$PWD:$PATH" make test-jqjq JQ=jq
PATH="$PWD:$PATH" JQ=jq make test-jqjq
test-jqjq-gojq:
name: Run tests with jqjq using gojq
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: |
curl -sOLJ 'https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-amd64'
mv jq-linux-amd64 jq
chmod a+x jq
curl -Ls 'https://github.com/itchyny/gojq/releases/download/v0.12.16/gojq_v0.12.16_linux_amd64.tar.gz' | tar xz
mv gojq*/gojq gojq
PATH="$PWD:$PATH" make test-jqjq JQ=gojq
PATH="$PWD:$PATH" JQ=gojq make test-jqjq
test-jqjq-jaq:
name: Run tests with jqjq using jaq
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: |
curl -sOLJ 'https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-amd64'
mv jq-linux-amd64 jq
chmod a+x jq
curl -sOLJ 'https://github.com/01mf02/jaq/releases/download/v2.0.0-epsilon/jaq-x86_64-unknown-linux-gnu'
mv jaq-x86_64-unknown-linux-gnu jaq
chmod a+x jaq
PATH="$PWD:$PATH" make test-jqjq JQ=jaq
PATH="$PWD:$PATH" JQ=jaq make test-jqjq
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
JQ=jq
JQ ?= jq

test: test-jq test-jqjq

Expand All @@ -8,4 +8,4 @@ test-jq:

.PHONY: test-jqjq
test-jqjq:
./jqjq --jq "${JQ}" --run-tests < jqjq.test
./jqjq --run-tests < jqjq.test
2 changes: 1 addition & 1 deletion jqjq
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
eval "$(
jq \
"${JQ:=jq}" \
-nr \
-L "$(dirname "$(realpath "${BASH_SOURCE[0]}")")" \
'include "jqjq"; $ARGS.positional | invoke_client_jqjq' \
Expand Down
2 changes: 1 addition & 1 deletion jqjq.jq
Original file line number Diff line number Diff line change
Expand Up @@ -2832,7 +2832,7 @@ def invoke_client_jqjq:
end;
( . as $args
| parse_options
| [ (.jq // "jq" | sh_escape)
| [ (.jq // env.JQ // "jq" | sh_escape)
, if .action == "run-tests" then "-nsRr"
elif .mode == "repl" then "-njR"
else "-nj"
Expand Down

0 comments on commit 2cc0093

Please sign in to comment.