Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
33 changes: 31 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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

Expand Down
23 changes: 21 additions & 2 deletions crates/agentflare-artifacts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,23 @@ 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).
let meta_path = store.base_path().join(&id).join("meta.json");
let created_before = store.get(&id).unwrap().created_at - 3600;
let meta = std::fs::read_to_string(&meta_path).unwrap();
let backdated = meta.replace(
&format!("\"created_at\": {}", created_before + 3600),
&format!("\"created_at\": {created_before}"),
);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
assert_ne!(meta, backdated, "created_at not found in {meta_path:?}");
std::fs::write(&meta_path, backdated).unwrap();

let update = PublishRequest {
name: "updated".into(),
artifact_type: ArtifactType::Markdown,
Expand All @@ -88,8 +105,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]
Expand Down
Loading