difftreelog
Merge commit 'd93ca83fe3668f134c0a705b972e2b52072ebf3d'
in: master
3 files changed
.github/workflows/release.ymldiffbeforeafterboth--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -53,38 +53,98 @@
needs: [test]
strategy:
matrix:
- os: [ubuntu-latest, macOS-latest, windows-latest]
+ target:
+ # Tier 1
+ - aarch64-unknown-linux-gnu
+ - i686-pc-windows-gnu
+ - i686-pc-windows-msvc
+ - i686-unknown-linux-gnu
+ - x86_64-apple-darwin
+ - x86_64-pc-windows-gnu
+ - x86_64-pc-windows-msvc
+ - x86_64-unknown-linux-gnu
+
+ # Other
+ - x86_64-unknown-linux-musl
include:
- - os: ubuntu-latest
- rust: stable
- target: x86_64-unknown-linux-musl
+ - target: aarch64-unknown-linux-gnu
+ os: ubuntu-latest
bin: jrsonnet
- name: jrsonnet-linux-amd64
- - os: windows-latest
- rust: stable
- target: x86_64-pc-windows-msvc
+ name: jrsonnet-linux-gnu-aarch64
+ - target: i686-pc-windows-gnu
+ os: windows-latest
bin: jrsonnet.exe
- name: jrsonnet-windows-amd64.exe
- - os: macOS-latest
- rust: stable
- target: x86_64-apple-darwin
+ name: jrsonnet-windows-gnu-i686.exe
+ - target: i686-pc-windows-msvc
+ os: windows-latest
+ bin: jrsonnet.exe
+ name: jrsonnet-windows-msvc-i686.exe
+ - target: i686-unknown-linux-gnu
+ os: ubuntu-latest
bin: jrsonnet
+ name: jrsonnet-linux-gnu-i686
+ - target: x86_64-apple-darwin
+ os: macOS-latest
+ bin: jrsonnet
name: jrsonnet-darwin-amd64
+ - target: x86_64-pc-windows-gnu
+ os: windows-latest
+ bin: jrsonnet.exe
+ name: jrsonnet-windows-gnu-amd64.exe
+ - target: x86_64-pc-windows-msvc
+ os: windows-latest
+ bin: jrsonnet.exe
+ name: jrsonnet-windows-msvc-amd64.exe
+ - target: x86_64-unknown-linux-gnu
+ os: ubuntu-latest
+ bin: jrsonnet
+ name: jrsonnet-linux-gnu-amd64
+
+ - target: x86_64-unknown-linux-musl
+ os: ubuntu-latest
+ bin: jrsonnet
+ name: jrsonnet-linux-musl-amd64
runs-on: ${{ matrix.os }}
steps:
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
- toolchain: ${{ matrix.rust }}
+ toolchain: stable
override: true
target: ${{ matrix.target }}
+
- name: Checkout
uses: actions/checkout@v2
+
+ - name: Linux x86 cross compiler
+ if: ${{ matrix.target == 'i686-unknown-linux-gnu' }}
+ run: sudo apt install gcc-multilib
+
+ - name: Windows x86 cross compiler
+ if: ${{ matrix.target == 'i686-pc-windows-gnu' }}
+ uses: egor-tensin/setup-mingw@v2
+ with:
+ platform: x86
+
+ - name: ARM cross compiler
+ if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
+ uses: actions-rs/cargo@v1
+ with:
+ command: install
+ args: cross
+
+ - name: Run ARM build
+ if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
+ shell: bash
+ run: cross --bin=jrsonnet --release --target ${{ matrix.target }}
+
- name: Run build
+ if: ${{ matrix.target != 'aarch64-unknown-linux-gnu' }}
uses: actions-rs/cargo@v1
with:
command: build
args: --bin=jrsonnet --release --target ${{ matrix.target }}
+
- name: Package
shell: bash
run: |
@@ -93,8 +153,10 @@
cp ${{ matrix.bin }} ../../../${{ matrix.name }}
cd -
+
- name: Generate SHA-256
run: shasum -a 256 ${{ matrix.name }} > ${{ matrix.name }}.sha256
+
- name: Publish
uses: softprops/action-gh-release@v1
with:
crates/jrsonnet-evaluator/src/builtin/mod.rsdiffbeforeafterboth1use crate::{1use crate::{2 equals,2 equals,3 error::{Error::*, Result},3 error::{Error::*, Result},4 parse_args, primitive_equals, push, throw, with_state, ArrValue, Context, FuncVal, LazyVal,4 parse_args, primitive_equals, push, throw, with_state, ArrValue, Context, EvaluationState,5 Val,5 FuncVal, LazyVal, Val,6};6};7use format::{format_arr, format_obj};7use format::{format_arr, format_obj};74 ("reverse".into(), builtin_reverse),74 ("reverse".into(), builtin_reverse),75 ("id".into(), builtin_id),75 ("id".into(), builtin_id),76 ("strReplace".into(), builtin_str_replace),76 ("strReplace".into(), builtin_str_replace),77 ("parseJson".into(), builtin_parse_json),77 ].iter().cloned().collect()78 ].iter().cloned().collect()78 };79 };79}80}164 })165 })165}166}167168fn builtin_parse_json(169 context: Context,170 _loc: Option<&ExprLocation>,171 args: &ArgsDesc,172) -> Result<Val> {173 parse_args!(context, "parseJson", args, 1, [174 0, s: ty!(string) => Val::Str;175 ], {176 let state = EvaluationState::default();177 let path = Rc::new(PathBuf::from("std.parseJson"));178 state.evaluate_snippet_raw(path ,s)179 })180}166181167// faster182// faster168fn builtin_slice(context: Context, _loc: Option<&ExprLocation>, args: &ArgsDesc) -> Result<Val> {183fn builtin_slice(context: Context, _loc: Option<&ExprLocation>, args: &ArgsDesc) -> Result<Val> {crates/jrsonnet-evaluator/src/lib.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/lib.rs
+++ b/crates/jrsonnet-evaluator/src/lib.rs
@@ -809,6 +809,21 @@
}
#[test]
+ fn parse_json() {
+ assert_json!(
+ r#"std.parseJson('{"a": -1,"b": 1,"c": 3.141,"d": []}')"#,
+ r#"{"a": -1,"b": 1,"c": 3.141,"d": []}"#
+ );
+ // TODO: this should in fact fail as is no proper JSON syntax
+ assert_json!(
+ r#"std.parseJson("{a:-1, b:1, c:3.141, d:[]}")"#,
+ r#"{"a": -1,"b": 1,"c": 3.141,"d": []}"#
+ );
+ // TODO: this is also no valid JSON
+ assert_json!(r#"std.parseJson('local x = 2; x * x')"#, r#"4"#);
+ }
+
+ #[test]
fn test() {
assert_json!(
r#"[[a, b] for a in [1,2,3] for b in [4,5,6]]"#,