Skip to content

chore(flagd): generate protobuf modules from a task, not a build - #447

Open
aepfli wants to merge 2 commits into
mainfrom
chore/flagd-protoc-poe-task
Open

aepfli wants to merge 2 commits into
mainfrom
chore/flagd-protoc-poe-task

Conversation

@aepfli

@aepfli aepfli commented Sep 19, 2026

Copy link
Copy Markdown
Member

Closes #446.

Protoc moves out of the build hook into hatch_build_protoc.py, which poe generate-protos runs as the first step of test, test-cov and mypy. The build hook calls the same module, so a checkout still builds from the submodule pin and ships only what it generated. Same split the flagd testkit already uses.

hatch-protobuf is dropped: the protoc invocation is defined once, and the mypy plugins now resolve against the running interpreter instead of an activated PATH. CI no longer runs uv build for every package on every Python version. CONTRIBUTING.md drops the stale hatch build / hatch test instructions.

check result
generated output vs. hatch-protobuf byte-identical, all 20 files
poe mypy clean, 26 files, strict
poe test 784 passed, 273 deselected
uv build wheel built from the sdist, 20 modules in each

uv.lock also carries an unrelated exceptiongroup marker collapse from re-locking with uv 0.11.6.

The protobuf modules existed only as a side effect of `hatch build`, so CI
had to build every package on every Python version to obtain them and a new
contributor had to know to run a build before the tests would import. Build
hooks belong to artifact construction; test inputs do not come from them.

Generation moves into hatch_build_protoc.py, which `poe generate-protos`
runs as the first step of `test`, `test-cov` and `mypy`. The build hook
(hatch_build.py) calls the same module so a checkout still builds from the
submodule pin, and only ships what it generated. hatch-protobuf is dropped:
the protoc invocation is now defined once, in Python, and the mypy plugins
resolve against the running interpreter rather than an activated PATH.

Output is byte-identical to what hatch-protobuf produced.

Signed-off-by: Simon Schrottner <simon.schrottner@flagsmith.com>
@coderabbitai

coderabbitai Bot commented Sep 19, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Files ignored due to path filters: 1
  • uv.lock is excluded by !**/*.lock
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 292afc90-09ab-4126-81fe-ea540de2c3db
Commits

Reviewing files that changed from the base of the PR and between 9f5b0d3 and 87fa15d.

Files ignored due to path filters: 1
  • uv.lock is excluded by !**/*.lock

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 2f2acfae-5618-41ab-83ca-ee52640637cf

📥 Commits

Reviewing files that changed from the base of the PR and between a3ffd2c and 9f5b0d3.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (5)
  • .github/workflows/build.yml
  • CONTRIBUTING.md
  • providers/openfeature-provider-flagd/hatch_build.py
  • providers/openfeature-provider-flagd/hatch_build_protoc.py
  • providers/openfeature-provider-flagd/pyproject.toml
💤 Files with no reviewable changes (1)
  • .github/workflows/build.yml

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

The PR moves flagd protobuf generation from the build hook into an explicit script and Poe task. Tests and type checking generate modules first. The build hook registers generated outputs, and contributor instructions now use poe test.

Changes: Flagd protobuf generation

Layer / File(s) Summary
Protobuf generation and build artifacts
providers/openfeature-provider-flagd/hatch_build_protoc.py, providers/openfeature-provider-flagd/hatch_build.py
The provider generates Python, gRPC, and mypy protobuf modules. The Hatch hook registers generated paths as build artifacts.
Task and build configuration
providers/openfeature-provider-flagd/pyproject.toml, .github/workflows/build.yml
The provider adds generation dependencies and a generate-protos task. Tests, coverage, and mypy run generation first. The workflow no longer runs uv build before validation.
Contributor test workflow
CONTRIBUTING.md
Testing instructions now use poe test and remove the initial hatch build requirement.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Other · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant PoeTask
  participant ProtobufGenerator
  participant Protoc
  PoeTask->>ProtobufGenerator: run generate-protos
  ProtobufGenerator->>Protoc: generate Python, gRPC, and mypy modules
  Protoc-->>ProtobufGenerator: return generated outputs
  ProtobufGenerator-->>PoeTask: continue test or mypy task
Loading

Suggested reviewers: gruebel

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: moving flagd protobuf generation from the build hook into a task.
Description check ✅ Passed The description accurately explains the protobuf generation changes, related build-hook reuse, CI updates, contributor guidance, and validation results.
Linked Issues check ✅ Passed The changes satisfy the coding requirements in issue #446. hatch_build_protoc.py provides reusable generation. The generate-protos task runs before test, test-cov, and mypy. The Hatch build …
Out of Scope Changes check ✅ Passed The reported changes stay within issue #446. They modify protobuf generation, build-hook packaging, CI build steps, dependencies, contributor instructions, and related test-task ordering. These change…
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. (2 skipped: 2 u…
Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@codecov

codecov Bot commented Sep 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.10%. Comparing base (b33d91c) to head (87fa15d).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #447      +/-   ##
==========================================
+ Coverage   95.45%   96.10%   +0.65%     
==========================================
  Files          24       47      +23     
  Lines        1077     1798     +721     
==========================================
+ Hits         1028     1728     +700     
- Misses         49       70      +21     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore(flagd): protobuf modules are only generated by a build

3 participants