Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .factory/review.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Factory review configuration, read from the repository's default branch,
# never from the pull request itself. Factory's PR risk assessment reads
# `rules`; Droid Auto Review leaves that key to Factory.
rules:
# Every pull request is assessed and gets a risk comment. The Droid App may
# approve a pull request whose overall risk is minimal or low; one rated
# medium or high waits for a human. Setting approve_pr: false stops every
# approval and keeps the comments (shadow mode).
- risk_assessment:
approve_risk_level: low
72 changes: 68 additions & 4 deletions .github/workflows/droid-review.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,97 @@
name: Droid Auto Review

# Reviews each ready pull request once, then runs Factory's PR risk
# assessment in the same job, so the assessment sees how the review ended
# and the review threads it left. Factory decides whether each run skips,
# holds, or judges, and writes the risk comment and any approval as the Droid
# GitHub App. This workflow holds no credential that can approve.
#
# Factory accepts risk reports only from this file as it is on the default
# branch, so edits to it take effect after merge. .factory/review.yaml caps
# the Droid App's approvals at low overall risk (approve_risk_level: low).
#
# Every push runs the risk step, which reassesses the new head once every
# Droid review thread is resolved. Drafts run only the risk step, which
# withdraws approvals of older commits. Reassess a pull request by hand with
# `gh workflow run droid-review.yml -f pr_number=<n>`; a dispatch from a branch
# other than the default one is a dry run that never approves.
#
# pull_request, never pull_request_target: a run for a fork's pull request
# gets no secrets and no OIDC token, so it cannot ask Factory for anything.
on:
pull_request:
types: [opened, ready_for_review, reopened]
types: [opened, synchronize, ready_for_review, reopened]
workflow_dispatch:
inputs:
pr_number:
description: Pull request number to reassess
required: true
type: number

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
# One run per pull request. A review event (opened, reopened,
# ready_for_review) cancels the run in progress, because its own risk step
# covers the new head. A push never cancels: it waits for the run in
# progress, so a review still running posts its threads before the push's
# risk step reads them, and a newer push replaces one that is still
# waiting. A risk dispatch has its own group so it never cancels a review
# in flight. Draft events have theirs because GitHub starts queued runs in
# arbitrary order: a delayed draft run must not cancel the ready_for_review
# run.
group: ${{ github.workflow }}-${{ github.event.pull_request.number || (inputs.pr_number && format('risk-{0}', inputs.pr_number)) || github.ref }}${{ github.event.pull_request.draft && '-draft' || '' }}
cancel-in-progress: ${{ github.event.action != 'synchronize' }}

jobs:
droid-review:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
# The review takes up to 30 minutes and the risk judge up to 20 more.
timeout-minutes: 60
permissions:
contents: write
pull-requests: write
issues: write
# Proves to Factory which repository and workflow file is asking, and
# is exchanged for the Droid App token the review and the judge use.
id-token: write
actions: read
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
fetch-depth: 1
persist-credentials: false

- name: Run Droid Auto Review
id: review
if: >-
github.event_name == 'pull_request' &&
github.event.action != 'synchronize' &&
github.event.pull_request.draft == false
uses: Factory-AI/droid-action@main
with:
factory_api_key: ${{ secrets.FACTORY_API_KEY }}
automatic_review: true
automatic_security_review: true
allowed_bots: "dependabot,factory-droid"

# Runs after a failed or skipped review too, so Factory can hold the
# assessment and still withdraw approvals of older commits. A cancelled
# run leaves the pull request to the run that replaced it. A fork's run
# has no OIDC token, so the step would only fail there; a dispatch for
# a fork's pull request runs here and Factory skips it as a fork.
# The risk sub-action exists only on droid-action's dev-internal branch
# and tracks the backend deployed at staging.api.factory.ai (Factory's
# production deployment of factory-mono's dev branch), so it is left
# unpinned.
- name: Run Risk Assessment
if: >-
!cancelled() &&
(github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository)
uses: Factory-AI/droid-action/risk@dev-internal
with:
factory_api_key: ${{ secrets.FACTORY_API_KEY }}
pr_number: ${{ inputs.pr_number }}
review_outcome: ${{ steps.review.outcome }}
api_base_url: https://staging.api.factory.ai
dry_run: ${{ github.event_name == 'workflow_dispatch' && github.ref_name != github.event.repository.default_branch }}
Loading