|
| 1 | +# GitLab Setup |
| 2 | + |
| 3 | +This action ships a **GitLab CI/CD Component** that delivers the same |
| 4 | +automated code-review experience as the GitHub action on GitLab merge |
| 5 | +requests (MRs). The component runs on every `merge_request_event` pipeline, |
| 6 | +posts inline comments on the diff, maintains a sticky tracking note, and |
| 7 | +optionally runs a security-focused subagent in parallel. |
| 8 | + |
| 9 | +## Quick start with `/install-code-review` |
| 10 | + |
| 11 | +The fastest path is the guided installer built into the Droid CLI: |
| 12 | + |
| 13 | +```bash |
| 14 | +droid |
| 15 | +> /install-code-review |
| 16 | +``` |
| 17 | + |
| 18 | +It detects GitLab, asks which account should be the poster of review |
| 19 | +comments (you supply its PAT as `GITLAB_TOKEN`), asks the configuration |
| 20 | +questions below, drops `factory/droid-review.yml` in your project, wires |
| 21 | +it into `.gitlab-ci.yml`, and opens an MR / direct-commits to the target |
| 22 | +project(s). |
| 23 | + |
| 24 | +## Manual installation |
| 25 | + |
| 26 | +### 1. Prerequisites |
| 27 | + |
| 28 | +| Requirement | How to get it | |
| 29 | +| ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 30 | +| GitLab Maintainer role on the project | Repo admin grants you Maintainer (40) | |
| 31 | +| `FACTORY_API_KEY` CI/CD variable | Generate at <https://app.factory.ai/settings/api-keys>; add as **masked**, **unprotected** variable at the project, subgroup, or top-level group level | |
| 32 | +| `GITLAB_TOKEN` CI/CD variable | A personal access token with the `api` scope, owned by whichever account should post review comments. The token owner is the poster — there is no API impersonation. Add as **masked**, **unprotected**. | |
| 33 | + |
| 34 | +### 2. Add the CI/CD Component |
| 35 | + |
| 36 | +Drop-in samples live in [`gitlab/examples/`](../gitlab/examples/). The |
| 37 | +layout is two files: |
| 38 | + |
| 39 | +- [`factory/droid-review.yml`](../gitlab/examples/factory/droid-review.yml) — self-contained config (include + inputs + variables). Drop verbatim. |
| 40 | +- [`.gitlab-ci.yml`](../gitlab/examples/.gitlab-ci.yml) — project-root entry point. If you already have one, append the include line below to its `include:` block. |
| 41 | + |
| 42 | +**`factory/droid-review.yml`** (drop into your project): |
| 43 | + |
| 44 | +```yaml |
| 45 | +include: |
| 46 | + - project: "factory-components/droid-action" |
| 47 | + ref: main |
| 48 | + file: "/templates/droid-review.yml" |
| 49 | + inputs: |
| 50 | + automatic_review: "true" |
| 51 | + automatic_security_review: "false" |
| 52 | + review_depth: "deep" |
| 53 | + include_suggestions: "true" |
| 54 | + security_block_on_critical: "true" |
| 55 | + security_block_on_high: "false" |
| 56 | + |
| 57 | +droid-review: |
| 58 | + variables: |
| 59 | + FACTORY_API_KEY: $FACTORY_API_KEY |
| 60 | + GITLAB_TOKEN: $GITLAB_TOKEN |
| 61 | +``` |
| 62 | +
|
| 63 | +**`.gitlab-ci.yml`** (project root, just needs the one include line): |
| 64 | + |
| 65 | +```yaml |
| 66 | +include: |
| 67 | + - local: "factory/droid-review.yml" |
| 68 | +``` |
| 69 | + |
| 70 | +> The remote `include:` URL is pinned to `@main`, which tracks the |
| 71 | +> latest stable cut of droid-action. |
| 72 | + |
| 73 | +### 3. Push an MR |
| 74 | + |
| 75 | +Open or push to an MR. The next `merge_request_event` pipeline will run |
| 76 | +the `droid-review` job. Expect ~5-10 minutes for a typical change. |
| 77 | + |
| 78 | +## Inputs |
| 79 | + |
| 80 | +| Input | Default | Description | |
| 81 | +| ---------------------------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------- | |
| 82 | +| `automatic_review` | `"true"` | Run code review automatically on every MR pipeline. | |
| 83 | +| `automatic_security_review` | `"false"` | Run a parallel security-focused subagent on every MR pipeline. Findings are prefixed `[security]` and posted alongside code-review comments. | |
| 84 | +| `review_depth` | `"deep"` | `"deep"` (thorough) or `"shallow"` (fast). | |
| 85 | +| `review_model` | `""` | Override the model. Empty = use depth preset. | |
| 86 | +| `reasoning_effort` | `""` | Override reasoning effort. Empty = use depth preset. | |
| 87 | +| `include_suggestions` | `"true"` | Include code suggestion blocks in review comments when the fix is high-confidence. | |
| 88 | +| `security_block_on_critical` | `"true"` | Block merge on CRITICAL security findings. (Mirrors GitHub action; surface-level parity.) | |
| 89 | +| `security_block_on_high` | `"false"` | Block merge on HIGH security findings. (Mirrors GitHub action; surface-level parity.) | |
| 90 | +| `settings` | `""` | Droid Exec settings as a JSON string or a path to a JSON file. Merged into `~/.factory/droid/settings.json` before each `droid exec` call. | |
| 91 | + |
| 92 | +## What you get |
| 93 | + |
| 94 | +Each MR pipeline produces: |
| 95 | + |
| 96 | +- **Inline review comments** anchored to the relevant diff lines, posted in a |
| 97 | + single batched `submit_review` call. Findings are prefixed with priority |
| 98 | + tags (`P0`, `P1`, `P2`, `P3`) and `[security]` for security findings. |
| 99 | +- **A sticky tracking note** on the MR with pipeline + job links, telemetry |
| 100 | + (`N turns • Xm Ys`), session IDs, and a security badge when |
| 101 | + `automatic_security_review` is enabled. |
| 102 | +- **Debug artifacts** at `.droid-debug/` (prompts, candidate JSON, raw |
| 103 | + stream-json logs) retained for 1 week. |
| 104 | +- **A custom droid library** copied from |
| 105 | + `$DROID_ACTION_DIR/.factory/droids` into `~/.factory/droids` on the |
| 106 | + runner, so subagents like `security-reviewer` are reachable. |
0 commit comments