summaryrefslogtreecommitdiffstats
path: root/tests/pipeline.rs
Commit message (Collapse)AuthorAgeFilesLines
* comments: say why, not whataur-build12 days1-34/+21
| | | | | | | | | | | | | | Every module-level `//!` header is gone, and the comments that remained either re-explained the line below them or had grown into paragraphs. Density went from one comment line per 6.7 lines of code to one per 10. 827 insertions against 2194 deletions across 86 files. What survived: the invariants (I1-I12), the design cross-references into DESIGN.md, and the notes recording a bug that was found and fixed — those are the comments that carry weight, because they answer a question the code cannot answer about itself. What did not: restating a function signature in prose, and narration of the statement underneath.
* pipeline: replace the devtools chroot with pinned pacman -U provisioningaur-build12 days1-3/+54
| | | | | | | | | | | | | | | | | | | | | | | The chroot step existed to run mkarchroot/makechrootpkg, whose sudo requirement was the whole reason a build had to run on the hub under root-adjacent rules. The sandbox model makes the chroot redundant: the sandbox boots from a base that already carries the official packages, and step 2 now provisions it with a lease manifest instead — every dependency we publish, pinned to the exact version and digest of the artifact the index serves. The hub re-hashes every blob before staging it, installs with pacman -U (no -Sy, no live resolution, no mirror at build time), and the sandbox's own pacman -Q must confirm the pinned world landed before a build may start. A byte that hashes differently, or a world that drifted, fails closed. The build step is now plain makepkg -c -f: no -s (dependencies arrive installed; resolving at build time is what the pinning model forbids) and no -si (ingest signs). mkarchroot/makechrootpkg are gone from the pipeline and the config; their shims stay as stand-ins for the real devtools so the shim protocol itself remains exercised. The shim pacman grew a real fake installed-database: -U refuses bytes that do not hash to the digest their name claims, -Q reports what landed, so the world check is a test and not a no-op.
* pipeline: signing moves from the build step to hub-side ingestaur-build13 days1-0/+33
| | | | | | | | | | | | | The build step used to pass -si<key> through makechrootpkg, which meant whatever machine ran the build had to hold the signing key - fine for a chroot on the hub, disqualifying for a remote sandbox. The build now produces unsigned bytes; ingest signs the exact bytes that entered the store, with the same key and code path that signs the database, and a gpg failure fails the build closed. verify() no longer checks for a build-made signature: the meaningful guarantee moved to 'ingest produced one or the build failed'. The shim makechrootpkg now only emits .sig when -si is passed, like the real tool, so the suite cannot accidentally test a signing path that no longer exists.
* pipeline, db: the correctness minors — fsync, withdrawal, orphans, retry classaur-build13 days1-0/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | m-7. `fsync_file` and `fsync_dir` opened, ignored every error, and returned Ok, in the module whose entire guarantee is "fsync, then rename". A filesystem that refused the sync — full, read-only, a network mount that had dropped — still produced a successful publish whose database might not be on disk. They propagate now, with the path and the cause. m-10. `withdraw_release_in` set `state='withdrawn'` unconditionally, so withdrawing twice reported success the second time while changing nothing, and withdrawing a release that had never been live did the same. The write is a compare-and-swap on `state='published'`, and a refusal names the state that was actually there ("release 1 is withdrawn, not published: nothing to withdraw"). m-16. Artifacts are copied into the served tree before the DB commit, and when the commit refused they stayed: files no index names, sitting in the directory consumers download from. `publish` now tracks which files it created (a file that already existed belongs to the release still being served and is never touched) and removes them if the publish does not land. m-14. `is_transient` treated every `Error::Io` as retryable, which made ENOSPC and EACCES — plain `Io` — into three identical failures and a silent build. Only the kinds that mean "ask again in a moment" retry now. This turned a test that had been asserting the bug: it simulated a transient failure by pointing `makechrootpkg` at a nonexistent path, which is a missing binary, not a flaky network. That test now asserts the opposite (one attempt, no retries), and a new one produces a genuinely transient failure the way production does — a `SKIP` source whose bytes go unreachable after detection, cache dropped, so the `sources` step fails over the fetch path and retries to the cap. m-13. `random_hex` read `/dev/urandom` into a zeroed buffer, ignored every error, and hashed it anyway. Since C-1 the session id is the whole credential, so a failed read is now a refusal: `new_session()` returns `Option`, and the two call sites answer 500 rather than mint a token derivable from the clock and a counter. m-9. The row-error policy is decided and applied: a row that cannot be read fails the query instead of vanishing from the result (six `filter_map(|r| r.ok())` sites, including the reaper's and the claimer's), and `setting_i64` documents its own policy — absent means default, nonsense means default *and a complaint*, because a typo that silently does nothing is worse than a knob that refuses to apply.
* config: the test hooks are a gated submodule, not the production surfaceaur-build13 days1-2/+2
| | | | | | | | | | | | | | | | | | | | | | | Seven fields sat on `Config` next to `signing_key_id` and `bind`: a PATH override, three shim protocol variables, a fault-injection point in the middle of `publish()`, and two more shims could obey. m-9's complaint was not that they exist — the shims are how I4, I5 and I9 are tested for real, and a mock would have asserted the mock's own behaviour — but that nothing said which of these was production and which was scaffolding, and the publish path carried a test branch on every real publish. They are one `TestHooks` submodule now, documented as what it is, and the whole submodule is `#[cfg(feature = "test-support")]` — the same feature that already gates the shims and the raw SQL escape hatch, and which only this crate's own dev-dependency turns on. A production build has no `hooks` field, no shim protocol in `child_env`, and no fault-injection branch in `publish()`; the serialized config skips the section entirely when nothing is hooked, so a real `config.json` never mentions any of it. `TestHooks::is_empty()` names the state a real process runs in, and three tests hold the line: the hook fields may be declared exactly once and only inside `TestHooks`, every `publish_fault` read in `publish.rs` must sit behind the feature gate, and a default config serializes without a trace of hooks.
* db: the review, step, release and subscription states are enums tooaur-build13 days1-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | M-8 named four more machines after `build_state`, and each had the same defect in miniature: `&str` constants, a writer that took any `&str`, and a rule that lived only in the caller's discipline. They are `CandidateState`, `StepState`, `ReleaseState` and `SubscriptionState` now, all parsed through one `db::state_col` at the row boundary — a column value the code cannot name fails the read rather than becoming a state it did not ask for. The one that mattered is the review machine. `resolve_in(tx, id, &str)` would move a candidate to any state from any state, so an approval racing a rejection, or a stale worker resolving a review that had already been superseded, silently overwrote what a human had decided — the direct route to breaking I2 and I3 with no symptom anywhere. It is a compare-and-swap on `CandidateState` now: a decided review is only ever frozen, never re-decided, and a refusal names both states. `supersede_in` goes through it, so the freeze cannot resurrect a superseded review either. `StepState` gives I5 teeth. `begin_step` upserted over any existing checkpoint, including one recorded `succeeded`, so a resume that asked to re-run a finished step could rewrite the very row that told it to skip; the upsert now refuses to touch a done checkpoint and `finish_step` is a CAS. The blocked path (`running → pending`) and the reaper's `running → interrupted` are unchanged, and both are in the table. Two behaviour changes, both for the better and both tested: the UI's pause button now says "orphaned: nothing to pause" instead of rewriting an orphaned subscription back to a pausable state, and a step checkpoint that is already done makes `begin_step` an error rather than a quiet overwrite. Five tests in `tests/state_machine.rs` cover the review CAS in both directions, the frozen checkpoint, the interrupted/blocked transitions, and the unknown value in a candidate and a step row.
* db: the build state machine is an enum, and a state write is a compare-and-swapaur-build13 days1-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `build_state` was seven `&str` constants and `set_state(&str)` would write any string a caller invented, so the machine existed only as `WHERE state IN (...)` clauses scattered across six modules and nothing could say that `succeeded → running` is nonsense. It is `db::model::BuildState` now: parsed where a row is read (a state the code cannot name is an error, not an empty string — which also retires m-12's `current_state` returning `""`), and `set_state` takes the variant and writes only if the row's current state is one of `to`'s legal predecessors. A refused transition writes nothing and says why. Writing the machine down surfaced three things that were true of the flows but of nobody's documentation. The step loop re-asserts `Running` at every step boundary, so a self-write is a no-op and not a move — every state accepts its own name. A failed build is resumed *on its own row* (I5: the step checkpoints say where to continue), so `failed → running` is a real transition. And `builds::retry` — the UI's requeue button — moved any row to `queued` unconditionally, including one that had already published, re-queueing a build whose every step was checkpointed as done; it goes through the machine now and is refused with a reason. `requeue_transient` likewise. What the CAS buys is the zombie case, which no test covered: a worker's lease expires mid-step, the reaper returns the build to the queue, and the original worker — still running — comes back and writes `succeeded` over whatever the new owner has since done. That write now fails loudly and the queue keeps ownership. `builds_for_pkgbase` had a second, hand-copied row mapper that dropped unreadable rows with `filter_map(|r| r.ok())`; it shares `row_to_build` now and a bad row fails the query instead of vanishing from the package page (m-9's policy, applied where it bit). `tests/state_machine.rs` pins the whole table, the zombie refusal, the unknown state, the terminal build that does not move, and the requeue-of-a-published- build refusal. `tests/live.rs` walks a build through `running` before succeeding instead of teleporting it.
* staleness: blocked builds wait properly, and the review answers §10.3 ↵aur-build14 days1-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | before you approve Three real defects, all found while writing the tests that pin §10 down: - **requeue_blocked requeued everything blocked.** The dispatcher sweeps it every pass, so a build waiting on a package that has not arrived was put back on the queue, claimed, blocked again, and repeated — a busy loop burning a claim and a plan step each tick. It now only requeues a build whose every blocking name is actually in the index. The old pipeline test asserted the broken behaviour and has been rewritten to assert the correct one. - **The review page could not warn about missing dependencies, because nothing ever computed them.** candidates::set_missing_deps existed and was never called; missing deps were discovered at plan time, i.e. after a human had already approved. Detection now records them with the same rule the plan step uses, so the reviewer sees 'the build will block until these are published' before deciding, and the CLI and the page agree because both read the row. - **The dependents question was unanswered.** §10.3 asks 'approving this marks N packages stale'. The review page now says exactly that and names them, from the same derivation the Attention page uses. tests/staleness.rs (6 tests) also pins the claims that were easy to fake: staleness is derived on read — a schema scan asserts no column anywhere stores it, and withdrawing a dependency flips a dependent from Outdated to Missing without a single write to the dependent; a blocked build names its blocker on Attention and is not counted as a failure; a dependency we stopped publishing reads as missing rather than outdated. dep-partner added to the corpus so blocked builds are testable end to end. 149 tests pass, clippy clean.
* cli: operator command line with the approval path (§7.2)aur-build14 days1-4/+9
| | | | | | | | | | | | | | | | | aur-build init/subscribe/detect/reviews/show/approve/reject/build/run/ builds/status/packages/audit. approve renders the review and then approves with the hashes it just rendered, so the CLI cannot approve a diff it did not show you; --identity/--diff reproduce the stale case explicitly and a refusal exits 2 (the web equivalent is 409). Approvals are now immutable at the schema level: migration 0006 rejects UPDATE and DELETE on the approval table, because that row is the only proof the system has of what a human actually looked at (§7.2, I10). Publishing also refuses when no approval is reachable, including the manual-rebuild path that inherits one. 10 tests, including two that drive the compiled binary end to end against a file:// AUR fixture.
* pipeline: ten-step build machine with atomic signed publishaur-build2026-11-171-0/+439
materialize -> plan -> chroot -> sources -> pkgver -> build -> collect -> verify -> ingest -> publish, each checkpointed in build_step so a worker that dies resumes at the next incomplete step without repeating the expensive one (I5). Step 0 materializes from the local mirror only and re-hashes the tree: there is no path from 'AUR moved since the review' to 'we built it anyway' (I3). Step 4 re-resolves a VCS pkgver and refuses when it no longer matches the approved identity. Publish renders the index to .tmp, fsyncs, commits release + package rows and the accepted pointer under a compare-and-swap, then renames over the served database and signs it, so a crash leaves the old index byte-for-byte intact (I4) and every index entry traces back to an approval (I1). Ingest records the world snapshot as the BUILDINFO installed set intersected with our own packages, which is what keeps staleness meaningful (I12). 17 shim-driven end-to-end tests, including kill-mid-publish and crash-resume, with no root, network, or real chroot.