Skip to content

ci: harden release workflow and fix flaky test#102

Merged
27Bslash6 merged 3 commits into
mainfrom
fix/ci-workflow-fixes
Apr 30, 2026
Merged

ci: harden release workflow and fix flaky test#102
27Bslash6 merged 3 commits into
mainfrom
fix/ci-workflow-fixes

Conversation

@27Bslash6
Copy link
Copy Markdown
Contributor

@27Bslash6 27Bslash6 commented Apr 29, 2026

Summary

  • Add validate-inputs job that rejects force_release without a valid semver tag (vX.Y.Z) and verifies the tag exists on the remote
  • Route validated tag through job output instead of raw github.event.inputs (prevents script injection)
  • Add explicit if guard on publish job (defense in depth)
  • Wire force_release gate through attest and publish jobs so manual re-releases complete end-to-end
  • Fix flaky test_concurrent_operations — use threading.Barrier for deterministic contention instead of timing-dependent time.sleep

Test plan

  • CI passes on this PR (especially Python 3.13)
  • After merge, re-run 0.6.0 release: gh workflow run release-please.yml --ref main -f force_release=true -f release_tag=v0.6.0
  • Verify force_release=true without release_tag fails fast

Summary by CodeRabbit

Release Notes

This release contains internal test improvements with no user-facing changes. Test reliability enhancements were made to improve code quality assurance processes.

The attest job only checked release_created, so manual
workflow_dispatch with force_release=true would build wheels
then skip attestation and publishing. Now both attest gate
and checkout ref respect the force_release/release_tag inputs.
- Add validate-inputs job that fails fast when force_release=true
  but release_tag is empty (prevents publishing from wrong commit)
- Add explicit if-guard to publish job (defense in depth)
- Wire validate-inputs into build-wheels and build-sdist needs
Use threading.Barrier for simultaneous thread launch and tighter
parameters (capacity=5, 20 workers, work >> timeout) so rejections
are guaranteed by construction, not by timing luck.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 29, 2026

📝 Walkthrough

Walkthrough

A test for concurrent operations was refactored to improve determinism by adjusting controller configuration parameters, introducing thread synchronization via a barrier, and adding explicit error handling for barrier failures.

Changes

Cohort / File(s) Summary
Test Determinism Improvements
tests/unit/test_load_control.py
Modified test_concurrent_operations to reduce timing sensitivity by lowering controller concurrency limits and timeout values, synchronizing 20 worker threads with a barrier, extending permit hold duration to exceed timeout, and adding threading.BrokenBarrierError exception handling. Updated assertions to reflect new semaphore limits.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 Barriers sync when workers dance,
With tightened timeouts and controlled chance,
No flaky tests shall slip past me,
Now deterministic—predictably free! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the two main changes: hardening the CI release workflow and fixing the flaky test with a deterministic barrier approach.
Description check ✅ Passed The description covers key technical details but lacks explicit sections matching the template structure; however, it provides essential context about changes, motivation, and test plan.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ci-workflow-fixes

Review rate limit: 4/5 reviews remaining, refill in 12 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
tests/unit/test_load_control.py (1)

151-152: Reduce magic numbers to avoid future drift in this test.

20 and 2 are duplicated across setup and assertions. If one value changes and another is missed, this test can become brittle or misleading.

Suggested refactor
-        controller = BackpressureController(max_concurrent=2, queue_size=3, timeout=0.01)
+        total_workers = 20
+        controller = BackpressureController(max_concurrent=2, queue_size=3, timeout=0.01)

         results = []
         exceptions = []
-        barrier = threading.Barrier(20, timeout=5)
+        barrier = threading.Barrier(total_workers, timeout=5)

         threads = []
-        for i in range(20):
+        for i in range(total_workers):
             t = threading.Thread(target=worker, args=(i,))
             threads.append(t)
             t.start()
@@
-        assert len(results) + len(exceptions) == 20
+        assert len(results) + len(exceptions) == total_workers
@@
-        assert controller._semaphore._value == 2  # Back to max_concurrent
+        assert controller._semaphore._value == controller.max_concurrent

Also applies to: 158-158, 174-174, 184-184, 188-188

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/unit/test_load_control.py` around lines 151 - 152, Replace hardcoded
numbers with named constants so the test doesn't drift: introduce local
constants (e.g., total_threads, max_workers, queue_len) and use them when
calling max_concurrent(max_workers) and queue_size(queue_len), compute capacity
= max_concurrent(max_workers) + queue_size(queue_len), and use total_threads and
capacity in the assertion that expects rejected == total_threads - capacity (and
in any other places currently using 20 or 2). Update references around
max_concurrent, queue_size, and the capacity calculation so the setup and
assertions derive from the same constants.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tests/unit/test_load_control.py`:
- Around line 151-152: Replace hardcoded numbers with named constants so the
test doesn't drift: introduce local constants (e.g., total_threads, max_workers,
queue_len) and use them when calling max_concurrent(max_workers) and
queue_size(queue_len), compute capacity = max_concurrent(max_workers) +
queue_size(queue_len), and use total_threads and capacity in the assertion that
expects rejected == total_threads - capacity (and in any other places currently
using 20 or 2). Update references around max_concurrent, queue_size, and the
capacity calculation so the setup and assertions derive from the same constants.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: be08f5fb-a16b-4c22-87c7-08f2e768382f

📥 Commits

Reviewing files that changed from the base of the PR and between 5842d30 and b1fed17.

📒 Files selected for processing (1)
  • tests/unit/test_load_control.py

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@27Bslash6 27Bslash6 merged commit 4fb674b into main Apr 30, 2026
32 checks passed
@27Bslash6 27Bslash6 deleted the fix/ci-workflow-fixes branch April 30, 2026 02:56
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.

1 participant