diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index ef17cdc..73c838b 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -10,32 +10,38 @@ on: jobs: linux: runs-on: ubuntu-latest + strategy: + matrix: + platform: [ + { target: "x86_64-unknown-linux-musl", image_tag: "x86_64-musl" }, +# { target: "aarch64-unknown-linux-musl", image_tag: "aarch64-musl" }, + ] + container: + image: docker://messense/rust-musl-cross:${{ matrix.platform.image_tag }} + env: + CFLAGS_armv7_unknown_linux_musleabihf: '-mfpu=vfpv3-d16' steps: - - uses: actions/checkout@v3 - - uses: messense/maturin-action@v1 - with: - manylinux: auto - command: build - args: --release --sdist -o dist --find-interpreter - - name: Upload wheels - uses: actions/upload-artifact@v2 - with: - name: wheels - path: dist + - uses: actions/checkout@v2 +# - name: Build Wheels - manylinux +# uses: messense/maturin-action@main +# with: +# target: ${{ matrix.platform.target }} +# manylinux: auto +# container: off +# args: --release -o dist + - name: Build Wheels - musllinux + uses: messense/maturin-action@main + with: + target: ${{ matrix.platform.target }} + manylinux: musllinux_1_2 + container: off - windows: - runs-on: windows-latest - steps: - - uses: actions/checkout@v3 - - uses: messense/maturin-action@v1 - with: - command: build - args: --release -o dist --find-interpreter - - name: Upload wheels - uses: actions/upload-artifact@v2 - with: - name: wheels - path: dist + args: --release -o dist + - name: Upload wheels + uses: actions/upload-artifact@v2 + with: + name: wheels + path: dist macos: runs-on: macos-latest @@ -55,7 +61,7 @@ jobs: name: Release runs-on: ubuntu-latest # if: "startsWith(github.ref, 'refs/tags/')" - needs: [ macos, windows, linux ] + needs: [ macos, linux ] steps: - uses: actions/download-artifact@v2 with: diff --git a/Cargo.lock b/Cargo.lock index 0eb0227..50acdb9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -29,8 +29,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "deno_core" version = "0.114.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8ddd27161918d0d0cc44ee5ff3b817b4c87e868922d63ee026f3e7c24f36131" +source = "git+https://github.com/fevral13/deno.git?branch=patched#fe1c73b8ab03afdbb2db93f969d7af918cb6017a" dependencies = [ "anyhow", "futures", @@ -55,7 +54,7 @@ checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" [[package]] name = "evalrspy" -version = "0.1.0" +version = "0.1.3" dependencies = [ "anyhow", "js-sandbox", @@ -216,9 +215,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754" +checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" [[package]] name = "js-sandbox" @@ -524,8 +523,7 @@ dependencies = [ [[package]] name = "serde_v8" version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f393dfbff517625ec0d87f449c8778f5645ebff9408f70988cf9a9ac33525934" +source = "git+https://github.com/fevral13/deno.git?branch=patched#fe1c73b8ab03afdbb2db93f969d7af918cb6017a" dependencies = [ "serde", "serde_bytes", @@ -549,9 +547,9 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] name = "syn" -version = "1.0.101" +version = "1.0.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e90cde112c4b9690b8cbe810cba9ddd8bc1d7472e2cae317b69e9438c1cba7d2" +checksum = "3fcd952facd492f9be3ef0d0b7032a6e442ee9b361d4acc2b1d0c4aaa5f613a1" dependencies = [ "proc-macro2", "quote", @@ -607,9 +605,9 @@ checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" [[package]] name = "unicode-ident" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd" +checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" [[package]] name = "unicode-normalization" diff --git a/Cargo.toml b/Cargo.toml index bdbc12a..eadb6f8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "evalrspy" -version = "0.1.0" +version = "0.1.3" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -14,4 +14,7 @@ serde = { version = "1.0.145", features = ["derive"] } serde_json = "1.0.85" anyhow = "1.0.65" thiserror = "1.0.37" -js-sandbox = "0.2.0-rc.0" \ No newline at end of file +js-sandbox = "0.2.0-rc.0" + +[patch.crates-io] +deno_core = { git = "https://github.com/fevral13/deno.git", branch = "patched" } \ No newline at end of file diff --git a/src/evaluator/evaluator.rs b/src/evaluator/evaluator.rs index 8c091d1..5889cf9 100644 --- a/src/evaluator/evaluator.rs +++ b/src/evaluator/evaluator.rs @@ -1,13 +1,13 @@ use js_sandbox::{AnyError, Script}; use pyo3::prelude::*; -use serde::{self, Deserialize}; +use serde; use serde_json::{self, Value}; use std::time::Duration; use thiserror; use super::constants::{DEFAULT_TIMEOUT, JS_PRELUDE}; -#[derive(Debug, Deserialize)] +#[derive(Debug, serde::Deserialize)] pub struct Request { pub script: String, pub variables: Value, @@ -24,16 +24,16 @@ impl Request { #[derive(thiserror::Error, Debug)] enum EvalrsError { #[error("Wrong argument structure")] - WrongArguments, + WrongArguments(#[source] serde_json::Error), #[error("Variables must be a dict")] WrongVariablesType, #[error("Script is not a valid JS code")] - WrongScriptCode { source: AnyError }, + WrongScriptCode(#[source] AnyError), #[error("Script evaluation error")] - ScriptEvaluationError { source: AnyError }, + ScriptEvaluationError(#[source] AnyError), } #[pyfunction] @@ -67,7 +67,7 @@ fn parse_request(request_string: &str) -> Result { match parse_result { Ok(request) => Ok(request), - Err(_) => Err(EvalrsError::WrongArguments), + Err(error) => Err(EvalrsError::WrongArguments(error)), } } @@ -93,7 +93,7 @@ fn get_script_evaluator(script_code: &str, timeout: u64) -> Result Ok(evaluator.with_timeout(duration)), - Err(error) => Err(EvalrsError::WrongScriptCode { source: error }), + Err(error) => Err(EvalrsError::WrongScriptCode(error)), } } @@ -107,7 +107,7 @@ fn evaluate_script( (Value::String(script.clone()), variables.clone()), ) { Ok(result) => Ok(result), - Err(error) => Err(EvalrsError::ScriptEvaluationError { source: error }), + Err(error) => Err(EvalrsError::ScriptEvaluationError(error)), } }