git.delta.rocks / jrsonnet / refs/commits / cead2c336a71

difftreelog

Merge commit 'd93ca83fe3668f134c0a705b972e2b52072ebf3d'

Yaroslav Bolyukin2021-05-23parents: #b148741 #d93ca83.patch.diff
in: master

3 files changed

modified.github/workflows/release.ymldiffbeforeafterboth
53 needs: [test]53 needs: [test]
54 strategy:54 strategy:
55 matrix:55 matrix:
56 os: [ubuntu-latest, macOS-latest, windows-latest]56 target:
57 # Tier 1
58 - aarch64-unknown-linux-gnu
59 - i686-pc-windows-gnu
60 - i686-pc-windows-msvc
61 - i686-unknown-linux-gnu
62 - x86_64-apple-darwin
63 - x86_64-pc-windows-gnu
64 - x86_64-pc-windows-msvc
65 - x86_64-unknown-linux-gnu
66
67 # Other
68 - x86_64-unknown-linux-musl
57 include:69 include:
58 - os: ubuntu-latest70 - target: aarch64-unknown-linux-gnu
59 rust: stable71 os: ubuntu-latest
60 target: x86_64-unknown-linux-musl
61 bin: jrsonnet72 bin: jrsonnet
62 name: jrsonnet-linux-amd6473 name: jrsonnet-linux-gnu-aarch64
63 - os: windows-latest74 - target: i686-pc-windows-gnu
64 rust: stable75 os: windows-latest
65 target: x86_64-pc-windows-msvc
66 bin: jrsonnet.exe76 bin: jrsonnet.exe
67 name: jrsonnet-windows-amd64.exe77 name: jrsonnet-windows-gnu-i686.exe
78 - target: i686-pc-windows-msvc
79 os: windows-latest
80 bin: jrsonnet.exe
81 name: jrsonnet-windows-msvc-i686.exe
82 - target: i686-unknown-linux-gnu
83 os: ubuntu-latest
84 bin: jrsonnet
85 name: jrsonnet-linux-gnu-i686
68 - os: macOS-latest86 - target: x86_64-apple-darwin
69 rust: stable87 os: macOS-latest
70 target: x86_64-apple-darwin
71 bin: jrsonnet88 bin: jrsonnet
72 name: jrsonnet-darwin-amd6489 name: jrsonnet-darwin-amd64
90 - target: x86_64-pc-windows-gnu
91 os: windows-latest
92 bin: jrsonnet.exe
93 name: jrsonnet-windows-gnu-amd64.exe
94 - target: x86_64-pc-windows-msvc
95 os: windows-latest
96 bin: jrsonnet.exe
97 name: jrsonnet-windows-msvc-amd64.exe
98 - target: x86_64-unknown-linux-gnu
99 os: ubuntu-latest
100 bin: jrsonnet
101 name: jrsonnet-linux-gnu-amd64
102
103 - target: x86_64-unknown-linux-musl
104 os: ubuntu-latest
105 bin: jrsonnet
106 name: jrsonnet-linux-musl-amd64
73 runs-on: ${{ matrix.os }}107 runs-on: ${{ matrix.os }}
74 steps:108 steps:
75 - name: Install stable toolchain109 - name: Install stable toolchain
76 uses: actions-rs/toolchain@v1110 uses: actions-rs/toolchain@v1
77 with:111 with:
78 toolchain: ${{ matrix.rust }}112 toolchain: stable
79 override: true113 override: true
80 target: ${{ matrix.target }}114 target: ${{ matrix.target }}
115
81 - name: Checkout116 - name: Checkout
82 uses: actions/checkout@v2117 uses: actions/checkout@v2
118
119 - name: Linux x86 cross compiler
120 if: ${{ matrix.target == 'i686-unknown-linux-gnu' }}
121 run: sudo apt install gcc-multilib
122
123 - name: Windows x86 cross compiler
124 if: ${{ matrix.target == 'i686-pc-windows-gnu' }}
125 uses: egor-tensin/setup-mingw@v2
126 with:
127 platform: x86
128
129 - name: ARM cross compiler
130 if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
131 uses: actions-rs/cargo@v1
132 with:
133 command: install
134 args: cross
135
136 - name: Run ARM build
137 if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
138 shell: bash
139 run: cross --bin=jrsonnet --release --target ${{ matrix.target }}
140
83 - name: Run build141 - name: Run build
142 if: ${{ matrix.target != 'aarch64-unknown-linux-gnu' }}
84 uses: actions-rs/cargo@v1143 uses: actions-rs/cargo@v1
85 with:144 with:
86 command: build145 command: build
modifiedcrates/jrsonnet-evaluator/src/builtin/mod.rsdiffbeforeafterboth
1use 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}
167
168fn 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}
166181
167// faster182// faster
168fn builtin_slice(context: Context, _loc: Option<&ExprLocation>, args: &ArgsDesc) -> Result<Val> {183fn builtin_slice(context: Context, _loc: Option<&ExprLocation>, args: &ArgsDesc) -> Result<Val> {
modifiedcrates/jrsonnet-evaluator/src/lib.rsdiffbeforeafterboth
808 );808 );
809 }809 }
810
811 #[test]
812 fn parse_json() {
813 assert_json!(
814 r#"std.parseJson('{"a": -1,"b": 1,"c": 3.141,"d": []}')"#,
815 r#"{"a": -1,"b": 1,"c": 3.141,"d": []}"#
816 );
817 // TODO: this should in fact fail as is no proper JSON syntax
818 assert_json!(
819 r#"std.parseJson("{a:-1, b:1, c:3.141, d:[]}")"#,
820 r#"{"a": -1,"b": 1,"c": 3.141,"d": []}"#
821 );
822 // TODO: this is also no valid JSON
823 assert_json!(r#"std.parseJson('local x = 2; x * x')"#, r#"4"#);
824 }
810825
811 #[test]826 #[test]
812 fn test() {827 fn test() {