refactor: Replace nix codegen with openapi-gen-build #6
No reviewers
Labels
No labels
automerge
bug
dependencies
duplicate
enhancement
help wanted
invalid
migrations
question
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Personal/my-cli!6
Loading…
Reference in a new issue
No description provided.
Delete branch "openapi-gen-build"
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?
Review Summary
This PR transitions
my-forgefrom a manual Nix-based codegen step (just codegen→nix build .#codegen→ artifacts intarget/generated/forgejo-client) to an automaticbuild.rs-driven codegen usingopenapi-gen-build. The generated code lives atcrates/my-forge/src/generated/and is regenerated on every build. The CI and Nix packaging are updated accordingly.Positive aspects
cargo buildhandles everything.rustls(droppingnative-tls/openssl-sys) reduces transitive dependencies and build complexity..cargo/config.tomlproperly registers the forgejo sparse registry foropenapi-gen-build.Issues
Two minor maintainability concerns — neither is blocking:
crates/my-forge/build.rs:8).woodpecker/verify.yaml:14)*🤖 Review by opencode (opencode/deepseek-v4-flash-free) — verdict: changes
Code review findings from opencode.
@ -19,3 +12,3 @@image: docker.io/rust:1.97-bookwormdepends_on: Generate codecommands:- version=7.23.0[style] The openapi-generator-cli version
7.23.0is hardcoded. This will silently drift from the version tested locally. Consider reading the version from a single source (e.g. a.envfile, orCargo.tomlmetadata), or at least adding a comment noting where to update it.@ -0,0 +5,4 @@use openapi_gen_build::Error;let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());let workspace_root = manifest_dir.join("../../");[style]
workspace_rootis derived viamanifest_dir.join("../../"), which breaks if the crate is relocated. Usestd::env::var("CARGO_WORKSPACE_DIR")instead — it is available in build scripts since Rust 1.64 and is the canonical way to locate the workspace root.Review Summary
This PR moves the Forgejo API codegen from a separate Nix derivation (
nix/codegen.nix+just codegen) into abuild.rsscript using the newopenapi-gen-buildcrate. The generated code now lives incrates/my-forge/src/generated/(gitignored) instead oftarget/generated/forgejo-client. Theforgejo-clientexternal crate is replaced by direct crate dependencies (serde,serde_repr,url,tokio-util,chrono/serde). TLS is switched fromnative-tls/openssltorustls(viareqwest's default), simplifying cross-compilation and Nix builds. CI is consolidated into a singleVerifystep that installs JRE/openapi-generator-cli, builds, clippys, and tests. Overall the direction is correct and the changes are well-executed.Verdict: Approve — two minor comments below.
*🤖 Review by opencode (opencode/deepseek-v4-flash-free) — verdict: approve
Code review findings from opencode.
[performance] Consolidating Build, Clippy, and Test into a single serial step loses parallelism. Previously Clippy and Test ran in parallel after Build; now they run sequentially. Consider splitting back into named steps with
depends_onfor faster feedback and clearer failure output.@ -0,0 +3,4 @@use openapi_gen_build::Error;let manifest_dir = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap());[style] Path computation
manifest_dir.join("../../")is fragile and assumes the crate is exactly two levels below the workspace root. UsingCARGO_WORKSPACE_DIRis unstable; consider iterating parent dirs looking for a workspaceCargo.toml, or at least add a comment documenting the assumed layout.