Menu
AkurAI-Build
publicLatest change 1488f88860de09bbb6791f4c67d3a8a8a3e0765f - Replace the JSON CI CLI with a full read/write akurai-build MCP tool set (repo add/host/sync/rename/remove/visibility/branches/tree, run queue/wait/retry/promote, artifact get, doctor, init); keep keygen/migrate/serve as plain CLI subcommands; update skill and deploy.md to the MCP tool set by Ólafur Búi Ólafsson
#[path = "support/mcp.rs"]
mod support;
use std::{fs, path::Path, process::Command};
use anyhow::{Context, Result, ensure};
use serde_json::{Value, json};
use support::McpSession;
#[test]
#[ignore = "run through ./deploy.sh docker-smoke on a Docker host"]
fn restricted_docker_job_produces_verified_artifact() -> Result<()> {
let temporary = tempfile::tempdir()?;
let repository = temporary.path().join("repository");
let data = temporary.path().join("data");
let key = temporary.path().join("database.key");
fs::create_dir(&repository)?;
git(&repository, &["init", "-b", "main"])?;
git(&repository, &["config", "user.name", "AkurAI Test"])?;
git(
&repository,
&["config", "user.email", "test@example.invalid"],
)?;
fs::write(
repository.join(".akurai.yml"),
"version: 1\njobs:\n - name: build\n image: alpine:3.22\n cache: [cache]\n run: mkdir -p out && printf hit > cache/state && printf container > out/artifact.txt\n artifacts: [out/artifact.txt]\n",
)?;
git(&repository, &["add", ".akurai.yml"])?;
git(&repository, &["commit", "-m", "docker pipeline"])?;
cli(&data, &key, &["keygen", "--out", support::str(&key)?])?;
cli(&data, &key, &["migrate"])?;
let mut mcp = McpSession::start(&data, &key, false)?;
mcp.call(
"akurai_repo_add",
json!({"name": "docker-fixture", "url": support::str(&repository)?, "branch": "main"}),
)?;
let run = mcp.call(
"akurai_run_queue",
json!({"repository": "docker-fixture", "wait": true}),
)?;
ensure!(run["status"] == "succeeded", "Docker run failed: {run}");
let artifact = &run["artifacts"][0];
ensure!(
artifact["sha256"].as_str().is_some(),
"artifact digest missing"
);
Ok(())
}
fn cli(data: &Path, key: &Path, arguments: &[&str]) -> Result<Value> {
let output = Command::new(env!("CARGO_BIN_EXE_akurai"))
.args([
"--data",
support::str(data)?,
"--key-file",
support::str(key)?,
])
.args(arguments)
.output()?;
let value: Value = serde_json::from_slice(&output.stdout).with_context(|| {
format!(
"invalid CLI JSON: {}",
String::from_utf8_lossy(&output.stdout)
)
})?;
ensure!(
output.status.success(),
"CLI failed: {value}\n{}",
String::from_utf8_lossy(&output.stderr)
);
Ok(value)
}
fn git(directory: &Path, arguments: &[&str]) -> Result<()> {
let output = Command::new("git")
.current_dir(directory)
.args(arguments)
.output()?;
ensure!(
output.status.success(),
"git failed: {}",
String::from_utf8_lossy(&output.stderr)
);
Ok(())
}