This repository contains resources related to the JuliaGPU Buildkite CI infrastructure:
- a custom Ubuntu-based image that can be based off of another image (e.g. CUDA's images);
- Docker Compose templates and systemd service files to tie everything together, and give each job a safe and reproducible execution environment.
Many of these features come from the fact that the JuliaGPU CI is intended to be run on a variety of repositories (and external PRs to those repositories), whereas Buildkite is typically used within the (trusted) boundaries of a single organization.
This README documents how to use the JuliaGPU Buildkite CI. For details on the available agents, or how to add one, see the agents README. Note that this Buildkite set-up is fairly new, and the set-up may still change. Keep an eye on this README if anything breaks.
If your Julia package can use a GPU, you may use the JuliaGPU CI infrastructure to run tests on a system with a GPU. This is not a general-purpose CI service, and only intended to run GPU-related tests of Julia packages. For all other testing, use public infrastructure (Travis, Github Actions, etc).
Before everything else, the the Buildkite app needs to be available for the GitHub organization that hosts your repository. If the organization is not listed, a user with administrative privileges on both the JuliaLang BuildKite and the GitHub organization in question should set that up and make sure the organization is then listed as a repository provider. You should coordinate this on the #gpu channel of the JuliaLang slack, and ping BuildKite admins (@maleadt, @vchuravy, @DilumAluthge, ...).
Next, a Buildkite admin sets up a pipeline for the repository:
-
Create a new pipeline, named after the package. Select the repository (if its organization isn't listed, the Buildkite app isn't set up for it), check it out over HTTPS, select the JuliaGPU cluster, and grant access to the JuliaGPU team. Buildkite creates the GitHub webhook itself.
-
Use the following steps:
steps: - label: ":buildkite: Pipeline upload" command: buildkite-agent pipeline upload branches: "!gh-pages" agents: queue: upload
-
Apply the standard settings with the Buildkite CLI (
SLUGis the pipeline's slug, e.g.cuda-dot-jl). This only changes the settings listed, so it can also be re-applied to existing pipelines:bk api -X PATCH /pipelines/SLUG --data '{ "visibility": "public", "branch_configuration": "main master release-* v* ci/pr-*", "skip_queued_branch_builds": true, "skip_queued_branch_builds_filter": "!main !master", "cancel_running_branch_builds": true, "cancel_running_branch_builds_filter": "!main !master", "provider_settings": { "build_branches": true, "build_tags": true, "build_pull_requests": true, "build_pull_request_forks": false, "skip_pull_request_builds_for_existing_commits": true, "publish_commit_status": true, "publish_commit_status_per_step": true } }'
In the web UI, these are: the pipeline is public; branches
main master release-* v*andci/pr-*are built, as are tags and pull requests; intermediate builds are skipped and cancelled except onmain/master; and every step posts its own commit status.- Fork PRs are not built (
build_pull_request_forks: false): jobs on these agents are not isolated well enough to run arbitrary code from anyone. Fork PRs are built after a maintainer approves them, through buildkite-pr-relay, which pushes them toci/pr-<N>branches. - Per-step commit statuses let GitHub Actions workflows react to a single step, e.g. deploy the documentation when the documentation step passes (see Secrets).
- Fork PRs are not built (
Finally, you should create .buildkite/pipeline.yml in your repository with the steps to
perform GPU CI. Start from the following template:
steps:
- label: "Julia v1"
plugins:
- JuliaCI/julia#v1:
version: "1"
- JuliaCI/julia-test#v1: ~
- JuliaCI/julia-coverage#v1: ~
agents:
queue: "cuda"
if: build.message !~ /\[skip tests\]/
timeout_in_minutes: 60If you want to perform several tests, or introduce test phases, you may want to add
additional steps. Note that each step is run in a fresh container (as opposed to how
Buildkite normally works), so you need to repeat the set-up that provides Julia (here done
by the julia plugin) and/or instantiates your project (done by the julia-test plugin).
If you need to send resources across steps, use
artifacts.
Coverage is uploaded to Codecov without a token, which Codecov accepts for public repositories once token authentication is disabled for the organization (see below).
Pull requests from forks (third-party PRs) are not built automatically: these agents can't safely run arbitrary code from anyone. Instead, use buildkite-pr-relay to build them once a maintainer has approved their commit:
- Add the relay's two workflows (
BuildkiteApproval.ymlandBuildkiteRelay.yml, in branch mode, which needs no token) to your repository. - In the repository's or organization's Actions settings, require approval for all external contributors, or for first-time contributors if returning contributors may be built without approval. Don't leave GitHub's default (only contributors new to GitHub), which lets almost every account through.
Maintainers then approve each new commit of a fork PR with Approve workflows to run, and
the relay pushes it to a ci/pr-<N> branch that Buildkite builds (all JuliaGPU pipelines
build ci/pr-*). Such a build has no pull-request metadata, so if your pipeline treats
pull requests differently, also check the branch, e.g.
if: build.pull_request.id == null && build.branch !~ /^ci\/pr-/ # not on any PRPRs that change .github/ or .buildkite/ aren't relayed; to build one, push it to a
branch of your repository.
Jobs on these agents get no secrets. The agents run code from many repositories, and
the old mechanism (SECRET_* variables encrypted with a key shared by all agents) gave
every job that key. Pipelines that still define SECRET_* variables get a warning
annotation, and the variables are no longer decrypted.
Do whatever needs a credential in GitHub Actions instead, with the repository's own
secrets or GITHUB_TOKEN:
- Coverage: in the Codecov settings of your GitHub organization, make token
authentication optional for public repositories. The
julia-coverageplugin then uploads without a token (JuliaGPU's repositories already work this way). Alternatively, upload the coverage files as a Buildkite artifact and send them to Codecov from GitHub Actions. - Documentation, benchmarks and other publishing: build the result on Buildkite and
upload it as an artifact. A GitHub Actions workflow triggered by the commit status
Buildkite posts for that step (
on: status) downloads the artifact with a read-only Buildkite token (see below) and publishes it. Such a workflow runs from the default branch; it should decide from GitHub's data (is the commit on the default branch, tagged, the head of a PR from the same repository?) what to publish, and treat the artifact as untrusted data. See CUDA.jl's.github/workflowsfor examples (Documentation.ymlfor Documenter.jl docs,Benchmark.ymlfor benchmarks).
To download artifacts, GitHub Actions needs a Buildkite API token. Ask a Buildkite admin
(on the #gpu channel of the JuliaLang Slack) for one for your GitHub organization, and store
it as the organization secret BUILDKITE_TOKEN (or as a repository secret). These tokens
are read-only (read_builds and read_artifacts), and each organization gets its own, so
one can be revoked without affecting others. JuliaGPU's repositories already have one.