generated from lucas/rust-template
Compare commits
13 commits
renovate/a
...
master
Author | SHA1 | Date | |
---|---|---|---|
e27711fa3f | |||
e58cb628c0 | |||
bd02952b91 | |||
2f5754a9eb | |||
c73f26bd67 | |||
6d7ccda449 | |||
09abc20574 | |||
94ce380eea | |||
2dcd69e6d2 | |||
183394831c | |||
f07d09572f | |||
2574dedfdc | |||
b2699a4601 |
5 changed files with 47 additions and 30 deletions
27
.forgejo/workflows/check.yaml
Normal file
27
.forgejo/workflows/check.yaml
Normal file
|
@ -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: Build
|
||||||
|
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: Run clippy
|
||||||
|
run: cargo clippy -- -D warnings
|
||||||
|
- name: Run rustfmt
|
||||||
|
run: cargo fmt --all -- --check
|
|
@ -3,8 +3,7 @@
|
||||||
"extends": [
|
"extends": [
|
||||||
"config:recommended",
|
"config:recommended",
|
||||||
":combinePatchMinorReleases",
|
":combinePatchMinorReleases",
|
||||||
":enableVulnerabilityAlerts",
|
":enableVulnerabilityAlerts"
|
||||||
":rebaseStalePrs"
|
|
||||||
],
|
],
|
||||||
"prConcurrentLimit": 10,
|
"prConcurrentLimit": 10,
|
||||||
"branchPrefix": "renovate/"
|
"branchPrefix": "renovate/"
|
||||||
|
|
29
Cargo.lock
generated
29
Cargo.lock
generated
|
@ -170,27 +170,27 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "color-eyre"
|
name = "color-eyre"
|
||||||
version = "0.6.4"
|
version = "0.6.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e6e1761c0e16f8883bbbb8ce5990867f4f06bf11a0253da6495a04ce4b6ef0ec"
|
checksum = "e5920befb47832a6d61ee3a3a846565cfa39b331331e68a3b1d1116630f2f26d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"backtrace",
|
"backtrace",
|
||||||
"color-spantrace",
|
"color-spantrace",
|
||||||
"eyre",
|
"eyre",
|
||||||
"indenter",
|
"indenter",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"owo-colors 4.2.0",
|
"owo-colors",
|
||||||
"tracing-error",
|
"tracing-error",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "color-spantrace"
|
name = "color-spantrace"
|
||||||
version = "0.2.1"
|
version = "0.3.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cd6be1b2a7e382e2b98b43b2adcca6bb0e465af0bdd38123873ae61eb17a72c2"
|
checksum = "b8b88ea9df13354b55bc7234ebcce36e6ef896aca2e42a15de9e10edce01b427"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"owo-colors 3.5.0",
|
"owo-colors",
|
||||||
"tracing-core",
|
"tracing-core",
|
||||||
"tracing-error",
|
"tracing-error",
|
||||||
]
|
]
|
||||||
|
@ -689,12 +689,6 @@ version = "0.1.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
|
checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "owo-colors"
|
|
||||||
version = "3.5.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "owo-colors"
|
name = "owo-colors"
|
||||||
version = "4.2.0"
|
version = "4.2.0"
|
||||||
|
@ -950,9 +944,9 @@ checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "reqwest"
|
name = "reqwest"
|
||||||
version = "0.12.18"
|
version = "0.12.20"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e98ff6b0dbbe4d5a37318f433d4fc82babd21631f194d370409ceb2e40b2f0b5"
|
checksum = "eabf4c97d9130e2bf606614eb937e86edac8292eaa6f422f995d7e8de1eb1813"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64",
|
"base64",
|
||||||
"bytes",
|
"bytes",
|
||||||
|
@ -963,11 +957,8 @@ dependencies = [
|
||||||
"hyper",
|
"hyper",
|
||||||
"hyper-rustls",
|
"hyper-rustls",
|
||||||
"hyper-util",
|
"hyper-util",
|
||||||
"ipnet",
|
|
||||||
"js-sys",
|
"js-sys",
|
||||||
"log",
|
"log",
|
||||||
"mime",
|
|
||||||
"once_cell",
|
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"quinn",
|
"quinn",
|
||||||
|
@ -1350,9 +1341,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tower-http"
|
name = "tower-http"
|
||||||
version = "0.6.4"
|
version = "0.6.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0fdb0c213ca27a9f57ab69ddb290fd80d970922355b83ae380b395d3986b8a2e"
|
checksum = "5cc2d9e086a412a451384326f521c8123a99a466b329941a9403696bff9b0da2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"bytes",
|
"bytes",
|
||||||
|
|
|
@ -4,14 +4,14 @@ use mlua::IntoLua;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// Converts a `serde_json::Value` to a `mlua::Value`.
|
/// Converts a `serde_json::Value` to a `mlua::Value`.
|
||||||
fn json_to_lua(value: serde_json::Value, lua: &mlua::Lua) -> mlua::Result<mlua::Value<'_>> {
|
fn json_to_lua(value: serde_json::Value, lua: &mlua::Lua) -> mlua::Result<mlua::Value> {
|
||||||
match value {
|
match value {
|
||||||
serde_json::Value::Null => Ok(mlua::Value::Nil),
|
serde_json::Value::Null => Ok(mlua::Value::Nil),
|
||||||
serde_json::Value::Bool(value) => Ok(mlua::Value::Boolean(value)),
|
serde_json::Value::Bool(value) => Ok(mlua::Value::Boolean(value)),
|
||||||
serde_json::Value::Number(value) => match value.as_f64() {
|
serde_json::Value::Number(value) => match value.as_f64() {
|
||||||
Some(number) => Ok(mlua::Value::Number(number)),
|
Some(number) => Ok(mlua::Value::Number(number)),
|
||||||
None => Err(mlua::Error::ToLuaConversionError {
|
None => Err(mlua::Error::ToLuaConversionError {
|
||||||
from: "serde_json::Value::Number",
|
from: String::from("serde_json::Value::Number"),
|
||||||
to: "Number",
|
to: "Number",
|
||||||
message: Some("Number cannot be represented by a floating-point type".into()),
|
message: Some("Number cannot be represented by a floating-point type".into()),
|
||||||
}),
|
}),
|
||||||
|
@ -52,8 +52,8 @@ pub(crate) struct ApiEvent {
|
||||||
pub status: u16,
|
pub status: u16,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'lua> IntoLua<'lua> for ApiEvent {
|
impl IntoLua for ApiEvent {
|
||||||
fn into_lua(self, lua: &'lua mlua::Lua) -> mlua::Result<mlua::Value<'lua>> {
|
fn into_lua(self, lua: &mlua::Lua) -> mlua::Result<mlua::Value> {
|
||||||
let headers = lua.create_table_with_capacity(0, self.headers.len())?;
|
let headers = lua.create_table_with_capacity(0, self.headers.len())?;
|
||||||
for (k, v) in self.headers {
|
for (k, v) in self.headers {
|
||||||
let k = lua.create_string(k)?;
|
let k = lua.create_string(k)?;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::sync::mpsc::Receiver;
|
use std::sync::mpsc::Receiver;
|
||||||
|
|
||||||
use color_eyre::Result;
|
use color_eyre::{eyre, Result};
|
||||||
use mlua::{Function, IntoLua as _, Lua, LuaSerdeExt};
|
use mlua::{Function, IntoLua as _, Lua, LuaSerdeExt};
|
||||||
use tokio::sync::mpsc::UnboundedSender;
|
use tokio::sync::mpsc::UnboundedSender;
|
||||||
|
|
||||||
|
@ -96,23 +96,23 @@ pub fn worker(
|
||||||
Event::Webhook(data) => {
|
Event::Webhook(data) => {
|
||||||
tracing::trace!(id = data.topic, "Received webhook event");
|
tracing::trace!(id = data.topic, "Received webhook event");
|
||||||
let data = lua.to_value(&data)?;
|
let data = lua.to_value(&data)?;
|
||||||
event_fn.call::<_, ()>(("webhook", data))?
|
event_fn.call(("webhook", data))?
|
||||||
}
|
}
|
||||||
Event::Api(data) => {
|
Event::Api(data) => {
|
||||||
tracing::trace!(id = data.id, status = data.status, "Received api event");
|
tracing::trace!(id = data.id, status = data.status, "Received api event");
|
||||||
let data = data.into_lua(&lua)?;
|
let data = data.into_lua(&lua)?;
|
||||||
event_fn.call::<_, ()>(("api", data))?
|
event_fn.call(("api", data))?
|
||||||
}
|
}
|
||||||
Event::Error(data) => {
|
Event::Error(data) => {
|
||||||
tracing::trace!(id = data.id, message = data.message, "Received error event");
|
tracing::trace!(id = data.id, message = data.message, "Received error event");
|
||||||
let data = lua.to_value(&data)?;
|
let data = lua.to_value(&data)?;
|
||||||
event_fn.call::<_, ()>(("error", data))?
|
event_fn.call(("error", data))?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
})?;
|
}).map_err(|e| eyre::eyre!("{:?}", e))?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue