Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/PYTHON_TEST_DISPOSITION.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ gain tests; it does not move down.
| test_check_rust_version.py | retired | `scripts/check_rust_version.py`. A Python lint over the engine toolchain pin. |
| test_check_workflow_policy.py | retired | `scripts/check_workflow_policy.py` over GitHub workflow YAML. CI policy, not product behaviour. |
| test_checks.py | ported | CI-revision reads in the collectors and the project brief. |
| test_ci_watch.py | ported | Watched-ref and deployed-version reads in `application/deployed.rs`. |
| test_ci_watch.py | ported | Watched-ref and deployed-version reads are in `application/deployed.rs`. The bound-branch announce is in `application/ci_watch.rs`: the feed event once per conclusion, staleness, the notice text, and the session nudge (notice, then Enter; none at a permission prompt). `test_a_sweep_announces_and_survives_an_announce_failure` is `a_failed_announce_does_not_fail_the_sweep` in `application/collect.rs`, driven by the `ci_watch::seam` failure switch. |
| test_claude_profile.py | unported | Claude Code account profiles and their bootstrap. Named accounts land on `session.start` in WI-1306 (triage row 7782a7e8, under WI-1074). |
| test_cli.py | ported | `adapters/cli.rs`. |
| test_clone.py | ported | Clone service under `application/services`. |
Expand Down
39 changes: 39 additions & 0 deletions engine/core/src/adapters/forge/lanes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
//! whose source cannot be read records *why* in its observation rather than
//! failing the sweep, so "not readable" never reads as "not deployed".

use std::io::Read;
use std::time::Duration;

use serde_json::{Map, Value};

use super::kinds::{COLLECTOR_DEPLOY_LANES, KIND_DEPLOY_LANE};
Expand All @@ -33,6 +36,42 @@ pub trait VersionFetch {
fn get(&self, url: &str) -> Result<(u16, Vec<u8>), String>;
}

/// The real fetch: one GET with the collector's ten-second timeout, reading at
/// most 64 KiB. An error status answers with an empty body, as Python does.
pub struct HttpVersionFetch;

const VERSION_TIMEOUT: Duration = Duration::from_secs(10);
const VERSION_BODY_CAP: u64 = 65_536;

impl VersionFetch for HttpVersionFetch {
fn get(&self, url: &str) -> Result<(u16, Vec<u8>), String> {
if !(url.starts_with("https://") || url.starts_with("http://")) {
return Err("version_url must be http(s)".to_owned());
}
let agent = ureq::AgentBuilder::new().timeout(VERSION_TIMEOUT).build();
let request = agent
.get(url)
.set("Accept", "application/json")
.set("User-Agent", "vogt-deploy-lanes");
match request.call() {
Ok(response) => read_capped(response),
Err(ureq::Error::Status(status, _)) => Ok((status, Vec::new())),
Err(error) => Err(error.to_string()),
}
}
}

fn read_capped(response: ureq::Response) -> Result<(u16, Vec<u8>), String> {
let status = response.status();
let mut bytes = Vec::new();
response
.into_reader()
.take(VERSION_BODY_CAP)
.read_to_end(&mut bytes)
.map_err(|error| error.to_string())?;
Ok((status, bytes))
}

/// One observation per configured deployment lane of a project.
pub struct DeployLanesCollector<'a> {
directory: &'a dyn ForgeDirectory,
Expand Down
7 changes: 4 additions & 3 deletions engine/core/src/adapters/forge/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ pub use collectors::{
pub use directory::ForgeClients;
pub use github::repo_of;
pub use kinds::{
current_collector, COLLECTOR_CHECKS, COLLECTOR_ISSUES, COLLECTOR_NOTIFICATIONS,
COLLECTOR_PULLS, KIND_CHECK, KIND_DEPLOY_LANE, KIND_ISSUE, KIND_LABEL, KIND_NOTIFICATION,
KIND_PULL_REQUEST, KIND_RELEASE,
current_collector, COLLECTOR_CHECKS, COLLECTOR_DEPLOY_LANES, COLLECTOR_ISSUES,
COLLECTOR_NOTIFICATIONS, COLLECTOR_PULLS, KIND_CHECK, KIND_DEPLOY_LANE, KIND_ISSUE, KIND_LABEL,
KIND_NOTIFICATION, KIND_PULL_REQUEST, KIND_RELEASE,
};
pub use lanes::{DeployLanesCollector, HttpVersionFetch};
pub use models::RepoRef;
pub use provider::ForgeProvider;
pub use registry::has_configured_forge;
Expand Down
Loading
Loading