Add a Forgejo release source #5
Loading…
Reference in a new issue
No description provided.
Delete branch "worktree-forgejo-source"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
Item 1 of making pkgwatch install itself from its own Forgejo releases: pkgwatch could only track GitHub-hosted projects. This lets a package be checked, fetched and verified against a Forgejo instance's releases API, so
code.austinschaefer.com/schaefera/pkgwatchcan be tracked like any other package.What
Config (
src/config.rs): asourcekey, following the schema already sketched indocs/SPEC.md.github-releaseis the default when omitted, so existingpackages.d/*.tomlfiles are unchanged.forgejo-releasealso requires abase_url. Validation runs once at load and rejects: a Forgejo source with nobase_url, abase_urlon a GitHub source (a mistypedsourcewould otherwise be silently ignored), a URL without http(s), andgithub-attestationon a Forgejo source (ghonly speaks GitHub).Polymorphic release sources, in one module (
src/release_source/): aReleaseSourcetrait (latest_releaseplus the releasesapiroot), with each part in its own file:contract.rs(the trait),github.rs(GithubEndpoints, the existing Atom-feed check, moved unchanged) andforgejo.rs(ForgejoEndpoints, new). The submodules are private andmod.rsre-exports their types, so the rest of the crate imports everything fromcrate::release_sourceand never names a host's file.mod.rsalso holdsfor_package(&Package) -> Result<Box<dyn ReleaseSource>>, the one place that knows which hosts exist. Per-host logic no longer accumulates inchecker.rs, which keeps onlyversion_from_tag, and adding a host doesn't touch the existing ones. Namedrelease_sourcerather thansourcebecausesourcereads like source code next to the config key.Forgejo check: one call to
releases/latest, which already returns only the newest non-draft, non-prerelease release, so it doesn't need GitHub's confirm-each-tag workaround.Fetcher and verifier: take the releases API root instead of a GitHub-specific type. GitHub and Forgejo serve the same
releases/tags/<tag>endpoint and JSON shape, so these needed no per-host logic.Pipeline: the host is resolved per package and passed as
&dyn ReleaseSource; a bad one fails only that package.Docs: the SPEC documents
source, the trait and module, and why the HTTP is hand-rolled rather than using an API-client crate (octocrabis async against our blockingreqwest;forgejo-apiis a generated binding of the whole API for one endpoint; the GitHub check uses an Atom feed no crate covers). Revisit if pkgwatch needs authenticated or write API calls.ARCHITECTURE.mdis updated for the new boundary.Testing
cargo fmt --check,cargo clippy --all-targets -- -D warningsand the complexity lint are clean, andcargo check --releasepasses. 117 tests pass in 20 of 20 runs: config parsing and each validation rule, the factory, both hosts'latest_release(including the Forgejo no-releases 404 and server-error cases), and an end-to-end Forgejo pipeline test that fails verification, proving check, fetch and verify all ran through Forgejo.Also verified against a real Forgejo:
forgejo/forgejooncode.forgejo.org, using scratch dirs. pkgwatch checked, downloaded the 122 MB release binary and passed same-origin sha256 verification (tier 4). That run stopped before build/publish, and predates the trait refactor and module move, which moved code without changing behaviour.Not exercised live: this repo's own
releases/latestcurrently returns 404 because it has no releases yet. The Forgejo source turns that into a clear "no published release found" error, covered by a test.Review
Self-reviews by a single agent: the first found no bugs (docs, wording and a duplicate test helper were addressed), and a second on the trait refactor confirmed the moved code is line-for-line identical with no tests lost. Its remaining nit, naming the implementors
GithubEndpoints/ForgejoEndpointseven though they are now full sources, was left as is to keep the diff small. The later module grouping and rename were pure moves covered by the compiler and the full test suite.Next
Item 2: a Forgejo Actions release workflow that builds the binary and publishes it with
SHA256SUMSon av*tag (the first tag will bev0.1.0, matchingCargo.toml), plus a--versionflag. Then item 3,packages.d/pkgwatch.toml.🤖 Generated with Claude Code
New commits pushed, approval review dismissed automatically according to repository settings