refactor: Replace nix codegen with openapi-gen-build #6

Merged
martin merged 2 commits from openapi-gen-build into main 2026-07-30 19:23:34 +00:00
Owner
No description provided.
martin self-assigned this 2026-07-30 18:54:25 +00:00
refactor: Replace nix codegen with openapi-gen-build
Some checks failed
ci/woodpecker/pr/pr-review Pipeline was successful
ci/woodpecker/push/verify Pipeline failed
40966f3a29
Member

Review Summary

This PR transitions my-forge from a manual Nix-based codegen step (just codegennix build .#codegen → artifacts in target/generated/forgejo-client) to an automatic build.rs-driven codegen using openapi-gen-build. The generated code lives at crates/my-forge/src/generated/ and is regenerated on every build. The CI and Nix packaging are updated accordingly.

Positive aspects

  • Cleaner workflow: No manual codegen step needed — cargo build handles everything.
  • Consistent dependency graph: Switching reqwest to rustls (dropping native-tls/openssl-sys) reduces transitive dependencies and build complexity.
  • Good error handling in build.rs: Distinguishes "generator not installed" from other failures with clear panic messages.
  • CI simplification: Removes the separate Nix-based codegen step; the Build step now installs JRE + openapi-generator-cli and builds directly.
  • Cargo config added: .cargo/config.toml properly registers the forgejo sparse registry for openapi-gen-build.

Issues

Two minor maintainability concerns — neither is blocking:

  1. Fragile workspace root path (crates/my-forge/build.rs:8)
  2. Hardcoded CLI version (.woodpecker/verify.yaml:14)

*🤖 Review by opencode (opencode/deepseek-v4-flash-free) — verdict: changes

# Review Summary This PR transitions `my-forge` from a manual Nix-based codegen step (`just codegen` → `nix build .#codegen` → artifacts in `target/generated/forgejo-client`) to an automatic `build.rs`-driven codegen using `openapi-gen-build`. The generated code lives at `crates/my-forge/src/generated/` and is regenerated on every build. The CI and Nix packaging are updated accordingly. ## Positive aspects - **Cleaner workflow**: No manual codegen step needed — `cargo build` handles everything. - **Consistent dependency graph**: Switching reqwest to `rustls` (dropping `native-tls`/`openssl-sys`) reduces transitive dependencies and build complexity. - **Good error handling in build.rs**: Distinguishes "generator not installed" from other failures with clear panic messages. - **CI simplification**: Removes the separate Nix-based codegen step; the Build step now installs JRE + openapi-generator-cli and builds directly. - **Cargo config added**: `.cargo/config.toml` properly registers the forgejo sparse registry for `openapi-gen-build`. ## Issues Two minor maintainability concerns — neither is blocking: 1. **Fragile workspace root path** (`crates/my-forge/build.rs:8`) 2. **Hardcoded CLI version** (`.woodpecker/verify.yaml:14`) --- *🤖 Review by opencode (opencode/deepseek-v4-flash-free) — verdict: **changes**
clank-bot left a comment

Code review findings from opencode.

Code review findings from opencode.
@ -19,3 +12,3 @@
image: docker.io/rust:1.97-bookworm
depends_on: Generate code
commands:
- version=7.23.0
Member

[style] The openapi-generator-cli version 7.23.0 is hardcoded. This will silently drift from the version tested locally. Consider reading the version from a single source (e.g. a .env file, or Cargo.toml metadata), or at least adding a comment noting where to update it.

[style] The openapi-generator-cli version `7.23.0` is hardcoded. This will silently drift from the version tested locally. Consider reading the version from a single source (e.g. a `.env` file, or `Cargo.toml` metadata), 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("../../");
Member

[style] workspace_root is derived via manifest_dir.join("../../"), which breaks if the crate is relocated. Use std::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.

[style] `workspace_root` is derived via `manifest_dir.join("../../")`, which breaks if the crate is relocated. Use `std::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.
ci: Merge steps
All checks were successful
ci/woodpecker/pr/pr-review Pipeline was successful
ci/woodpecker/push/verify Pipeline was successful
cf93bf148a
Member

Review Summary

This PR moves the Forgejo API codegen from a separate Nix derivation (nix/codegen.nix + just codegen) into a build.rs script using the new openapi-gen-build crate. The generated code now lives in crates/my-forge/src/generated/ (gitignored) instead of target/generated/forgejo-client. The forgejo-client external crate is replaced by direct crate dependencies (serde, serde_repr, url, tokio-util, chrono/serde). TLS is switched from native-tls/openssl to rustls (via reqwest's default), simplifying cross-compilation and Nix builds. CI is consolidated into a single Verify step 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

# Review Summary This PR moves the Forgejo API codegen from a separate Nix derivation (`nix/codegen.nix` + `just codegen`) into a `build.rs` script using the new `openapi-gen-build` crate. The generated code now lives in `crates/my-forge/src/generated/` (gitignored) instead of `target/generated/forgejo-client`. The `forgejo-client` external crate is replaced by direct crate dependencies (`serde`, `serde_repr`, `url`, `tokio-util`, `chrono/serde`). TLS is switched from `native-tls`/`openssl` to `rustls` (via `reqwest`'s default), simplifying cross-compilation and Nix builds. CI is consolidated into a single `Verify` step 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**
clank-bot left a comment

Code review findings from opencode.

Code review findings from opencode.
Member

[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_on for faster feedback and clearer failure output.

[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_on` for 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());
Member

[style] Path computation manifest_dir.join("../../") is fragile and assumes the crate is exactly two levels below the workspace root. Using CARGO_WORKSPACE_DIR is unstable; consider iterating parent dirs looking for a workspace Cargo.toml, or at least add a comment documenting the assumed layout.

[style] Path computation `manifest_dir.join("../../")` is fragile and assumes the crate is exactly two levels below the workspace root. Using `CARGO_WORKSPACE_DIR` is unstable; consider iterating parent dirs looking for a workspace `Cargo.toml`, or at least add a comment documenting the assumed layout.
martin merged commit 047f29c96d into main 2026-07-30 19:23:34 +00:00
martin deleted branch openapi-gen-build 2026-07-30 19:23:34 +00:00
Sign in to join this conversation.
No description provided.