Skip to main content
Live. This area is documented as current, user-reliable behavior.

Goal

Send CircleCI jobs to StackShift computers with a self-hosted runner resource class.

Prerequisites

  • A StackShift project.
  • A CircleCI organization where you can create runner resource classes.

Workflow

1
In CircleCI, open Runners and click Create Resource Class, for example acme/stackshift-medium. You don’t need the token it shows.
2
In CircleCI, open User Settings, then Personal API Tokens, and create a token.
3
On StackShift, open Computers, then CI. Under CircleCI resource classes, enter the resource class, pick its size, paste your API token and click Connect resource class.
4
Set resource_class in your CircleCI config to the resource class and push.
5
Watch the job on the CI page. CircleCI shows its logs as usual.

What happens

  • StackShift watches how many jobs wait on the resource class and starts one computer for each, up to the number you allow at once.
  • Each computer runs the CircleCI runner, takes one job and stops. The computer is then deleted, so nothing carries over between jobs.
  • Each job gets a runner token made for it alone, and StackShift revokes it when the job ends. Disconnecting the resource class revokes them all.
  • Jobs run as the sandbox user, with Docker and sudo.
  • A job may run up to 5 hours, CircleCI’s default limit for runners.
  • Computers are billed per second like any computer, and the free plan limits for computers apply.

One resource class per size

A resource class always runs on one size. To offer more sizes, create a resource class for each, such as acme/stackshift-medium and acme/stackshift-large, and connect each with its size: small (2 vCPU, 4 GB), small-mem (2 vCPU, 8 GB), medium (4 vCPU, 8 GB), medium-mem (4 vCPU, 16 GB), large (8 vCPU, 16 GB) or xlarge (16 vCPU, 32 GB).

Create the resource class from the terminal

You can also create it with the CircleCI CLI.

Your CircleCI config

.circleci/config.yml

Connect with the CLI

The CLI reads your API token from CIRCLECI_TOKEN, or asks for it when it isn’t set.

Good to know

  • Your API token is stored encrypted and never shown again. To change it, disconnect the resource class and connect it again.
  • To start jobs from your own setup, save a snapshot of a ci-runner computer and connect the resource class with that snapshot.
  • Use the resource class only for StackShift. Another runner on it could take a job a StackShift computer was started for.
  • CircleCI doesn’t run forked pull requests from public projects on self-hosted runners.

Expected result

Each job runs on a fresh ci-runner computer of the connected size, and the computer is deleted when the job ends.

Common failures

  • Jobs stay queued in CircleCI: the note under the resource class on the CI page says why, such as a rejected API token or the jobs-at-once limit.
  • A job shows Taken by another runner: another runner on the same resource class picked it up first. Its computer is deleted without running anything.
  • Waiting for a computer: the reason under the job says what it waits for, such as capacity or funds. It starts as soon as that clears.

Run GitHub Actions jobs on computers

Change runs-on to stackshift-medium and each job runs on a fresh computer of its own, deleted when the job ends.

Start jobs from a snapshot

Save a ci-runner computer with your repository, toolchain and caches, and start jobs from it with stackshift-medium-snapshot-<name>.