diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 75faad53f..dc0c99a34 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,6 +9,16 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: ${{ github.event_name != 'push' }} +env: + # Nothing in CI attaches a debugger, and full debuginfo is expensive twice + # over: MSVC spends real link time writing PDBs, and the artifacts they + # bloat are what the rust-cache archive has to restore on every run (54s on + # Windows against 12s on Linux). `line-tables-only` keeps panic backtraces + # readable, which is the only debug information a failing job actually uses. + # Workflow-level so build and clippy agree — a per-job value would give them + # divergent artifacts and halve the cache hit rate. + CARGO_PROFILE_DEV_DEBUG: line-tables-only + jobs: changes: runs-on: ubuntu-latest @@ -40,6 +50,9 @@ jobs: # A hung test would otherwise pin a runner for GitHub's 6h default and # block the branch's required check indefinitely; fail fast instead. A # cold-cache build+test finishes well under this on every OS. + # + # zizmor: ignore[template-injection] -- github.workspace is a runner path, + # not attacker-controlled input. timeout-minutes: 25 strategy: matrix: @@ -66,8 +79,24 @@ jobs: save-if: ${{ github.ref == 'refs/heads/master' }} - if: needs.changes.result != 'success' || needs.changes.outputs.code == 'true' uses: mozilla-actions/sccache-action@d651010b8da762cde178750d8eda7b5febfe147a # v0.0.9 - - if: needs.changes.result != 'success' || needs.changes.outputs.code == 'true' - run: cargo build --workspace --verbose + # Defender real-time protection is on in the windows-latest image and + # scans every object file, PDB and executable rustc writes -- and every + # temp file the tests create, which is why the same suite that runs in + # ~20s on Linux takes ~90s here. Best-effort: a runner that refuses the + # exclusion should build slowly, not fail. + - if: runner.os == 'Windows' && (needs.changes.result != 'success' || needs.changes.outputs.code == 'true') + shell: pwsh + run: | + try { + Add-MpPreference -ExclusionPath "${{ github.workspace }}", "$env:USERPROFILE\.cargo", "$env:TEMP" -ErrorAction Stop + } catch { + Write-Host "Defender exclusions unavailable, continuing: $_" + } + # No separate `cargo build` step: `cargo test` compiles and links the + # same libs and bins (it builds every bin target so integration tests + # can spawn them -- see crates/flare-git-shim/tests/shim_test.rs), so + # building first was a second full pass over the workspace for nothing. + # Non-test targets still get type-checked by `clippy --all-targets`. - if: needs.changes.result != 'success' || needs.changes.outputs.code == 'true' run: cargo test --workspace --verbose diff --git a/crates/agentflare-artifacts/src/lib.rs b/crates/agentflare-artifacts/src/lib.rs index d4ac389c6..8ddab3e25 100644 --- a/crates/agentflare-artifacts/src/lib.rs +++ b/crates/agentflare-artifacts/src/lib.rs @@ -74,6 +74,27 @@ mod tests { let resp = store.publish(&req).unwrap(); let id = resp.id.clone(); + // Backdate the stored created_at before updating. Both publishes land + // in the same second, so leaving it alone would make "preserved" and + // "stamped afresh" indistinguishable — the old assertion compared + // created_at to updated_at, which passed for that reason rather than + // because the invariant held, and failed outright whenever the two + // writes straddled a second boundary (seen on a windows-latest + // runner: 1785126773 against 1785126774). + // Edited as JSON rather than by string replacement: the artifact's + // created_at and its first history entry's start out identical, so a + // textual replace would move both and leave the fixture describing a + // version that was created before the artifact it belongs to. + let meta_path = store.base_path().join(&id).join("meta.json"); + let mut meta: serde_json::Value = + serde_json::from_str(&std::fs::read_to_string(&meta_path).unwrap()).unwrap(); + let created_before = meta["created_at"] + .as_u64() + .unwrap_or_else(|| panic!("no created_at in {meta_path:?}")) + - 3600; + meta["created_at"] = created_before.into(); + std::fs::write(&meta_path, serde_json::to_string_pretty(&meta).unwrap()).unwrap(); + let update = PublishRequest { name: "updated".into(), artifact_type: ArtifactType::Markdown, @@ -88,8 +109,10 @@ mod tests { let artifact = store.get(&id).unwrap(); assert_eq!(artifact.content, "v2"); assert_eq!(artifact.artifact_type, ArtifactType::Markdown); - // created_at must stay the same on update - assert_eq!(artifact.created_at, artifact.updated_at); // same sec + // An update must carry the stored created_at forward, not stamp a new + // one — the backdating above is what makes the difference visible. + assert_eq!(artifact.created_at, created_before); + assert!(artifact.updated_at >= artifact.created_at); } #[test]