CI and automation¶
Authenticate with a token¶
pp login needs a browser. In CI, on a server, or for an agent, use an API
token.
Create one from the dashboard or from a machine that is already signed in:
$ pp token create github-actions
pp_3f9a2c1b4d5e_8c7e…
proofpod: this token is shown once. Use it as PROOFPOD_TOKEN in CI.
Then set PROOFPOD_TOKEN in the job's environment. It takes precedence over
any stored credentials.
Share a workspace between jobs¶
CI runners are usually fresh machines, and by default every machine gets its own workspace, so every job would start with an empty build cache. Give the workspace a name instead:
All jobs using that name share one workspace: sources are synced as a diff from whatever the previous job left, and Lake only rebuilds what changed.
Use one name per line of development that should share a cache. A name per
branch (myproject-${BRANCH}) is a good default; a single shared name is fine
if jobs do not overlap. A workspace runs one command at a time, so jobs that
share a name queue behind each other.
GitHub Actions¶
name: Lean
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
env:
PROOFPOD_TOKEN: ${{ secrets.PROOFPOD_TOKEN }}
PROOFPOD_WORKSPACE: myproject-${{ github.ref_name }}
steps:
- uses: actions/checkout@v4
- name: Install ProofPod
run: curl -LsSf https://proofpod.dev/install.sh | sh
- name: Build
run: pp --cpu 16 --memory 32G --timeout 2h lake build
- name: Test
run: pp lake test
The runner itself needs no Lean toolchain, no Mathlib cache and no large machine: a standard runner spends the job waiting on output.
Output and exit codes in scripts¶
- Only the command's own output goes to stdout. ProofPod's messages go to stderr.
- When stderr is not a terminal, ProofPod prints warnings and errors only. Add
--verboseto also log sync details, the environment and the cost summary, or--quietfor nothing but the command's output. ppexits with the command's exit code. See the full list in the CLI reference.
if pp --quiet lake env lean Candidate.lean > result.txt 2> errors.txt; then
echo "proof accepted"
fi
Checking many files¶
A common automation pattern is checking a stream of candidate proofs. Inside a project:
pp never reads standard input unless you pass --stdin, so it is safe to call
from a loop that is itself reading a list, and from harnesses that leave stdin
open:
while read -r file; do
pp --quiet lake env lean "$file" || echo "$file" >> failed.txt
done < candidates.txt
The sandbox stays warm for two minutes after each command, so consecutive checks skip the cold start. Each check of a file importing all of Mathlib takes about 7 seconds and costs about $0.0002.
Checks in one workspace run one at a time. To run checks in parallel, use
several named workspaces (--workspace checks-1, --workspace checks-2, …),
up to your account's limit of 8 concurrent commands.
Fixing versions for reproducibility¶
By default the cloud follows the project's lean-toolchain and
lake-manifest.json, which is what you want when both are committed. To pin
regardless of the checkout, set them explicitly: