Catch new errors in pull requests

Check every preview deploy from GitHub Actions for error patterns production has never logged, and see the result as a status on the pull request.

Intermediate20 min to complete5 min read

Before you start

  • A Tailcove source receiving your app's logs
  • A preview or review app that each pull request deploys from GitHub Actions

If each pull request already gets a preview deploy, Tailcove can check it the way it checks a release, before anything is merged. You record the preview from the workflow, and 15 minutes later its deploy check looks for errors the preview logged that your production source hasn't logged once in the last week. The answer shows up on the pull request as a commit status called Tailcove preview check, next to your tests.

On this page7 sections

This is a different check from the one in Fail a deploy when errors spike. A preview gets almost no traffic and starts from nothing, so comparing its errors a minute with "the hour before" tells you nothing. Instead it asks a narrower question: did this branch produce a kind of error we haven't seen?

1. Decide where previews log#

The check compares the preview's error patterns with a week of one source. There are two common setups.

Previews log to their own source (say web-preview, with production on web). Open web-preview in Tailcove, go to Settings → Deploy checks and set Compare previews with to web. A preview's error then counts as new only when production never logged it in the 7 days before the deploy.

Previews log to the production source, told apart by environment. Leave Compare previews with on the default, the source itself. Production traffic fills the 7 days, so the comparison still works.

Either way, the GitHub status needs a repository on the source the preview is recorded against: set it with the GitHub repository button on that source's Issues tab. If the repository is connected through the Tailcove GitHub App, give the app the Commit statuses permission (read and write), or GitHub refuses the status and the report page says so.

2. Make a token for CI#

In Tailcove, open Settings → API tokens, pick the For CI preset (it ticks deploys:read and deploys:write) and create the token. Add it to the repository under Settings → Secrets and variables → Actions as TAILCOVE_API_TOKEN. Then copy the preview source's id from the address of its page, like src_01jbx5q8k7m3n2p4r6s8t0v1w3.

3. Record the preview from the workflow#

Add a job to the workflow that builds your preview. It runs after the preview is up, records it and waits for the check:

on:
  pull_request:

jobs:
  preview:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Deploy the preview
        run: ./scripts/deploy-preview.sh "pr-${{ github.event.pull_request.number }}"

  preview-check:
    needs: preview
    runs-on: ubuntu-latest
    timeout-minutes: 25
    env:
      TAILCOVE_API_TOKEN: ${{ secrets.TAILCOVE_API_TOKEN }}
    steps:
      - name: Install tailcove
        run: |
          curl -fsSL https://github.com/tailcove/agent/releases/latest/download/tailcove_linux_amd64.tar.gz | tar -xz tailcove
          sudo install -m 0755 tailcove /usr/local/bin/tailcove

      - name: Record the preview and wait for its check
        run: >
          tailcove deploy
          --source src_01jbx5q8k7m3n2p4r6s8t0v1w3
          --env preview
          --pull-request ${{ github.event.pull_request.number }}
          --branch "${{ github.head_ref }}"
          --sha ${{ github.event.pull_request.head.sha }}
          --wait

--pull-request is what makes it a preview. --env preview (or review, pr, pr-482, review/fix-login) does too, on its own, if you'd rather not send the number.

4. Why the head SHA matters#

Don't leave the commit to GITHUB_SHA here. On a pull_request event, GitHub checks out a merge commit it made for this run, joining your branch with the base branch, and GITHUB_SHA is that commit. It isn't on your branch, so a status set on it never appears on the pull request. The commit the pull request shows is github.event.pull_request.head.sha, which is why the step passes it with --sha.

The same goes for the commit you deploy. If your preview script builds from the checkout, check out the head commit instead of the merge, so the code you test is the code the status lands on:

      - uses: actions/checkout@v4
        with:
          ref: ${{ github.event.pull_request.head.sha }}

5. What counts as a regression#

Fifteen minutes after the preview is recorded (one more for the last lines to arrive), the check reads the preview source's logs for those 15 minutes. It regressed when:

  • an error pattern with 3 or more error lines in the preview isn't anywhere in the comparison source's last 7 days, at any level, or
  • an issue of the preview's source was seen for the first time in those 15 minutes.

There's no error-rate rule. A preview throwing hundreds of errors of a kind production also throws is healthy as far as this check goes, because it didn't introduce them.

If the preview sent no logs in the 15 minutes, the check has no data, and the status is a success that says so. So hit the preview with something after it deploys: a smoke test, an end-to-end suite, a few curl calls. The check can only judge code paths that ran.

--wait exits 1 when the preview regressed and 0 for healthy or no data. To keep the status on the pull request but not block the merge, add continue-on-error: true to the step; to block it, make Tailcove preview check a required status check in the branch protection rules.

6. Read the result#

The status's Details link opens the report: the pull request and branch, the source it was compared with, each new error pattern with its first line and a link to those lines, and each new issue. If the source has default alert channels, a regression is also sent there as "Preview v1.5.0 for PR #482: 1 new error pattern." with the branch and the comparison source.

Releases keep their own status, Tailcove deploy check, so a pull request that's also deployed somewhere for real can show both.

FAQ#

Will a slow, empty preview fail my pull request?

No. A preview with no logs in the 15 minutes gets no data, which the CLI and the status treat as a pass.

A pattern is flagged as new, but production does log it.

Check Compare previews with on the preview source. If it's on the default, the preview is compared with its own source, which only knows what other previews logged in the past week.

Can I use it on GitLab, Bitbucket or Vercel?

Yes. Pass the merge request or pull request number with --pull-request and the source branch's last commit with --sha. The GitHub status needs a GitHub repository; on other hosts the report page, the API and your alert channels still get the result (see the deploys API).

Ready to try it on your own logs?

The Free plan includes a source, live tail, search and alerts. No credit card.