|
| 1 | +# Deployment Guide for Lean 4 CI on Morph Cloud |
| 2 | + |
| 3 | +This guide walks you through deploying the Lean 4 CI pipeline on your own repository. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +1. **Morph Cloud Account**: Sign up at [cloud.morph.so](https://cloud.morph.so) |
| 8 | +2. **GitHub Repository**: Fork or clone this repository |
| 9 | +3. **Python 3.11+**: For local testing and development |
| 10 | + |
| 11 | +## Step 1: Fork the Repository |
| 12 | + |
| 13 | +1. Click the "Fork" button at the top-right of this repository |
| 14 | +2. Clone your forked repository locally: |
| 15 | + ```bash |
| 16 | + git clone https://github.com/SentinelOps-CI/morph-lean-ci |
| 17 | + cd morph-lean-ci |
| 18 | + ``` |
| 19 | + |
| 20 | +## Step 2: Set Up Morph Cloud API Key |
| 21 | + |
| 22 | +1. Go to [cloud.morph.so](https://cloud.morph.so) and sign in |
| 23 | +2. Navigate to your account settings |
| 24 | +3. Generate an API key |
| 25 | +4. Copy the API key |
| 26 | + |
| 27 | +## Step 3: Configure GitHub Secrets |
| 28 | + |
| 29 | +1. Go to your forked repository on GitHub |
| 30 | +2. Navigate to Settings → Secrets and variables → Actions |
| 31 | +3. Click "New repository secret" |
| 32 | +4. Name: `MORPH_API_KEY` |
| 33 | +5. Value: Paste your Morph Cloud API key |
| 34 | +6. Click "Add secret" |
| 35 | + |
| 36 | +## Step 4: Test Local Setup (Optional) |
| 37 | + |
| 38 | +1. Install dependencies: |
| 39 | + ```bash |
| 40 | + pip install -r requirements.txt |
| 41 | + ``` |
| 42 | + |
| 43 | +2. Set your API key: |
| 44 | + ```bash |
| 45 | + export MORPH_API_KEY="your_api_key_here" |
| 46 | + ``` |
| 47 | + |
| 48 | +3. Test the setup: |
| 49 | + ```bash |
| 50 | + python scripts/test_setup.py |
| 51 | + ``` |
| 52 | + |
| 53 | +## Step 5: Trigger the CI Pipeline |
| 54 | + |
| 55 | +1. Go to the "Actions" tab in your repository |
| 56 | +2. Select the "Lean 4 CI on Morph Cloud" workflow |
| 57 | +3. Click "Run workflow" |
| 58 | +4. Choose the number of shards (4 or 8) |
| 59 | +5. Click "Run workflow" |
| 60 | + |
| 61 | +## Step 6: Monitor and Debug |
| 62 | + |
| 63 | +### Viewing Results |
| 64 | +- Check the Actions tab for workflow progress |
| 65 | +- Download artifacts to see logs and test results |
| 66 | +- View the summary for performance metrics |
| 67 | + |
| 68 | +### Debugging Failures |
| 69 | +When a shard fails, the logs will contain a snapshot ID. You can debug it: |
| 70 | + |
| 71 | +```bash |
| 72 | +# Start an instance from the failure snapshot |
| 73 | +morphcloud instance start <snapshot-id> |
| 74 | + |
| 75 | +# SSH into the instance |
| 76 | +morphcloud instance ssh <instance-id> |
| 77 | + |
| 78 | +# Investigate the failure |
| 79 | +cd repo |
| 80 | +lake build |
| 81 | +lake test |
| 82 | +``` |
| 83 | + |
| 84 | +## Configuration Options |
| 85 | + |
| 86 | +### Modifying Shard Count |
| 87 | +Edit `.github/workflows/lean-ci.yml`: |
| 88 | +```yaml |
| 89 | +matrix: |
| 90 | + shard: ${{ fromJson(format('[0,1,2,3,4,5,6,7]')) }} |
| 91 | + shards: ${{ fromJson(format('[{0}]', github.event.inputs.shards || '4')) }} |
| 92 | +``` |
| 93 | +
|
| 94 | +### Resource Allocation |
| 95 | +Modify `scripts/build_snapshot.py`: |
| 96 | +```python |
| 97 | +base_snapshot = client.snapshots.create( |
| 98 | + image_id="morphvm-minimal", |
| 99 | + vcpus=4, # Adjust CPU cores |
| 100 | + memory=8192, # Adjust memory (MB) |
| 101 | + disk_size=32768 # Adjust disk size (MB) |
| 102 | +) |
| 103 | +``` |
| 104 | + |
| 105 | +### Timeout Settings |
| 106 | +Modify `scripts/run_shard.py`: |
| 107 | +```python |
| 108 | +instance = client.instances.start( |
| 109 | + snapshot_id=snapshot_id, |
| 110 | + name=f"lean-ci-shard-{args.shard}", |
| 111 | + ttl=3600 # Adjust TTL (seconds) |
| 112 | +) |
| 113 | +``` |
| 114 | + |
| 115 | +## Performance Optimization |
| 116 | + |
| 117 | +### Caching Strategy |
| 118 | +- The base snapshot includes pre-warmed mathlib cache |
| 119 | +- Each shard runs from the same cached snapshot |
| 120 | +- Failed shards create new snapshots for instant repro |
| 121 | + |
| 122 | +### Scaling Considerations |
| 123 | +- Start with 4 shards for testing |
| 124 | +- Scale to 8 shards for larger projects |
| 125 | +- Monitor Morph Cloud usage and costs |
| 126 | + |
| 127 | +## Troubleshooting |
| 128 | + |
| 129 | +### Common Issues |
| 130 | + |
| 131 | +1. **API Key Error** |
| 132 | + - Verify `MORPH_API_KEY` is set in GitHub secrets |
| 133 | + - Check API key permissions in Morph Cloud |
| 134 | + |
| 135 | +2. **Snapshot Creation Fails** |
| 136 | + - Verify Morph Cloud account has sufficient credits |
| 137 | + - Check image availability (`morphvm-minimal`) |
| 138 | + |
| 139 | +3. **Lean Installation Fails** |
| 140 | + - Check network connectivity in Morph Cloud |
| 141 | + - Verify Lean 4 setup script is accessible |
| 142 | + |
| 143 | +4. **Test Failures** |
| 144 | + - Check Lean syntax in your examples |
| 145 | + - Verify mathlib dependencies are correct |
| 146 | + |
| 147 | +### Getting Help |
| 148 | + |
| 149 | +- Check Morph Cloud documentation: [docs.morph.so](https://docs.morph.so) |
| 150 | +- Review Morph Python SDK: [github.com/morph-labs/morph-python-sdk](https://github.com/morph-labs/morph-python-sdk) |
| 151 | +- Open issues in this repository for CI-specific problems |
| 152 | + |
| 153 | +## Next Steps |
| 154 | + |
| 155 | +1. **Customize Examples**: Replace `examples/hello-lean` with your own Lean project |
| 156 | +2. **Add Tests**: Create more comprehensive test suites |
| 157 | +3. **Optimize Caching**: Add more sophisticated caching strategies |
| 158 | +4. **Monitor Performance**: Track build times and optimize resource allocation |
| 159 | + |
| 160 | +## Support |
| 161 | + |
| 162 | +For issues with: |
| 163 | +- **Morph Cloud**: Contact [email protected] |
| 164 | +- **Lean 4**: Check [leanprover-community.github.io](https://leanprover-community.github.io) |
| 165 | +- **CI Pipeline**: Open an issue in this repository |
0 commit comments