API
Git forges, merge queues, and agent orchestrators that have no runner protocol of their own can run jobs on Tuist Runners directly. You create a job with one request, a Tuist machine of the profile you choose checks out the commit and runs your script, and Tuist reports the result to your webhook endpoint.
Run a job#
-
Create an account token with the
account:runners:writescope:tuist account tokens create my-org --scopes account:runners:write --name forgebashtuist account tokens create my-org --scopes account:runners:write --name forge -
Create the job. A typical caller does this from its push hook, with a short-lived token that lets the machine clone the repository:
curl -X POST https://tuist.dev/api/accounts/my-org/runners/jobs \ -H "Authorization: Bearer $TUIST_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "profile": "tuist-macos", "repository_url": "https://git.example.com/acme/app.git", "clone_token": "<short-lived token>", "commit_sha": "4f1c2d0e9b8a7c6d5e4f3a2b1c0d9e8f7a6b5c4d", "ref": "refs/heads/main", "name": "test", "script": "mise install\nmise run test", "secrets": { "SIGNING_KEY": "..." }, "timeout_minutes": 30, "idempotency_key": "acme/app:4f1c2d0e:test" }'bashcurl -X POST https://tuist.dev/api/accounts/my-org/runners/jobs \-H "Authorization: Bearer $TUIST_TOKEN" \-H "Content-Type: application/json" \-d '{"profile": "tuist-macos","repository_url": "https://git.example.com/acme/app.git","clone_token": "<short-lived token>","commit_sha": "4f1c2d0e9b8a7c6d5e4f3a2b1c0d9e8f7a6b5c4d","ref": "refs/heads/main","name": "test","script": "mise install\nmise run test","secrets": { "SIGNING_KEY": "..." },"timeout_minutes": 30,"idempotency_key": "acme/app:4f1c2d0e:test"}'The response is the job, with its
workflow_job_id. It appears in the Runners section of your Tuist dashboard straight away and starts as soon as a machine of the profile is free. Warm machines usually start it within seconds. -
Follow the job. Subscribe a webhook endpoint to
runner_job.startedandrunner_job.completed. The completed event carries the job'sconclusion:success,failure, orcancelled. You can also pollGET /api/accounts/my-org/runners/jobs/{workflow_job_id}and read the log fromGET /api/accounts/my-org/runners/jobs/{workflow_job_id}/logs.
Integrate a git forge#
A forge without a runner protocol connects through a small bridge, which can be a service of the forge itself or a function it calls from its hooks:
- On push, the forge's push hook reaches the bridge. The bridge verifies the hook, decides which checks the commit needs, and mints a read-only clone token for the repository that expires after the job's timeout.
- For each check, the bridge creates a job with
idempotency_keyset to<repository>:<commit>:<check>, so a redelivered hook creates nothing new. It stores the returnedworkflow_job_idand can mark the check pending in the forge. - On
runner_job.startedandrunner_job.completed, the bridge verifies theTuist-Signatureheader with the endpoint's secret, finds the check byworkflow_job_idoridempotency_key, and updates the forge's commit status with theconclusion. It can link the status to the job's page in the Tuist dashboard. - When a push supersedes a commit, the bridge cancels the jobs it created for the older commit.
How the job runs#
The machine fetches commit_sha from repository_url over HTTPS. When the server does not serve a commit by its SHA, it fetches ref instead, which must contain the commit. The clone_token, if you give one, is sent as Authorization: Bearer <token> to the repository's host only. It never reaches your script or the job log.
Your script runs with Bash in a login shell, with set -eo pipefail, from the root of the checkout. The job fails when the script exits with a non-zero status or runs past timeout_minutes, which defaults to 60 and can be up to 360. Besides your env and secrets, the script sees CI=true, TUIST_JOB_ID, TUIST_JOB_NAME, TUIST_JOB_REPOSITORY_URL, TUIST_JOB_REF, and TUIST_JOB_COMMIT_SHA. Values of secrets are masked in the job log.
Retries and idempotency#
Give each job an idempotency_key that names what it is for, such as <repository>:<commit>:<check>. A request with a key already used in your account returns the existing job, with status 200 instead of 201, and creates nothing. This lets your push hook hand the request to a retry queue without risking duplicate jobs.
Webhook deliveries are retried until your endpoint answers with a 2xx status, so an event can arrive more than once. Use the id of the envelope, or the job's workflow_job_id with the event type, to deduplicate.
Cancel a job#
curl -X POST https://tuist.dev/api/accounts/my-org/runners/jobs/{workflow_job_id}/cancel \
-H "Authorization: Bearer $TUIST_TOKEN"
A job no machine has started is cancelled immediately. A running job stops within a few seconds, and its completed event reports cancelled. A job that no machine starts within 24 hours is cancelled automatically.
Caching and trust#
Anyone who can push to the repository can change what a job runs, so API jobs are treated as untrusted: they don't get your account's shared cache volumes or its cache signing grant. The secrets, script, and clone token of a job are stored encrypted and deleted once the job finishes.