From c73f26bd67c72af9da402175ab0ad0885c85cdef Mon Sep 17 00:00:00 2001 From: Lucas Schwiderski Date: Fri, 20 Jun 2025 20:34:26 +0200 Subject: [PATCH 1/2] Fix compiler issues Apparently some changes in mlua that weren't caught during the update. --- src/types.rs | 8 ++++---- src/worker/lua.rs | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/types.rs b/src/types.rs index 82002f0..2d52ab0 100644 --- a/src/types.rs +++ b/src/types.rs @@ -4,14 +4,14 @@ use mlua::IntoLua; use serde::{Deserialize, Serialize}; /// Converts a `serde_json::Value` to a `mlua::Value`. -fn json_to_lua(value: serde_json::Value, lua: &mlua::Lua) -> mlua::Result> { +fn json_to_lua(value: serde_json::Value, lua: &mlua::Lua) -> mlua::Result { match value { serde_json::Value::Null => Ok(mlua::Value::Nil), serde_json::Value::Bool(value) => Ok(mlua::Value::Boolean(value)), serde_json::Value::Number(value) => match value.as_f64() { Some(number) => Ok(mlua::Value::Number(number)), None => Err(mlua::Error::ToLuaConversionError { - from: "serde_json::Value::Number", + from: String::from("serde_json::Value::Number"), to: "Number", message: Some("Number cannot be represented by a floating-point type".into()), }), @@ -52,8 +52,8 @@ pub(crate) struct ApiEvent { pub status: u16, } -impl<'lua> IntoLua<'lua> for ApiEvent { - fn into_lua(self, lua: &'lua mlua::Lua) -> mlua::Result> { +impl IntoLua for ApiEvent { + fn into_lua(self, lua: &mlua::Lua) -> mlua::Result { let headers = lua.create_table_with_capacity(0, self.headers.len())?; for (k, v) in self.headers { let k = lua.create_string(k)?; diff --git a/src/worker/lua.rs b/src/worker/lua.rs index 6ef1ad7..669c4ee 100644 --- a/src/worker/lua.rs +++ b/src/worker/lua.rs @@ -1,6 +1,6 @@ use std::sync::mpsc::Receiver; -use color_eyre::Result; +use color_eyre::{eyre, Result}; use mlua::{Function, IntoLua as _, Lua, LuaSerdeExt}; use tokio::sync::mpsc::UnboundedSender; @@ -96,23 +96,23 @@ pub fn worker( Event::Webhook(data) => { tracing::trace!(id = data.topic, "Received webhook event"); let data = lua.to_value(&data)?; - event_fn.call::<_, ()>(("webhook", data))? + event_fn.call(("webhook", data))? } Event::Api(data) => { tracing::trace!(id = data.id, status = data.status, "Received api event"); let data = data.into_lua(&lua)?; - event_fn.call::<_, ()>(("api", data))? + event_fn.call(("api", data))? } Event::Error(data) => { tracing::trace!(id = data.id, message = data.message, "Received error event"); let data = lua.to_value(&data)?; - event_fn.call::<_, ()>(("error", data))? + event_fn.call(("error", data))? } } } Ok(()) - })?; + }).map_err(|e| eyre::eyre!("{:?}", e))?; Ok(()) } -- 2.47.2 From 2f5754a9eb19a25aace89c27cc65873665fe27e8 Mon Sep 17 00:00:00 2001 From: Lucas Schwiderski Date: Fri, 20 Jun 2025 20:35:03 +0200 Subject: [PATCH 2/2] Add CI workflow --- .forgejo/workflows/check.yaml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .forgejo/workflows/check.yaml diff --git a/.forgejo/workflows/check.yaml b/.forgejo/workflows/check.yaml new file mode 100644 index 0000000..94555bc --- /dev/null +++ b/.forgejo/workflows/check.yaml @@ -0,0 +1,27 @@ +name: check + +on: + push: + branches: [master] + pull_request_target: + +jobs: + build: + runs-on: docker + steps: + - uses: https://code.forgejo.org/actions/checkout@v4 + - uses: https://github.com/actions-rust-lang/setup-rust-toolchain@fb51252c7ba57d633bc668f941da052e410add48 + - name: clippy + run: cargo build + + check: + runs-on: docker + steps: + - uses: https://code.forgejo.org/actions/checkout@v4 + - uses: https://github.com/actions-rust-lang/setup-rust-toolchain@fb51252c7ba57d633bc668f941da052e410add48 + with: + components: clippy, rustfmt + - name: clippy + run: cargo clippy -- -D warnings + - name: rustfmt + run: cargo fmt --all -- --check -- 2.47.2