Run CI jobs in throwaway clones
GitHub Actions and GitLab CI jobs run in fresh clones of a Linux, Windows, or macOS template, one clone per job.
Requires OSMates Pro.
Prepare a template for GitHub
- Set up a machine with the tools your jobs need, such as git.
- Download GitHub's arm64 runner into
actions-runnerin the machine's home folder, as GitHub's download steps show. On Windows, useC:\actions-runner. - Skip
config.sh. Each clone registers its own runner. - Shut the machine down, then make it a template, with its name for
<machine>:
osmates template make <machine>
Add a GitHub runner pool
- On GitHub, create a fine-grained token with the repository's Administration permission set to Read and write. For an organization's runners, use Self-hosted runners instead.
- Save the token as a credential, and paste it when asked:
osmates credential add github-runners --host api.github.com --header Authorization --prefix "Bearer "
- Add the pool, with your template and repository:
osmates runner add linux-ci --from <template> --github <owner>/<repository> --credential github-runners --slots 2
Each slot is a clone with a runner waiting for a job. When the job ends, the clone and its runner are deleted, and a new clone takes the slot.
In your workflow, choose the runners by their labels:
runs-on: [self-hosted, Linux, ARM64]
Windows runners have the label Windows, and macOS runners macOS. Add your own labels with --label.
Remove a pool
osmates runner list
osmates runner remove linux-ci
runner list shows each pool and its slots. Removing a pool cancels its running jobs, which GitHub marks as failed.
Run GitLab jobs
GitLab Runner runs on your Mac and calls OSMates for a clone for each job.
- Install git and
gitlab-runnerin the machine. Artifacts and caches needgitlab-runneron thePATH, and Windows also needs PowerShell 7. - Make the machine a template, as for GitHub.
- Install GitLab Runner on your Mac, and register a runner with the
customexecutor. - In GitLab Runner's
config.toml, point the runner's stages at OSMates:
[[runners]]
executor = "custom"
builds_dir = "/builds"
cache_dir = "/cache"
[runners.custom]
config_exec = "/Applications/OSMates.app/Contents/Helpers/osmates"
config_args = ["runner", "gitlab", "config", "--from", "<template>"]
prepare_exec = "/Applications/OSMates.app/Contents/Helpers/osmates"
prepare_args = ["runner", "gitlab", "prepare"]
run_exec = "/Applications/OSMates.app/Contents/Helpers/osmates"
run_args = ["runner", "gitlab", "run"]
cleanup_exec = "/Applications/OSMates.app/Contents/Helpers/osmates"
cleanup_args = ["runner", "gitlab", "cleanup"]
- Restart GitLab Runner.
The clone is deleted when the job ends, fails, or is canceled. If GitLab Runner stops first, OSMates deletes the clone itself. For a macOS template, add limit = 2 to the runner's section, so a third job waits in GitLab.
Limits
- Your Mac runs two macOS clones at once, across every pool and job.
- A pool has 1 to 16 slots, and a macOS pool at most 2.
- A job waits for its clone to start, unless a slot was ready before the job came.
- An outdated runner in the template updates itself in each clone, before every job.
- GitHub's runner for Windows on arm64 is a preview at GitHub.