Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/pr-extensions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
# Run at 8:00 AM every day
- cron: "0 8 * * *"

env:
CARGO_TERM_COLOR: always
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
# Run at 8:00 AM every day
- cron: "0 8 * * *"

env:
CARGO_TERM_COLOR: always
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/rust-clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ on:
# The branches below must be a subset of the branches above
branches: [ "main" ]
workflow_dispatch:
schedule:
# Run at 8:00 AM every day
- cron: "0 8 * * *"

jobs:
rust-clippy-analyze:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test-c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
# Run at 8:00 AM every day
- cron: "0 8 * * *"

jobs:
test:
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/test-csharp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
# Run at 8:00 AM every day
- cron: "0 8 * * *"

jobs:
build-ffi:
Expand Down Expand Up @@ -129,4 +132,4 @@ jobs:

- name: Run Regorus.Tests
run: dotnet test --no-restore
working-directory: ./bindings/csharp/Regorus.Tests
working-directory: ./bindings/csharp/Regorus.Tests
3 changes: 3 additions & 0 deletions .github/workflows/test-ffi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
# Run at 8:00 AM every day
- cron: "0 8 * * *"

jobs:
test:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
# Run at 8:00 AM every day
- cron: "0 8 * * *"

jobs:
test:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test-java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
# Run at 8:00 AM every day
- cron: "0 8 * * *"

jobs:
test:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test-musl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
# Run at 8:00 AM every day
- cron: "0 8 * * *"

env:
CARGO_TERM_COLOR: always
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test-no-std.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
# Run at 8:00 AM every day
- cron: "0 8 * * *"

env:
CARGO_TERM_COLOR: always
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/test-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
# Run at 8:00 AM every day
- cron: "0 8 * * *"

env:
PYTHON_VERSION: "3.10"
Expand Down Expand Up @@ -86,4 +89,4 @@ jobs:
run: |
pip3 install ../../wheels/${{ matrix.host.wheel }}
python3 test.py
working-directory: bindings/python
working-directory: bindings/python
3 changes: 3 additions & 0 deletions .github/workflows/test-wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
# Run at 8:00 AM every day
- cron: "0 8 * * *"

jobs:
test:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/tests-debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
# Run at 8:00 AM every day
- cron: "0 8 * * *"

env:
CARGO_TERM_COLOR: always
Expand Down
44 changes: 22 additions & 22 deletions bindings/ruby/ext/regorusrb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,49 +45,49 @@ impl Engine {
self.engine
.borrow_mut()
.add_policy(path, rego)
.map_err(|e| Error::new(runtime_error(), format!("Failed to add policy: {}", e)))
.map_err(|e| Error::new(runtime_error(), format!("Failed to add policy: {e}")))
}

fn add_policy_from_file(&self, path: String) -> Result<String, Error> {
self.engine
.borrow_mut()
.add_policy_from_file(path)
.map_err(|e| Error::new(runtime_error(), format!("Failed to add policy: {}", e)))
.map_err(|e| Error::new(runtime_error(), format!("Failed to add policy: {e}")))
}

fn add_data(&self, ruby_hash: magnus::RHash) -> Result<(), Error> {
let data_value: regorus::Value = serde_magnus::deserialize(ruby_hash).map_err(|e| {
Error::new(
runtime_error(),
format!("Failed to deserialize Ruby value: {}", e),
format!("Failed to deserialize Ruby value: {e}"),
)
})?;

self.engine
.borrow_mut()
.add_data(data_value)
.map_err(|e| Error::new(runtime_error(), format!("Failed to add data: {}", e)))
.map_err(|e| Error::new(runtime_error(), format!("Failed to add data: {e}")))
}

fn add_data_json(&self, json_string: String) -> Result<(), Error> {
self.engine
.borrow_mut()
.add_data_json(&json_string)
.map_err(|e| Error::new(runtime_error(), format!("Failed to add data json: {}", e)))
.map_err(|e| Error::new(runtime_error(), format!("Failed to add data json: {e}")))
}

fn add_data_from_json_file(&self, path: String) -> Result<(), Error> {
let json_data = regorus::Value::from_json_file(path).map_err(|e| {
Error::new(
runtime_error(),
format!("Failed to parse JSON data file: {}", e),
format!("Failed to parse JSON data file: {e}"),
)
})?;

self.engine.borrow_mut().add_data(json_data).map_err(|e| {
Error::new(
runtime_error(),
format!("Failed to add data from file: {}", e),
format!("Failed to add data from file: {e}"),
)
})
}
Expand Down Expand Up @@ -115,7 +115,7 @@ impl Engine {
let input_value: regorus::Value = serde_magnus::deserialize(ruby_hash).map_err(|e| {
Error::new(
runtime_error(),
format!("Failed to deserialize Ruby value: {}", e),
format!("Failed to deserialize Ruby value: {e}"),
)
})?;

Expand All @@ -127,14 +127,14 @@ impl Engine {
self.engine
.borrow_mut()
.set_input_json(&json_string)
.map_err(|e| Error::new(runtime_error(), format!("Failed to set input JSON: {}", e)))
.map_err(|e| Error::new(runtime_error(), format!("Failed to set input JSON: {e}")))
}

fn add_input_from_json_file(&self, path: String) -> Result<(), Error> {
let json_data = regorus::Value::from_json_file(path).map_err(|e| {
Error::new(
runtime_error(),
format!("Failed to parse JSON input file: {}", e),
format!("Failed to parse JSON input file: {e}"),
)
})?;

Expand All @@ -147,12 +147,12 @@ impl Engine {
.engine
.borrow_mut()
.eval_query(query, false)
.map_err(|e| Error::new(runtime_error(), format!("Failed to evaluate query: {}", e)))?;
.map_err(|e| Error::new(runtime_error(), format!("Failed to evaluate query: {e}")))?;

serde_magnus::serialize(&results).map_err(|e| {
Error::new(
runtime_error(),
format!("Failed to serailzie query results: {}", e),
format!("Failed to serailzie query results: {e}"),
)
})
}
Expand All @@ -165,22 +165,22 @@ impl Engine {
.map_err(|e| {
Error::new(
runtime_error(),
format!("Failed to evaluate query as json: {}", e),
format!("Failed to evaluate query as json: {e}"),
)
})?;

serde_json::to_string(&results).map_err(|e| {
Error::new(
runtime_error(),
format!("Failed to serialize query results: {}", e),
format!("Failed to serialize query results: {e}"),
)
})
}

fn eval_rule(&self, query: String) -> Result<Option<magnus::Value>, Error> {
let result =
self.engine.borrow_mut().eval_rule(query).map_err(|e| {
Error::new(runtime_error(), format!("Failed to evaluate rule: {}", e))
Error::new(runtime_error(), format!("Failed to evaluate rule: {e}"))
})?;

match result {
Expand All @@ -190,7 +190,7 @@ impl Engine {
.map_err(|e| {
magnus::Error::new(
runtime_error(),
format!("Failed to serialize the rule evaluation result: {}", e),
format!("Failed to serialize the rule evaluation result: {e}"),
)
}),
}
Expand All @@ -200,7 +200,7 @@ impl Engine {
self.engine
.borrow_mut()
.eval_bool_query(query, false)
.map_err(|e| Error::new(runtime_error(), format!("Failed to evaluate query: {}", e)))
.map_err(|e| Error::new(runtime_error(), format!("Failed to evaluate query: {e}")))
}

fn eval_allow_query(&self, query: String) -> Result<bool, Error> {
Expand All @@ -226,14 +226,14 @@ impl Engine {
.map_err(|e| {
Error::new(
runtime_error(),
format!("Failed to get coverage report as json: {}", e),
format!("Failed to get coverage report as json: {e}"),
)
})?;

serde_json::to_string(&report).map_err(|e| {
Error::new(
runtime_error(),
format!("Failed to serialize coverage report: {}", e),
format!("Failed to serialize coverage report: {e}"),
)
})
}
Expand All @@ -247,14 +247,14 @@ impl Engine {
.map_err(|e| {
Error::new(
runtime_error(),
format!("Failed to get coverage report: {}", e),
format!("Failed to get coverage report: {e}"),
)
})?;

report.to_string_pretty().map_err(|e| {
Error::new(
runtime_error(),
format!("Failed to convert report to colored string: {}", e),
format!("Failed to convert report to colored string: {e}"),
)
})
}
Expand All @@ -275,7 +275,7 @@ impl Engine {
self.engine.borrow_mut().take_prints().map_err(|e| {
Error::new(
runtime_error(),
format!("Failed to gather print statement: {}", e),
format!("Failed to gather print statement: {e}"),
)
})
}
Expand Down
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fn main() -> Result<()> {
.output()
.expect("`git rev-parse HEAD` failed.");
let git_hash = String::from_utf8(output.stdout).unwrap();
println!("cargo:rustc-env=GIT_HASH={}", git_hash);
println!("cargo:rustc-env=GIT_HASH={git_hash}");
}

// Rerun only if build.rs changes.
Expand Down
2 changes: 1 addition & 1 deletion src/builtins/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ fn yaml_marshal(span: &Span, params: &[Ref<Expr>], args: &[Value], _strict: bool
ensure_args_count(span, name, params, args, 1)?;

let serialized = serde_yaml::to_string(&args[0])
.map_err(|err| span.error(&format!("could not serialize to yaml: {}", err)))?;
.map_err(|err| span.error(&format!("could not serialize to yaml: {err}")))?;

Ok(Value::String(serialized.into()))
}
Expand Down
2 changes: 1 addition & 1 deletion src/builtins/numbers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub fn arithmetic_operation(
v2: Value,
strict: bool,
) -> Result<Value> {
let op_name = format!("{:?}", op).to_lowercase();
let op_name = format!("{op:?}").to_lowercase();
let v1 = ensure_numeric(op_name.as_str(), expr1, &v1)?;
let v2 = ensure_numeric(op_name.as_str(), expr2, &v2)?;

Expand Down
2 changes: 1 addition & 1 deletion src/builtins/objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ fn json_match_schema(

// The following is expected to succeed.
let document: serde_json::Value = serde_json::from_str(&args[0].to_json_str()?)
.map_err(|err| span.error(&format!("Failed to parse JSON: {}", err)))?;
.map_err(|err| span.error(&format!("Failed to parse JSON: {err}")))?;

Ok(Value::from_array(
match compile_json_schema(&params[1], &args[1]) {
Expand Down
9 changes: 4 additions & 5 deletions src/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ impl Interpreter {
{
bail!(rhs
.span()
.error(&format!("redefinition for variable {}", name)));
.error(&format!("redefinition for variable {name}")));
}

(name, rhs_value)
Expand Down Expand Up @@ -3192,10 +3192,9 @@ impl Interpreter {
Expr::RefBrack { refr, index, .. } => (refr, Some(index.clone())),
Expr::RefDot { .. } => (refr, None),
Expr::Var { .. } => (refr, None),
_ => bail!(refr.span().error(&format!(
"invalid token {:?} with the default keyword",
refr
))),
_ => bail!(refr
.span()
.error(&format!("invalid token {refr:?} with the default keyword"))),
};

Parser::get_path_ref_components_into(refr, &mut path)?;
Expand Down
Loading
Loading