This guide walks you through deploying the Lean 4 CI pipeline on your own repository.
- Morph Cloud Account: Sign up at cloud.morph.so
- GitHub Repository: Fork or clone this repository
- Python 3.11+: For local testing and development
- Click the "Fork" button at the top-right of this repository
- Clone your forked repository locally:
git clone https://github.com/SentinelOps-CI/morph-lean-ci cd morph-lean-ci
- Go to cloud.morph.so and sign in
- Navigate to your account settings
- Generate an API key
- Copy the API key
- Go to your forked repository on GitHub
- Navigate to Settings → Secrets and variables → Actions
- Click "New repository secret"
- Name:
MORPH_API_KEY - Value: Paste your Morph Cloud API key
- Click "Add secret"
-
Install dependencies:
pip install -r requirements.txt
-
Set your API key:
export MORPH_API_KEY="your_api_key_here"
-
Test the setup:
python scripts/test_setup.py
- Go to the "Actions" tab in your repository
- Select the "Lean 4 CI on Morph Cloud" workflow
- Click "Run workflow"
- Choose the number of shards (4 or 8)
- Click "Run workflow"
- Check the Actions tab for workflow progress
- Download artifacts to see logs and test results
- View the summary for performance metrics
When a shard fails, the logs will contain a snapshot ID. You can debug it:
# Start an instance from the failure snapshot
morphcloud instance start <snapshot-id>
# SSH into the instance
morphcloud instance ssh <instance-id>
# Investigate the failure
cd repo
lake build
lake testEdit .github/workflows/lean-ci.yml:
matrix:
shard: ${{ fromJson(format('[0,1,2,3,4,5,6,7]')) }}
shards: ${{ fromJson(format('[{0}]', github.event.inputs.shards || '4')) }}Modify scripts/build_snapshot.py:
base_snapshot = client.snapshots.create(
image_id="morphvm-minimal",
vcpus=4, # Adjust CPU cores
memory=8192, # Adjust memory (MB)
disk_size=32768 # Adjust disk size (MB)
)Modify scripts/run_shard.py:
instance = client.instances.start(
snapshot_id=snapshot_id,
name=f"lean-ci-shard-{args.shard}",
ttl=3600 # Adjust TTL (seconds)
)- The base snapshot includes pre-warmed mathlib cache
- Each shard runs from the same cached snapshot
- Failed shards create new snapshots for instant repro
- Start with 4 shards for testing
- Scale to 8 shards for larger projects
- Monitor Morph Cloud usage and costs
-
API Key Error
- Verify
MORPH_API_KEYis set in GitHub secrets - Check API key permissions in Morph Cloud
- Verify
-
Snapshot Creation Fails
- Verify Morph Cloud account has sufficient credits
- Check image availability (
morphvm-minimal)
-
Lean Installation Fails
- Check network connectivity in Morph Cloud
- Verify Lean 4 setup script is accessible
-
Test Failures
- Check Lean syntax in your examples
- Verify mathlib dependencies are correct
- Check Morph Cloud documentation: docs.morph.so
- Review Morph Python SDK: github.com/morph-labs/morph-python-sdk
- Open issues in this repository for CI-specific problems
- Customize Examples: Replace
examples/hello-leanwith your own Lean project - Add Tests: Create more comprehensive test suites
- Optimize Caching: Add more sophisticated caching strategies
- Monitor Performance: Track build times and optimize resource allocation
For issues with:
- Morph Cloud: Contact support@morph.so
- Lean 4: Check leanprover-community.github.io
- CI Pipeline: Open an issue in this repository