Pull Request Reviews


Pull Request Reviews provide a comparison of a Site monitored in Calibre and a preview deployment. You can use Pull Request reviews to compare between a branch and your live Site, before changes are merged.

Each Pull Request Review tests preview deployments using the same conditions as your Site. This includes the same test location, authentication, headers, cookies, Test Profiles, and Pages. You can override authentication, headers, and cookies if needed.

Prerequisites

Each deployment must have a unique hostname (e.g.: my-preview-url-123.example.com in order to use Pull Request reviews.

Create a Pull Request Review

Required API Permission: Read Sites, Start Pull Request Reviews
1# This command will:
2# - Block until performance tests have been completed (`--waitForResult`)
3# - Return a failure if this PR fails specified performance budgets (`--failOnUnmetBudget`)
4# - Write `comparison_report.md`, a markdown formatted Performance report
5calibre site create-pull-request-review \
6 --site="calibre" \
7 --title="(fix): Reduce bundle size" \
8 --url="https://my-pr-123.example.com" \
9 --branch="$(git rev-parse --abbrev-ref HEAD)" \
10 --sha="$(git rev-parse HEAD)" \
11 --waitForResult \
12 --failOnUnmetBudget \
13 --markdown > comparison_report.md
1#!/usr/bin/env node
2
3import { PullRequestReview } from 'calibre'
4
5const createPRReview = async () => {
6 // Required
7 const url = 'https://my-pr-123.example.com'
8 const title = '(fix): Reduce bundle size'
9 const branch = 'fix/reduce-bundle-size'
10 const sha = '9ff192958fe518f0bb06b2e25ab5836f52353d8e'
11 const site = 'my-calibre-site-slug'
12
13 // Create the PR Review
14 const { uuid } = await PullRequestReview.create({
15 url,
16 title,
17 branch,
18 sha,
19 site
20 })
21
22 console.log('Pull Request Review queued:', branch)
23
24 // Wait for tests to run
25 const results = await PullRequestReview.waitForReviewCompletion(site, branch)
26
27 // Output the formatted JSON response
28 console.log(JSON.stringify(results, null, 2))
29}
30
31createPRReview()

You can read CLI documentation for calibre site create-pull-request-review here.

View an existing Pull Request Review

Required API Permission: Read Sites
1# Pro tip: Add the --markdown flag for Markdown,
2# or --json flag for JSON output
3calibre site pull-request-review \
4 --site="my-calibre-site-slug" \
5 --branch="fix/reduce-bundle-size"
1#!/usr/bin/env node
2
3import { PullRequestReview } from 'calibre'
4
5const getPRReview = async () => {
6 // Required
7 const site = 'my-calibre-site-slug'
8 const branch = 'fix/reduce-bundle-size'
9
10 // Fetch the Pull Request Review
11 const results = await PullRequestReview.getPRReviewByBranch(site, branch)
12
13 // Output the formatted JSON response
14 console.log(JSON.stringify(results, null, 2))
15}
16
17getPRReview()

You can read CLI documentation for calibre site pull-request-review here.

List Pull Request Reviews

Required API Permission: Read Sites
1calibre site pull-request-reviews --site <site>
1#!/usr/bin/env node
2
3import { PullRequestReview } from 'calibre'
4
5const getPRReviews = async () => {
6 // Required
7 const site = 'my-calibre-site-slug'
8
9 // Fetch a list of Pull Request Reviews
10 const results = await PullRequestReview.list(site)
11
12 // Output the formatted JSON response
13 console.log(JSON.stringify(results, null, 2))
14}
15
16getPRReviews()
Example response
1TITLE | BRANCH | SHA | STATUS | CREATED
2[UI] Add new dropdowns | feat/new-dropdowns | 8de2a10… | completed | 6:15PM 6-Sep-2023
3[Perf] Add lightbox alternative | perf/remove-lightbox | 05ae42a… | completed | 3:52PM 25-Aug-2023
4[UI] Migrate menus from Reach to Radix… | migrate-from-reach-menu | 241ccbb… | completed | 4:48PM 22-Aug-2023
5[Docs] Update FAQs | docs/update-faqs | 78f9a44… | completed | 5:31PM 15-Aug-2023
1[
2 {
3 "title": "[UI] Add new dropdowns",
4 "status": "completed",
5 "branch": "feat/new-dropdowns",
6 "sha": "8de2e10a4a1f7fe46daf5532095842bda6491ea1",
7 "createdAt": "2023-09-06T08:15:58Z"
8 },
9 {
10 "title": "[Perf] Add lightbox alternative",
11 "status": "completed",
12 "branch": "perf/remove-lightbox",
13 "sha": "05ae42a94a0cf860454b3226b4f3f016ed32430f",
14 "createdAt": "2023-08-25T05:52:37Z"
15 },
16 {
17 "title": "[UI] Migrate menus from Reach to Radix UI",
18 "status": "completed",
19 "branch": "migrate-from-reach-menu",
20 "sha": "241ecbb0d2c396c9413adb816fa3ca212eff00da",
21 "createdAt": "2023-08-22T06:48:03Z"
22 },
23 {
24 "title": "[Docs] Update FAQs",
25 "status": "completed",
26 "branch": "docs/update-faqs",
27 "sha": "78a9e442d4f952b612e2d9627b43e61cd5c7e044",
28 "createdAt": "2023-08-15T07:31:48Z"
29 }
30]

You can read CLI documentation for calibre site pull-request-reviews here.