555 Commits

Author SHA1 Message Date
John Bartholomew
10aef6a96c chore: add test cases for std.manifestYamlDoc error reporting 2025-06-19 15:46:07 +01:00
Rudo Thomas
80c7c4ad72 fix: Unchecked error in std.manifestYamlDoc().
Problem: A recursive call within manifestYamlDoc() might fail but the
return value is not checked.

Reproducible with:
```
$ jsonnet-2f73f61 -e "std.manifestYamlDoc({ x: { y: error 'foo' } }, quote_keys=false)"
"x:\n  "
```

Expected:
```
$ jsonnet-0.20.0 -e "std.manifestYamlDoc({ x: { y: error 'foo' } }, quote_keys=false)"
RUNTIME ERROR: foo
	<cmdline>:1:31-42	object <anonymous>
	...
```
2025-06-19 13:46:03 +01:00
John Bartholomew
bfa727258b doc: add an explanatory sentence in the REAMDE about WASM
fixes #774
2025-05-08 13:17:05 +01:00
John Bartholomew
0ea744d3dd chore: fix references to Go version in the README 2025-05-08 13:16:29 +01:00
John Bartholomew
67968688d9 release: prepare to release v0.21.0 v0.21.0 2025-05-07 16:12:02 +01:00
John Bartholomew
d670d5fb87 chore: fix release action to avoid creating two releases 2025-05-07 16:12:02 +01:00
Kohei Suzuki
2f73f6148f Remove dependency on cpp-jsonnet submodule from C bindings
This change allows us to build libgojsonnet from tarball downloaded from
GitHub releases.
2025-03-31 11:25:18 +01:00
Rudo Thomas
1c79f577ba fix: Fix error messages when a comprehension iterates over a non-array.
Problems:
 - When iterating over an empty string in a list comprehension, the
   result is an empty string. This is a bug, it should be an error.
 - When iterating over a non-empty string in a list comprehension, the
   expected and unexpected types in the error message are swapped.
 - Error messages mention "std.flatMap" when object/list comprehensions
   would iterate over a value that is neither array nor string.

```
$ jsonnet --version
Jsonnet commandline interpreter (Go implementation) v0.21.0-rc2
$ jsonnet -e '[a for a in ""]'
""
$ jsonnet -e '[a for a in "b"]'
RUNTIME ERROR: Unexpected type array, expected string
	<cmdline>:1:1-17
	During evaluation
$ jsonnet -e '{[a]: 1 for a in 2}'
RUNTIME ERROR: std.flatMap second param must be array / string, got number
	<cmdline>:1:1-20
	<cmdline>:1:1-20
	During evaluation
$ jsonnet -e '[a for a in 1]'
RUNTIME ERROR: std.flatMap second param must be array / string, got number
	<cmdline>:1:1-15
	During evaluation
```

FWIW, the C++ implementation does not have any of these problems. It
gives:
```
RUNTIME ERROR: In comprehension, can only iterate over array.
```

In the Go implementation comprehensions are desugared to a call to
std.flatMap which does accept a string in the "arr" parameter.

The fix: Desugar comprehensions to a call to a new hidden builtin which
only accepts arrays.
2025-03-21 16:37:59 +00:00
John Bartholomew
1add1e1b24 ci: check that the example using a bazel module builds 2025-03-16 16:43:03 +00:00
John Bartholomew
fb07a24f45 feat: add an example bazel module + go binary using the library
This is mostly so that I can add it as the test module to be used
in the bazel registry presubmit
2025-03-16 16:10:31 +00:00
John Bartholomew
2a263bf47f fix: passing name= to go_sdk.download() breaks use of the bazel module 2025-03-16 16:03:35 +00:00
John Bartholomew
9cd0cd006c ci: create a stable source archive attached to the release 2025-03-13 00:42:33 +00:00
John Bartholomew
2a3f4afd6a release: prepare to release v0.21.0-rc2 v0.21.0-rc2 2025-03-12 23:42:07 +00:00
Andrea Scarpino
fe1d35d61e Fix compatibility with setuptools 72 2025-03-12 23:29:18 +00:00
John Bartholomew
7a714b9bf5 ci: build gojsonnet wheels on Mac OS
Use the GitHub setup-go action to install Go, as it is not in the
Mac OS runner images by default.

I tried but failed to get a Windows wheel build working, so that
remains disabled for now.
2025-03-12 23:11:56 +00:00
John Bartholomew
b9ae88d62d chore: bazelignore the cpp-jsonnet subdirectory
Otherwise if the submodule is initialized Bazel will try to build
it when running commands like bazel test //...:all. But that doesn't
work because the cpp-jsonnet directory is not part of the same
bazel module.

Perhaps there is a better way to fix it but just ignoring the
cpp-jsonnet directory seems to be ok.
2025-03-12 20:24:46 +00:00
John Bartholomew
1f986a65f3 ci: pin bazel version to 7.5.0, and require up-to-date lockfile for CI build
Bazel 7 is currently in maintenance and supported to the end of 2026.

The CI build should require an up-to-date lockfile so that we can try
to catch before merging if Bazel dep changes are made without the
corresponding lockfile change.
2025-03-12 20:18:09 +00:00
Andrii Korotkov
bc787d68ca
chore: Switch to Go 1.23.7 and update dependencies (#794)
* chore: Update dependency versions
* Downgrade crypto to fix bazel CI
* Switch to Go 1.23.7 and update dependencies

Signed-off-by: Andrii Korotkov <andrii.korotkov@verkada.com>
2025-03-11 03:29:01 +00:00
John Bartholomew
52bb10f003 feat: add testdata coverage for minArray/maxArray onEmpty error 2025-03-11 00:45:58 +00:00
John Bartholomew
9a89560b0d feat: support onEmpty optional parameter on std.minArray,std.maxArray 2025-03-11 00:33:41 +00:00
Eduardo Sánchez Muñoz
6a15a2f3fc fix: output original value from array in std.minArray and std.maxArray instead of result of keyF 2025-03-10 23:28:39 +00:00
Mickael Carl
106c8f0c6c Use default options for formatter tests 2025-03-06 23:48:39 +00:00
Mickael Carl
6d83c91d49 Fix an out-of-bounds array access when formatting some empty comment 2025-03-06 23:48:39 +00:00
John Bartholomew
5b5bcd566a release: prepare to release v0.21.0-rc1
This updates embedded version numbers, and also updates the
C++ jsonnet dependency to the published v0.21.0-rc1 (source release).
v0.21.0-rc1
2025-02-22 23:18:43 +00:00
John Bartholomew
7b5c93866b ci: fix incorrect use of target_commitish in goreleaser release 2025-02-22 23:18:43 +00:00
John Bartholomew
06e51ba2c0 ci: grant goreleaser write permission to create releases 2025-02-22 23:05:08 +00:00
John Bartholomew
d1cde74e2c inject proposed version when running goreleaser 2025-02-22 23:02:15 +00:00
John Bartholomew
0558e35e56 chore: teach update_cpp_jsonnet.sh to pull a named release version 2025-02-22 22:07:32 +00:00
John Bartholomew
cb4d16f03e setup.py: be more verbose in the go build 2025-02-22 20:32:24 +00:00
John Bartholomew
7c36700ad7 reformat setup.py 2025-02-22 20:32:24 +00:00
John Bartholomew
3c92d79e96 ci: python cibuildwheel updates for go-jsonnet
- Checkout with submodules, otherwise the sdist won't include libjsonnet.h
- Install golang in the cibuildwheel build container.
- Skip musllinux build; it's not working for me.
- Skip Windows platform builds; they're not working for me.

It would be nice to get the other platforms working but I have already
spent hours on this and haven't succeeded yet. Previous go-jsonnet
releases on PyPI didn't have prebuilt wheel packages anyway, so it's
still strictly better to have some rather than none even if not all
platforms are covered.
2025-02-22 20:32:22 +00:00
John Bartholomew
e9ee116a7a tests: fix python compat test to allow pre-release versions 2025-02-22 17:57:53 +00:00
John Bartholomew
579361c1b5 ci: update versions of referenced github actions in ci.yml 2025-02-22 17:41:22 +00:00
John Bartholomew
e04e807f4e ci: run build-and-test on pushes to prepare-release branch 2025-02-22 17:32:12 +00:00
John Bartholomew
6f82698b7d ci: copy the publish-python.yml workflow from C++ jsonnet 2025-02-22 17:30:56 +00:00
John Bartholomew
63ffeb8875 ci: configure goreleaser to create draft GitHub releases 2025-02-22 17:30:56 +00:00
John Bartholomew
90261f34cf ci: trigger release workflow manually 2025-02-22 17:30:56 +00:00
John Bartholomew
40f0aa57e2 ci: update release workflow action references 2025-02-22 17:30:56 +00:00
John Bartholomew
6fa97cc3dc chore: update golang.org/x/crypto to v0.33.0 2025-02-21 16:32:36 +00:00
John Bartholomew
923f51b8e3 switch to go mod based goveralls in CI 2025-01-20 21:45:24 +00:00
John Bartholomew
9e1e952016 port some Python wrapper code fixes from C++ jsonnet
See commits on the C++ repo:

- 913281d203
- 842d31eefd
2025-01-20 21:45:24 +00:00
John Bartholomew
e1304d1698 update cppjsonnet and depend on a specific commit of jsonnet
This changes the bazel module dependencies so that the C++ jsonnet
repo dependency (which is actually used as the source for the
standard library and nothing else in the Bazel build) comes from
a specific commit of the jsonnet repo, rather than depending on
the 'published' jsonnet 0.20.0.

The two repos are tightly coupled anyway so I think this more
accurately reflects the situation. Particularly since the C++ repo
is also linked (at a specific commit) as a git submodule, which
is used for non-Bazel build and testing.
2025-01-20 21:45:24 +00:00
John Bartholomew
64c3804248 update Bazel rules with gazelle and manually 2025-01-20 21:45:24 +00:00
John Bartholomew
86cd73aec9 remove unmaintained travis config
As far as I'm aware we use GitHub Actions for our CI needs now.
2025-01-20 21:45:24 +00:00
John Bartholomew
156aa1d156 remove outdated .tool-versions config
It was added in Jan 2020 and apparently has never been updated since
then. It refers to Bazel 1.2.1 which is long out of date (Bazel 5 is
the oldest still maintained version, and Bazel 8 is the current
active version).
2025-01-20 21:45:24 +00:00
Tim Vergenz
e6f64e89f1
feat: add |||- chomped text block syntax (#773)
Resolves google/jsonnet#289

Companion PR to google/jsonnet#1175
2025-01-20 21:45:15 +00:00
John Bartholomew
a45dd8a8f4 chore: run GitHub CI action on more pull request activity
This corresponds to a similar commit on the C++ jsonnet repo:
a02a615def

The is intended to make it easier for me to trigger running CI on
existing pull requests.
2025-01-19 22:06:27 +00:00
John Bartholomew
74c8d09d4a feat: update cpp-jsonnet and stdlib to latest (unreleased)
This includes the stdlib additions in
https://github.com/google/jsonnet/pull/1187

Also updates golden files for go-jsonnet tests; the changes
to the goldens are mostly changes to error locations from
the standard library.
2025-01-18 17:12:28 +00:00
John Bartholomew
b3fed3ba12 feat: add builtin atan2 and hypot functions 2025-01-18 17:05:14 +00:00
Dominik Süß
2b4d7535f5
fix: use debugValueToString for debugger operations (#759)
The `valueToString` operation introduced by #742 is incompatible with the way
the implementation from #739 as it tries to manifest an object from stack while
the implementation needed by the debugger returns the value as-is without
further evaluation.
2024-06-11 14:40:04 +01:00