Repository navigation
test: monitor Cloudflare endpoint contract - #5
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe PR adds a scheduled and manually triggered Cloudflare live contract test. It also tracks client-timing fallbacks separately from latency measurement failures and reports them during loaded and unloaded measurements. ChangesLatency fallback reporting
Cloudflare live contract validation
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant CloudflareContractWorkflow
participant TestCloudflareLiveContract
participant CloudflareEndpoints
CloudflareContractWorkflow->>TestCloudflareLiveContract: run live contract test
TestCloudflareLiveContract->>CloudflareEndpoints: request download, upload, and metadata endpoints
CloudflareEndpoints-->>TestCloudflareLiveContract: return HTTP responses and metadata
TestCloudflareLiveContract-->>CloudflareContractWorkflow: report contract assertions
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
.github/workflows/cloudflare-contract.yml (1)
16-17: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick winDisable persisted checkout credentials.
Set
persist-credentials: falseonactions/checkout@v4. Thego teststep does not need Git credentials, so this prevents it from accessing the workflow token.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/cloudflare-contract.yml around lines 16 - 17, Update the actions/checkout@v4 step to set persist-credentials to false, ensuring the subsequent go test step cannot access persisted GitHub workflow credentials.Source: Linters/SAST tools
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/cloudflare/measure.go`:
- Around line 67-69: Resolve the nilerr lint warning in the ParseServerTiming
error branch without changing its non-fatal client-timing fallback behavior:
either add a narrowly scoped nolint:nilerr annotation with a reason or
restructure the branch so successful parsing proceeds normally and errors fall
through to the existing fallback. Keep the return values and surrounding measure
logic unchanged.
---
Nitpick comments:
In @.github/workflows/cloudflare-contract.yml:
- Around line 16-17: Update the actions/checkout@v4 step to set
persist-credentials to false, ensuring the subsequent go test step cannot access
persisted GitHub workflow credentials.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: cc88e578-a617-4a6c-8049-cb26cde1ec3f
📒 Files selected for processing (4)
.github/workflows/cloudflare-contract.ymlinternal/cloudflare/contract_live_test.gointernal/cloudflare/measure.gointernal/cloudflare/upload_test.go
9d8b724 to
0ec648a
Compare
Summary
__down,__up, and/meta.warningsinstead of silently degrading.Why
Cloudflare's public speed-test response shape can change independently of this repository. The normal unit tests use mocked HTTP responses and cannot detect that drift. This stacked PR adds an external contract check without making ordinary PR CI depend on the public service.
Runtime behavior
Missing
cfRequestDurationremains non-fatal. The CLI uses client timing and reports the fallback count in JSON warnings, while the live contract job alerts us to changes in response status, body size, upload acknowledgement, metadata fields, and key response headers.Validation
go test ./...(70 tests passed)go test -count=1 -tags=cloudflare_live ./internal/cloudflare -run '^TestCloudflareLiveContract$' -v(4 tests passed)go vet ./...go mod verifygo build -trimpath -ldflags='-s -w' -o dist/unispeedtest ./cmd/unispeedtest-jsonrun completed with positive upload throughput and JSON-only stdout.Stack
This PR targets
agent/fix-upload-speed-measurementand should be merged after the parent fix PR.Summary by CodeRabbit
Bug Fixes
Tests