openapi-gen-build #10

Merged
martin merged 9 commits from openapi-gen-build into main 2026-07-25 12:53:15 +00:00
Owner
No description provided.
martin self-assigned this 2026-07-25 12:17:29 +00:00
Member

Review Summary

This PR migrates the workspace from naersk to crane, replaces the generated forgejo-client crate with an api-clients workspace member that uses openapi-generator-cli at build time, and updates CI images.

Critical: cargo build without --workspace in virtual workspace

The root Cargo.toml is a virtual workspace (only [workspace], no [package]). Running cargo build without -p or --workspace will fail with an error. The old command was cargo build --workspace --all-targets --locked.

Security: Unverified download

openapi-generator-cli.jar is fetched from Maven with no checksum verification. A MITM or supply-chain compromise could substitute a malicious JAR.

CI inconsistency: Build and Test steps use different Rust versions

Build pins rust:1.97-bookworm; Test uses rust:1-bookworm (latest stable). If build scripts re-run during cargo test, openapi-generator-cli won't be available in the Test step's container.

Minor: Stale doc comment in core/src/forgejo.rs:72

References forgejo_client::apis::configuration::Configuration which no longer exists.


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

# Review Summary This PR migrates the workspace from naersk to crane, replaces the generated forgejo-client crate with an `api-clients` workspace member that uses openapi-generator-cli at build time, and updates CI images. ## Critical: `cargo build` without `--workspace` in virtual workspace The root `Cargo.toml` is a *virtual* workspace (only `[workspace]`, no `[package]`). Running `cargo build` without `-p` or `--workspace` will fail with an error. The old command was `cargo build --workspace --all-targets --locked`. ## Security: Unverified download `openapi-generator-cli.jar` is fetched from Maven with no checksum verification. A MITM or supply-chain compromise could substitute a malicious JAR. ## CI inconsistency: Build and Test steps use different Rust versions Build pins `rust:1.97-bookworm`; Test uses `rust:1-bookworm` (latest stable). If build scripts re-run during `cargo test`, openapi-generator-cli won't be available in the Test step's container. ## Minor: Stale doc comment in `core/src/forgejo.rs:72` References `forgejo_client::apis::configuration::Configuration` which no longer exists. --- *🤖 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.
@ -25,1 +16,3 @@
- cargo build --workspace --all-targets --locked
- version=7.23.0
- apt-get update -qq && apt-get install -y -qq default-jre-headless
- curl -fsSL --retry 3 https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/$version/openapi-generator-cli-$version.jar -o /usr/local/bin/openapi-generator-cli.jar
Member

[security] JAR downloaded without checksum verification. Add echo '<sha256> <file>' | sha256sum -c or use a pinned Nix derivation to verify integrity.

[security] JAR downloaded without checksum verification. Add `echo '<sha256> <file>' | sha256sum -c` or use a pinned Nix derivation to verify integrity.
@ -26,2 +21,4 @@
- chmod +x /usr/local/bin/openapi-generator-cli
- cargo build
- name: Test
Member

[bug] Test step does not install openapi-generator-cli. If cargo re-runs api-clients/build.rs (which shells out to openapi-generator-cli), the step will fail. Either install it here too or move codegen to its own step persisted via shared workspace.

[bug] Test step does not install openapi-generator-cli. If cargo re-runs `api-clients/build.rs` (which shells out to `openapi-generator-cli`), the step will fail. Either install it here too or move codegen to its own step persisted via shared workspace.
Member

[style] Test step uses rust:1-bookworm (latest) while Build pins rust:1.97-bookworm. Pin both to the same version for reproducible CI.

[style] Test step uses `rust:1-bookworm` (latest) while Build pins `rust:1.97-bookworm`. Pin both to the same version for reproducible CI.
@ -26,0 +19,4 @@
- test -s /usr/local/bin/openapi-generator-cli.jar
- printf '#!/bin/sh\nexec java -jar /usr/local/bin/openapi-generator-cli.jar "$@"\n' > /usr/local/bin/openapi-generator-cli
- chmod +x /usr/local/bin/openapi-generator-cli
- cargo build
Member

[bug] cargo build without --workspace will fail on a virtual workspace (root Cargo.toml has only [workspace], no [package]). Restore --workspace (and --locked to match the requirement in AGENTS.md).

[bug] `cargo build` without `--workspace` will fail on a virtual workspace (root Cargo.toml has only `[workspace]`, no `[package]`). Restore `--workspace` (and `--locked` to match the requirement in AGENTS.md).
Member

[bug] --locked was removed. AGENTS.md states CI runs --locked on every cargo command to detect stale Cargo.lock. Without it, deps can silently drift.

[bug] `--locked` was removed. AGENTS.md states CI runs `--locked` on every cargo command to detect stale Cargo.lock. Without it, deps can silently drift.
@ -71,10 +72,7 @@ pub fn resolve_forgejo_token(settings_forgejo_token: Option<&str>) -> Result<Str
/// Build a [`forgejo_client::apis::configuration::Configuration`] from a base URL
Member

[style] Doc comment still references forgejo_client::apis::configuration::Configuration (the old crate). Update to api_clients::forgejo::apis::configuration::Configuration or just Configuration since it's imported.

[style] Doc comment still references `forgejo_client::apis::configuration::Configuration` (the old crate). Update to `api_clients::forgejo::apis::configuration::Configuration` or just `Configuration` since it's imported.
ci: Use same rust image, build and test all targets, use locked
Some checks failed
ci/woodpecker/pr/pr-review Pipeline was successful
ci/woodpecker/push/verify Pipeline failed
ci/woodpecker/push/verify-nix unknown status
22b42206ae
Member

Review Summary

This PR migrates from naersk to crane, replaces the pre-generated forgejo-client crate with an api-clients crate that generates its code at build time via openapi-gen-build, and switches from native-tls to rustls. The overall direction is good, but there are two issues that would prevent correct evaluation/build and one maintainability concern.

Needs fixing

  1. forgejo-client-gen stale referenceflake.nix still tries to expose forgejo-client-gen = pluginScope.forgejo-client-gen in the packages set (line 158), but genForgejoClient and its pluginScope entry were deleted. This will cause an evaluation error if anyone runs nix build .#forgejo-client-gen or lists flake outputs.

  2. DevShell missing build dependencies — The api-clients build script requires openapi-generator-cli + jre at build time, but the nix develop shell does not provide them. Running cargo build -p forgejo-opencode-review in the dev shell will panic with "openapi-generator-cli is not installed".

Concern

  1. CI/nix version drift for openapi-generator-cli.woodpecker/verify.yaml hardcodes version 7.23.0 while nix builds use whatever nixpkgs ships. Different generator versions can produce different rust code, leading to subtle CI-vs-image inconsistencies.

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

# Review Summary This PR migrates from naersk to crane, replaces the pre-generated forgejo-client crate with an `api-clients` crate that generates its code at build time via `openapi-gen-build`, and switches from native-tls to rustls. The overall direction is good, but there are two issues that would prevent correct evaluation/build and one maintainability concern. ### Needs fixing 1. **`forgejo-client-gen` stale reference** — `flake.nix` still tries to expose `forgejo-client-gen = pluginScope.forgejo-client-gen` in the `packages` set (line 158), but `genForgejoClient` and its `pluginScope` entry were deleted. This will cause an evaluation error if anyone runs `nix build .#forgejo-client-gen` or lists flake outputs. 2. **DevShell missing build dependencies** — The `api-clients` build script requires `openapi-generator-cli` + `jre` at build time, but the `nix develop` shell does not provide them. Running `cargo build -p forgejo-opencode-review` in the dev shell will panic with "openapi-generator-cli is not installed". ### Concern 3. **CI/nix version drift for openapi-generator-cli** — `.woodpecker/verify.yaml` hardcodes version `7.23.0` while nix builds use whatever nixpkgs ships. Different generator versions can produce different rust code, leading to subtle CI-vs-image inconsistencies. --- *🤖 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.
@ -23,2 +14,3 @@
depends_on: Generate code
image: docker.io/rust:1.97-bookworm
commands:
- version=7.23.0
Member

[style] openapi-generator-cli version 7.23.0 is hardcoded here but comes from nixpkgs in nix builds. A version mismatch can produce different generated rust code. Consider pulling the version from a single source (e.g., a file nix and the CI script both read).

[style] openapi-generator-cli version `7.23.0` is hardcoded here but comes from nixpkgs in nix builds. A version mismatch can produce different generated rust code. Consider pulling the version from a single source (e.g., a file nix and the CI script both read).
@ -163,3 +161,1 @@
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
rustToolchain
devShells.default = rustPlatform.devShell {
Member

[bug] DevShell must include openapi-generator-cli and jre (or jdk_headless). The api-clients/build.rs panics if the CLI isn't found, so cargo build -p forgejo-opencode-review fails in nix develop.

[bug] DevShell must include `openapi-generator-cli` and `jre` (or `jdk_headless`). The `api-clients/build.rs` panics if the CLI isn't found, so `cargo build -p forgejo-opencode-review` fails in `nix develop`.
flake.nix Outdated
@ -160,9 +158,8 @@
forgejo-client-gen = pluginScope.forgejo-client-gen;
Member

[bug] Stale reference: forgejo-client-gen = pluginScope.forgejo-client-gen; but genForgejoClient was removed from the scope. This will fail at evaluation for .#forgejo-client-gen or nix flake show. Remove this line.

[bug] Stale reference: `forgejo-client-gen = pluginScope.forgejo-client-gen;` but `genForgejoClient` was removed from the scope. This will fail at evaluation for `.#forgejo-client-gen` or `nix flake show`. Remove this line.
ci: Merge steps in verify
Some checks failed
ci/woodpecker/pr/pr-review Pipeline was canceled
ci/woodpecker/push/verify Pipeline was successful
ci/woodpecker/push/verify-nix Pipeline was successful
48d9576a63
Member

Review Summary

This PR migrates the Nix build system from naersk to crane, replaces the pre-generated forgejo-client crate with a build-script-generated api-clients crate, simplifies the CI pipeline, and updates various configuration files accordingly.

The structural changes are sound and follow workspace conventions. The CI now installs openapi-generator-cli directly via curl instead of relying on Nix for codegen, and all verify steps run in a single container.

Key concerns:

  1. The openapi-generator-cli JAR is downloaded without checksum verification — previously Nix provided hash-verified downloads.
  2. #[path] in api-clients/src/lib.rs points outside the crate directory, which is fragile and may confuse tooling.
  3. Merging all verify steps into one reduces operational visibility (no per-step failure granularity).

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

# Review Summary This PR migrates the Nix build system from naersk to crane, replaces the pre-generated `forgejo-client` crate with a build-script-generated `api-clients` crate, simplifies the CI pipeline, and updates various configuration files accordingly. The structural changes are sound and follow workspace conventions. The CI now installs `openapi-generator-cli` directly via curl instead of relying on Nix for codegen, and all verify steps run in a single container. Key concerns: 1. The openapi-generator-cli JAR is downloaded without checksum verification — previously Nix provided hash-verified downloads. 2. `#[path]` in `api-clients/src/lib.rs` points outside the crate directory, which is fragile and may confuse tooling. 3. Merging all verify steps into one reduces operational visibility (no per-step failure granularity). --- *🤖 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.
Member

[style] Combining cargo build, cargo test, and clippy into a single step loses per-stage failure visibility in the Woodpecker UI. If CI cost is a concern, consider keeping them as separate steps with depends_on to preserve operational clarity while maintaining the same overall execution order.

[style] Combining `cargo build`, `cargo test`, and `clippy` into a single step loses per-stage failure visibility in the Woodpecker UI. If CI cost is a concern, consider keeping them as separate steps with `depends_on` to preserve operational clarity while maintaining the same overall execution order.
Member

[security] openapi-generator-cli JAR is downloaded without checksum verification (curl -fsSL --retry 3 ... with only test -s as validation). The previous Nix pipeline implicitly verified hashes via nixpkgs. Add a checksum check (e.g. download a .sha256 or .asc alongside the JAR, or hardcode the expected SHA-256) to prevent supply-chain attacks via MITM.

[security] openapi-generator-cli JAR is downloaded without checksum verification (`curl -fsSL --retry 3 ...` with only `test -s` as validation). The previous Nix pipeline implicitly verified hashes via nixpkgs. Add a checksum check (e.g. download a `.sha256` or `.asc` alongside the JAR, or hardcode the expected SHA-256) to prevent supply-chain attacks via MITM.
@ -0,0 +1,6 @@
#![allow(unused_imports)]
#[path = "../../target/generated/api-clients/generated/mod.rs"]
pub mod generated;
Member

[style] #[path = "../../target/generated/api-clients/generated/mod.rs"] points outside the crate's directory tree. This ties the crate to a workspace-level target/ layout and rust-analyzer/IDE tooling may fail to resolve the module. Consider using a include! macro or generating the file under api-clients/src/ instead.

[style] `#[path = "../../target/generated/api-clients/generated/mod.rs"]` points outside the crate's directory tree. This ties the crate to a workspace-level `target/` layout and `rust-analyzer`/IDE tooling may fail to resolve the module. Consider using a `include!` macro or generating the file under `api-clients/src/` instead.
martin merged commit 37a2c8fd2c into main 2026-07-25 12:53:15 +00:00
martin deleted branch openapi-gen-build 2026-07-25 12:53:15 +00:00
martin referenced this pull request from a commit 2026-07-25 12:53:16 +00:00
Sign in to join this conversation.
No description provided.