Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0993f2f36f | |||
| 69c845eabe | |||
| e4f427fa9d |
@@ -0,0 +1,49 @@
|
||||
name: Agents
|
||||
run-name: >-
|
||||
AI bot at
|
||||
#${{ gitea.event.issue.number || gitea.event.pull_request.number }}
|
||||
|
||||
on:
|
||||
issues:
|
||||
types: [opened]
|
||||
pull_request:
|
||||
types: [opened, review_requested]
|
||||
issue_comment:
|
||||
types: [created]
|
||||
pull_request_review_comment:
|
||||
types: [created]
|
||||
|
||||
# New human events replace stale runs for the same work item. AI-bot comments
|
||||
# get unique groups so their skipped workflows cannot cancel an active login.
|
||||
concurrency:
|
||||
group: >-
|
||||
agents-${{ gitea.event.sender.login == 'bot' && gitea.run_id ||
|
||||
gitea.event.issue.number || gitea.event.pull_request.number }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
bot:
|
||||
# Nothing the bot account posts can start a run, so it cannot trigger itself.
|
||||
if: >
|
||||
gitea.event.sender.login != 'bot' &&
|
||||
((gitea.event_name == 'issues' &&
|
||||
contains(gitea.event.issue.body, '@bot')) ||
|
||||
(gitea.event_name == 'pull_request' &&
|
||||
((gitea.event.action == 'opened' &&
|
||||
contains(gitea.event.pull_request.body, '@bot')) ||
|
||||
gitea.event.requested_reviewer.login == 'bot')) ||
|
||||
(gitea.event_name == 'issue_comment' &&
|
||||
contains(gitea.event.comment.body, '@bot')) ||
|
||||
(gitea.event_name == 'pull_request_review_comment' &&
|
||||
contains(gitea.event.review.content, '@bot')))
|
||||
runs-on: self-hosted
|
||||
container:
|
||||
volumes:
|
||||
- bot-home:/root
|
||||
steps:
|
||||
- name: Run AI bot
|
||||
# Intentionally follow protected main so centrally managed profiles and
|
||||
# quota fallbacks update without per-repository credential changes.
|
||||
uses: https://git.capsulizers.com/commons/bot-agents@main
|
||||
with:
|
||||
master-key: ${{ secrets.BOT_AGENTS_MASTER_KEY }}
|
||||
@@ -0,0 +1,51 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [main]
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
concurrency:
|
||||
group: ${{ gitea.workflow }}-${{ gitea.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
checks:
|
||||
runs-on: self-hosted
|
||||
container:
|
||||
volumes:
|
||||
- memona-plugin-target:/cargo-target
|
||||
env:
|
||||
CARGO_BUILD_JOBS: 2
|
||||
CARGO_TARGET_DIR: /cargo-target/serialized
|
||||
CARGO_HOME: /cargo-target/cargo-home
|
||||
RUSTUP_HOME: /cargo-target/rustup-home
|
||||
RUSTUP_TOOLCHAIN: stable
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install system packages
|
||||
run: >-
|
||||
apt-get update && apt-get install -y --no-install-recommends
|
||||
build-essential ca-certificates curl util-linux
|
||||
|
||||
# The same lock protects the shared toolchain and every Cargo command.
|
||||
# Keep its target and lock paths in sync with Memona's plugin checks.
|
||||
- name: Check and build plugin
|
||||
run: |
|
||||
flock --no-fork "$CARGO_TARGET_DIR.lock" sh -ec '
|
||||
export PATH="$CARGO_HOME/bin:$PATH"
|
||||
if [ ! -x "$CARGO_HOME/bin/rustup" ]; then
|
||||
mkdir -p "$CARGO_HOME"
|
||||
curl --proto =https --tlsv1.2 -fsSL https://sh.rustup.rs -o "$CARGO_HOME/rustup-init.sh"
|
||||
sh "$CARGO_HOME/rustup-init.sh" -y --no-modify-path --default-toolchain none
|
||||
rm "$CARGO_HOME/rustup-init.sh"
|
||||
fi
|
||||
rustup toolchain install stable --profile minimal --component clippy,rustfmt --target wasm32-wasip2 --no-self-update
|
||||
cargo fmt --check
|
||||
cargo clippy --locked --all-targets -- -D warnings
|
||||
cargo test --locked --lib
|
||||
cargo build --locked --release --target wasm32-wasip2
|
||||
'
|
||||
Generated
+29
-1
@@ -96,9 +96,10 @@ checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
|
||||
|
||||
[[package]]
|
||||
name = "memona-plugin-ftp"
|
||||
version = "0.1.2"
|
||||
version = "0.1.3"
|
||||
dependencies = [
|
||||
"memona-plugin-sdk",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -108,6 +109,12 @@ dependencies = [
|
||||
"wit-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"
|
||||
|
||||
[[package]]
|
||||
name = "prettyplease"
|
||||
version = "0.3.0"
|
||||
@@ -195,6 +202,27 @@ dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio"
|
||||
version = "1.53.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "202caea871b69668250d242070849eb495be178ed697a3e98aebce5bc81a0bed"
|
||||
dependencies = [
|
||||
"pin-project-lite",
|
||||
"tokio-macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-macros"
|
||||
version = "2.7.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78773a2a397f451582ce068015985c33193cf6dea8b74d2a639fe457b2f07b0e"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.26"
|
||||
|
||||
+4
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "memona-plugin-ftp"
|
||||
version = "0.1.2"
|
||||
version = "0.1.3"
|
||||
edition = "2024"
|
||||
license = "MIT"
|
||||
|
||||
@@ -10,6 +10,9 @@ crate-type = ["cdylib", "rlib"]
|
||||
[dependencies]
|
||||
memona-plugin-sdk = { path = "sdk" }
|
||||
|
||||
[dev-dependencies]
|
||||
tokio = { version = "1", features = ["macros", "rt"] }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
"schemaVersion": 1,
|
||||
"id": "memona/ftp",
|
||||
"name": "FTP",
|
||||
"version": "0.1.2",
|
||||
"version": "0.1.3",
|
||||
"apiVersion": "0.1.0",
|
||||
"description": "Open an FTP server as a folder, and let agents work in it.",
|
||||
"license": "MIT",
|
||||
|
||||
+7
-2
@@ -64,7 +64,9 @@ fn names_a_conflict(text: &str) -> bool {
|
||||
.collect();
|
||||
words.contains(&"exists")
|
||||
|| words.contains(&"nonempty")
|
||||
|| words.windows(2).any(|pair| matches!(pair, ["not" | "non", "empty"]))
|
||||
|| words
|
||||
.windows(2)
|
||||
.any(|pair| matches!(pair, ["not" | "non", "empty"]))
|
||||
}
|
||||
|
||||
/// What the first reply to a transfer command means. A transfer answers with
|
||||
@@ -255,7 +257,10 @@ mod tests {
|
||||
));
|
||||
// The same two conditions as other servers phrase them.
|
||||
assert!(matches!(
|
||||
refusal(550, "550 Cannot create a file when that file already exists."),
|
||||
refusal(
|
||||
550,
|
||||
"550 Cannot create a file when that file already exists."
|
||||
),
|
||||
Err(ErrorCode::Conflict)
|
||||
));
|
||||
assert!(matches!(
|
||||
|
||||
+23
-1
@@ -31,10 +31,11 @@ struct Ftp;
|
||||
|
||||
fn text(setting: Option<&Setting>) -> Option<String> {
|
||||
match setting {
|
||||
Some(Setting::Text(value)) | Some(Setting::Secret(value)) => {
|
||||
Some(Setting::Text(value)) => {
|
||||
let value = value.trim().to_owned();
|
||||
(!value.is_empty()).then_some(value)
|
||||
}
|
||||
Some(Setting::Secret(value)) => Some(value.clone()),
|
||||
Some(Setting::Toggle(_)) | None => None,
|
||||
}
|
||||
}
|
||||
@@ -394,3 +395,24 @@ impl Guest for Ftp {
|
||||
}
|
||||
|
||||
memona_plugin_sdk::export!(Ftp);
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::text;
|
||||
use memona_plugin_sdk::Setting;
|
||||
|
||||
#[tokio::test]
|
||||
async fn secret_credentials_preserve_significant_whitespace() {
|
||||
for password in [" ftp fixture secret ", " ", ""] {
|
||||
assert_eq!(
|
||||
text(Some(&Setting::Secret(password.to_owned()))),
|
||||
Some(password.to_owned())
|
||||
);
|
||||
}
|
||||
assert_eq!(
|
||||
text(Some(&Setting::Text(" server.example ".to_owned()))),
|
||||
Some("server.example".to_owned())
|
||||
);
|
||||
assert_eq!(text(Some(&Setting::Text(" ".to_owned()))), None);
|
||||
}
|
||||
}
|
||||
|
||||
+15
-1
@@ -12,7 +12,6 @@ struct Facts<'a> {
|
||||
|
||||
fn facts(line: &str) -> Option<Facts<'_>> {
|
||||
let (facts, name) = line.split_once(' ')?;
|
||||
let name = name.trim();
|
||||
if name.is_empty() {
|
||||
return None;
|
||||
}
|
||||
@@ -106,6 +105,21 @@ mod tests {
|
||||
use super::{machine_entry, machine_info, page};
|
||||
use memona_plugin_sdk::{EntryKind, ErrorCode};
|
||||
|
||||
#[tokio::test]
|
||||
async fn listing_names_preserve_significant_whitespace()
|
||||
-> Result<(), ErrorCode> {
|
||||
let listing = b"type=file;size=1; report.md \r\ntype=dir; spaced folder \r\ntype=file;size=2; \r\n";
|
||||
let listed = page(listing, 0, 10)?;
|
||||
let names: Vec<&str> = listed
|
||||
.entries
|
||||
.iter()
|
||||
.map(|entry| entry.name.as_str())
|
||||
.collect();
|
||||
assert_eq!(names, [" report.md ", " spaced folder ", " "]);
|
||||
assert!(listed.cursor.is_none());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reads_kind_and_size_and_skips_the_directory_itself()
|
||||
-> Result<(), &'static str> {
|
||||
|
||||
Reference in New Issue
Block a user