GitLab and other CI Integration

How to integrate Trunk Check into CI for GitLab and other non-GitHub providers, or for GitHub without using the Trunk GitHub App

If you use GitHub, we recommend you follow the GitHub Integration guide.

trunk check --ci will work on any CI provider.

You may also want to specify --upstream if, for example, your PRs are not merged into your default branch, but into a develop branch.

Caching and Persistence

  • Trunk caches the version of trunk itself, linters, formatters, and lint results, in ~/.cache/trunk

  • If your build machines are persistent, make sure this directory is not wiped out between CI jobs for best performance. If Trunk has to re-download every linter for every job because this directory is wiped out, it will be very slow.

  • If your build machines are ephemeral, there are a few options for caching:

    • CI systems have support for caching between CI jobs on ephemeral runners:

    • You can include a seeded trunk cache in a regularly updated image used for CI by running trunk check download, which will download all requirements to ~/.cache/trunk

Running trunk check on hourly/nightly builds

If you'd like to setup trunk check to run on a hourly/nightly CI run or release branch we recommend running with the following command:

trunk check --all --ci-progress --monitor=false

--ci-progress will print out the tool's progress every 30 seconds, whereas --no-progress will suppress any progress reporting.

You can also explicitly set the upstream branch if needed via --upstream, but we do detect your main branch by default.

Last updated