Continuous Integration
All
Gitlab
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.Gitlab performs a shallow clone by default which limits trunk's ability to detect the upstream commit to compute changes from. This is easily solved by simply fetching your main branch before running
trunk
:git fetch origin main
trunk check --ci
If your default branch is named something else (e.g.
master
), you should fetch
that branch instIf you host your source code on GitHub, you can also post inline annotations to GitHub.
TRUNK_TOKEN=...
trunk check --ci --trunk-annotate --github-commit=$(git rev-parse HEAD)
To get a
TRUNK_TOKEN
, you'll need to:- create a Trunk organization,
- download your token from your organization settings.
- 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
Sometimes you need to bypass a failing
trunk check
job on an individual pull request. To bypass the failing pull request add /trunk skip-check
as a comment or in the description of the pull request before Trunk Check runs (if it has already run, restart it).Note:trunk check
will still run in this case and report issues, but the job will always return a passing exit code.
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 modified 1mo ago