Compare commits
3 Commits
a8e4a710f1
...
feat-auto-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc21036448 | ||
|
|
4fd75701c7 | ||
|
|
b843105533 |
45
.woodpecker/server-clippy-fix.yaml
Normal file
45
.woodpecker/server-clippy-fix.yaml
Normal file
@@ -0,0 +1,45 @@
|
||||
when:
|
||||
- event: push
|
||||
branch: main
|
||||
path:
|
||||
include: ['.woodpecker/server-*.yaml', 'server/**']
|
||||
|
||||
steps:
|
||||
- name: clippy-fix
|
||||
image: jdxcode/mise:latest
|
||||
directory: server
|
||||
environment:
|
||||
CARGO_TERM_COLOR: always
|
||||
CARGO_TARGET_DIR: /usr/local/cargo/target
|
||||
CARGO_HOME: /usr/local/cargo/registry
|
||||
GITEA_TOKEN:
|
||||
from_secret: GITEA_TOKEN
|
||||
GITEA_URL:
|
||||
from_secret: GITEA_URL
|
||||
volumes:
|
||||
- cargo-target:/usr/local/cargo/target
|
||||
- cargo-registry:/usr/local/cargo/registry
|
||||
commands:
|
||||
- apt-get update && apt-get install -y pkg-config curl
|
||||
- mise install rust
|
||||
- mise install protoc
|
||||
- mise exec rust -- cargo clippy --fix --allow-dirty --all
|
||||
- |
|
||||
cd ..
|
||||
if git diff --quiet HEAD; then
|
||||
echo "No machine-applicable clippy fixes found, nothing to do."
|
||||
exit 0
|
||||
fi
|
||||
git config user.email "bot@arbiter"
|
||||
git config user.name "Clippy Bot"
|
||||
git add -A
|
||||
git commit -m "fix(clippy): apply auto-fixable linting suggestions"
|
||||
git config http.extraHeader "Authorization: token ${GITEA_TOKEN}"
|
||||
git push --force origin HEAD:refs/heads/bot/clippy-fixes
|
||||
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
|
||||
-X POST "${GITEA_URL}/api/v1/repos/${CI_REPO}/pulls" \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"title\":\"fix(clippy): apply auto-fixable linting suggestions\",\"head\":\"bot/clippy-fixes\",\"base\":\"main\",\"body\":\"Automated clippy fixes generated by CI bot.\"}")
|
||||
echo "Gitea API response: ${HTTP_STATUS}"
|
||||
[ "$HTTP_STATUS" = "201" ] || [ "$HTTP_STATUS" = "409" ] || [ "$HTTP_STATUS" = "422" ] || exit 1
|
||||
@@ -11,7 +11,9 @@ use kameo::{
|
||||
prelude::{ActorId, ActorRef, ActorStopReason, Context, WeakActorRef},
|
||||
reply::ReplySender,
|
||||
};
|
||||
use std::ops::ControlFlow;
|
||||
use std::{ops::ControlFlow, time::Duration};
|
||||
|
||||
const APPROVAL_TIMEOUT: Duration = Duration::from_secs(30);
|
||||
|
||||
pub struct Args {
|
||||
pub client: ClientProfile,
|
||||
@@ -64,6 +66,14 @@ impl Actor for ClientApprovalController {
|
||||
.await;
|
||||
}
|
||||
|
||||
let weak = actor_ref.downgrade();
|
||||
tokio::spawn(async move {
|
||||
tokio::time::sleep(APPROVAL_TIMEOUT).await;
|
||||
if let Some(r) = weak.upgrade() {
|
||||
let _ = r.tell(OnApprovalTimeout {}).await;
|
||||
}
|
||||
});
|
||||
|
||||
Ok(this)
|
||||
}
|
||||
|
||||
@@ -104,4 +114,14 @@ impl ClientApprovalController {
|
||||
ctx.stop();
|
||||
}
|
||||
}
|
||||
|
||||
/// Fired after `APPROVAL_TIMEOUT` elapses. Any operator that hasn't responded
|
||||
/// by then is treated as a denial to prevent zombie sessions from blocking the flow.
|
||||
#[message(ctx)]
|
||||
pub fn on_approval_timeout(&mut self, ctx: &mut Context<Self, ()>) {
|
||||
if self.pending > 0 {
|
||||
self.send_reply(Ok(false));
|
||||
ctx.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use super::{OutOfBand, OperatorConnection};
|
||||
use crate::{
|
||||
actors::{
|
||||
flow_coordinator::client_connect_approval::ClientApprovalController,
|
||||
flow_coordinator::client_connect_approval::{ClientApprovalAnswer, ClientApprovalController},
|
||||
operator_registry::ConnectOperator,
|
||||
},
|
||||
peers::client::ClientProfile,
|
||||
@@ -88,6 +88,7 @@ impl OperatorSession {
|
||||
actor = "operator",
|
||||
event = "failed to announce new client connection"
|
||||
);
|
||||
let _ = controller.tell(ClientApprovalAnswer { approved: false }).await;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user