← Back to Pull requests

Deploy AWS Device Farm Lambda orchestrator with OpenTofu #31

Closed
unknown closed this pull request without merging on Nov 25, 2026 01:52 UTC
View on GitHub
unknown unknown commented on Nov 24, 2026 19:02 UTC
Author

Running Android hardware tests for maplibre/mln-rs via GitHub Actions watcher workflows requires long-lived polling jobs and exposes AWS credential wiring in repository workflows. Moving orchestration into AWS Lambda behind a GitHub App lets untrusted fork PRs run safely on AWS Device Farm and report results natively via a GitHub Check Run (device-test / android), without executing untrusted PR code inside Lambda or keeping CI runners occupied while waiting on phones.

Summary


  • Go Lambda service (device-farm/): single static linux/arm64 binary (provided.al2023, bootstrap) dispatched via MODE:

  • - webhook: verifies X-Hub-Signature-256, filters configured repos (maplibre/mln-rs, structured so maplibre/maplibre-native can be added as a config entry) and optional ALLOWED_BRANCHES, enqueues onto SQS, and returns 202 Accepted.
    - worker: manages the device-test / android Check Run lifecycle (including workflow_run safety-net settling and check_run rerequested reruns), stops/supersedes older active runs on the same (repo, head_repo, head_branch), downloads android-device-tests without forwarding GitHub Authorization headers on redirect, extracts android-tests.zip without unpacking or executing its contents, fetches tools/device-farm/android.yml exclusively from main, uploads to Device Farm, and schedules runs on Pixel 9 and Galaxy S25.
    - poller: polls active runs every minute from DynamoDB state-index, collects TESTSPEC_OUTPUT.txt and CUSTOMER_ARTIFACT.zip, parses bounded junit.xml (falling back to the last 40 output lines), uploads results to private S3 with Content-Disposition: attachment, and settles the Check Run with Markdown summaries and sandboxed CloudFront links.
  • OpenTofu stack (opentofu/device-farm/): independent root in us-west-2 using the shared S3 state bucket, with Secrets Manager secret shell, DynamoDB table + GSIs + TTL, SQS queue + DLQ, private S3 bucket (30-day expiry) + CloudFront OAC (Content-Security-Policy: sandbox, X-Content-Type-Options: nosniff), least-privilege per-Lambda IAM roles, CloudWatch log retention, and EventBridge schedule.

  • Tooling & docs: wired device-farm into the root justfile, updated opentofu/README.md, and documented setup, branch-gated evaluation (allowed_branches), cutover, and onboarding additional repositories in device-farm/README.md.
  • Verification


  • go vet ./... and go test -count=1 -race ./... pass across all packages.

  • just device-farm::build produces a statically linked ARM aarch64 bootstrap binary packaged in bootstrap.zip.

  • tofu fmt -check -recursive opentofu and tofu -chdir=opentofu/device-farm init -backend=false && tofu -chdir=opentofu/device-farm validate pass with zero warnings.

  • No live AWS resources were modified (tofu apply was not run).
  • Created with gemini-4-neon in T3 Code.

    Diff: 363 lines (+272 / -91) across 4 files Reviewer: louwers Review duration: 410m
    All Vouch review confidence checks passed
    Residual risk 0.26 = Change Risk (0.66) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.66 · 363 lines diff across 4 files
    0.66
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.353
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.066
    Real PR Conversation Timeline
    1 comments
    "Review active on #31"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 65.8% (HIGH) · Higher = larger blast radius
    65.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 26% · Safe to merge
    26%
    Repository