Skip to content

CI

gspot can write a CI workflow that runs the checks on each pull request and on each push to the default branch, in one file beside your other workflows. A pull request that changes gspot.toml or a file in .gspot/ checks every file, so turn CI on after you fix or ignore the old findings.

For GitHub:

gspot set ci.enabled true

gspot writes .github/workflows/gspot.yml and prints the other files that change. Commit them with gspot.toml.

For GitLab, also set the provider:

gspot set ci.provider gitlab

gspot writes .gitlab/ci/gspot.yml and prints the other files that change. Commit them with gspot.toml, and include the workflow from .gitlab-ci.yml:

include:
- local: .gitlab/ci/gspot.yml

gspot doctor prints these commands when it finds GitHub or GitLab CI files, or an origin remote on GitHub or GitLab.

On GitHub, a job named lint runs for pull requests, merge queues, and pushes to the default branch, so open a pull request to check another branch. When your repository uses jest, vitest, or pytest, the workflow also runs a tests job, so the lint result does not wait for your tests. On GitLab, one job runs both.

To run your tests only in a workflow of your own, run gspot ignore vitest/tests --reason "<why>". gspot then stops running them, and the lint rules and coding agent rules of vitest stay.

The job runs gspot check --base with the base of the pull request or merge request, or with the previous push, so it checks what changed after that commit. It leaves out the manual checks. An empty base, the all-zero hash of a branch’s first push, or a full hash that the clone lacks checks every file, and the report says why. A base that shares no commit with HEAD checks every file too. Any other base that Git cannot find stops the run with exit code 2, and in a shallow clone the message says how to fetch the history.

The job fails when gspot install changes a file in the clone, such as a generated file that someone edited by hand, or a lockfile that is missing or out of date. To fix the job, run gspot install on your machine and commit the changed files.

On GitHub, the job runs on Linux, plus macOS when your repository uses the swift configuration. To add other systems:

gspot set ci.operating_systems linux macos windows

With more than one system, each system gets its own job: lint-linux, lint-macos, and lint-windows, and the same for tests. Choose only systems where your checks can run. To run the Linux job on a larger or self-hosted runner, name its label:

gspot set ci.linux_runner ubuntu-24.04-8core

Both settings work only on GitHub, so with ci.provider = "gitlab", gspot rejects them.

The GitLab job runs in the GitLab stage .pre, and only in merge request pipelines and in pipelines of the default branch. GitLab runs .pre only when a pipeline also has a job in another stage. To run one pipeline for each merge request, add this block to your .gitlab-ci.yml:

workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

Before gspot install, the job installs the dependencies from the lockfiles of the root folder and of each scope:

LockfileCommand
yarn.lock, Yarn 2 or lateryarn install --immutable
package-lock.jsonnpm ci
pnpm-lock.yamlpnpm install --frozen-lockfile
yarn.lock, Yarn 1yarn install --frozen-lockfile
bun.lockbun install --frozen-lockfile
bun.lockbbun install --frozen-lockfile
uv.lockuv sync --locked

Each command fails when the lockfile does not match its project. In a Next.js scope, the step then runs next typegen, so that the lint rules that read types find the route types.

The job runs gspot and these commands with the Node.js version that mise.toml pins, so CI runs the version that your machine runs. Without a Node.js pin in mise.toml, the job uses the version that gspot pins for CI.

The job runs gspot check under mise exec, so a [[command_check]] reads the variables that the [env] table of your mise config sets.

To run your own install command instead, set ci.setup_command. The job runs it before gspot install, and stops if it fails:

gspot set ci.setup_command -- bun install --frozen-lockfile

gspot quotes each argument, so the command runs without shell features: &&, pipes, and $VAR do not work. To run several commands, name a script that runs them.

Write your own pipeline when you use another CI provider, when your project installs private packages, or when its tests need a database or another service. The job that gspot writes passes no secret to the install step and starts no service container, so in these cases, keep ci.enabled off.

Clone with the full Git history, so that gspot can compare with the base revision. Install mise and the runtime of your project, and set GITHUB_TOKEN, which mise uses to look up tool releases. Then run these steps, starting each gspot command the way your package manager does, as Add gspot shows. With Bun:

example
bun install --frozen-lockfile
bunx --no-install gspot install
git add --intent-to-add -- .
git diff --exit-code
bunx --no-install gspot check --base "$BASE"

git diff --exit-code fails when gspot install changed a file, such as an out-of-date lockfile in .gspot/. $BASE names the revision to compare with, so that gspot checks only the changed files, and it follows the rules of What the job checks:

Provider BASE
Bitbucket Pipelines $BITBUCKET_PR_DESTINATION_COMMIT
Azure Pipelines origin/${SYSTEM_PULLREQUEST_TARGETBRANCH#refs/heads/}
Jenkins origin/$CHANGE_TARGET
Any other provider, such as CircleCI $(git merge-base origin/<default-branch> HEAD)

When a [[command_check]] reads the [env] table of your mise config, start gspot check under mise exec --, as the job that gspot writes does.

Let the pipeline fail when gspot exits with a code other than 0. Exit code 1 means that findings remain, and 2 means that the run did not finish, such as when a tool is missing.

In a monorepo, run your build before the checks, because tsc reads the types of a workspace package from its build. Without the build, typescript/tsc cannot find those types, and the lint rules that read types report false no-unsafe-* findings.

To cache downloads and installed tools, but no credentials, build the cache key from the gspot version, the files in .gspot/ that pin the tools, and your lockfiles.

.gspot/node_modules/ and .gspot/.venv/ hold tools built for one operating system. When a dev container shares the checkout with your machine, a gspot install in the container replaces the tools that your machine uses. The checks on your machine then report errors until you run gspot install there again. To prevent this, mount .gspot/node_modules/ and .gspot/.venv/ as volumes of the container, and run gspot install in its postCreateCommand.

Run gspot set ci.enabled false. gspot deletes the workflow file.