|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +################################################################################ |
| 4 | +# TEST SCRIPT TO RUN BEFORE PUSHING CHANGES |
| 5 | +# |
| 6 | +# This script ensures that the key components of the Lean project are functional |
| 7 | +# before changes are pushed to the repository by checking that: |
| 8 | +# 1. You are in the correct directory; |
| 9 | +# 2. The project builds successfully; |
| 10 | +# 3. The blueprint is successfully generated in both PDF and web versions; |
| 11 | +# 4. LaTeX declarations in the blueprint match Lean declarations in the codebase. |
| 12 | +################################################################################ |
| 13 | + |
| 14 | +# Ensure the script is in the outermost 'FLT' folder |
| 15 | +echo "Checking if you are in the correct directory..." |
| 16 | +if [ ! -f lakefile.lean ]; then |
| 17 | + echo "❌ Error: This doesn't appear to be the outermost 'FLT' directory. |
| 18 | + Please run this script from the correct folder." |
| 19 | + echo "Press any key to exit..." |
| 20 | + read |
| 21 | + exit 1 |
| 22 | +fi |
| 23 | +echo "✅ Correct directory detected." |
| 24 | + |
| 25 | +# Get Mathlib cache |
| 26 | +echo "Attempting to get Mathlib cache..." |
| 27 | +if ! lake exe cache get; then |
| 28 | + echo "❌ Error: Failed to get Mathlib cache. Continuing without cache." |
| 29 | +else |
| 30 | + echo "✅ Mathlib cache successfully retrieved." |
| 31 | +fi |
| 32 | + |
| 33 | +# Build the project |
| 34 | +echo "Building the project..." |
| 35 | +if ! lake build FLT; then |
| 36 | + echo "❌ Error: Project build failed. Please check the code for errors." |
| 37 | + echo "Press any key to exit..." |
| 38 | + read |
| 39 | + exit 1 |
| 40 | +else |
| 41 | + echo "✅ Project build completed successfully." |
| 42 | +fi |
| 43 | + |
| 44 | +# Generate the PDF version of the blueprint |
| 45 | +echo "Generating PDF version of the blueprint..." |
| 46 | +if ! leanblueprint pdf; then |
| 47 | + echo "❌ Error: Failed to generate PDF version of the blueprint." |
| 48 | + echo "Press any key to exit..." |
| 49 | + read |
| 50 | + exit 1 |
| 51 | +else |
| 52 | + echo "✅ PDF version of the blueprint generated successfully." |
| 53 | +fi |
| 54 | + |
| 55 | +# Generate the web version of the blueprint |
| 56 | +echo "Generating web version of the blueprint..." |
| 57 | +if ! leanblueprint web; then |
| 58 | + echo "❌ Error: Failed to generate web version of the blueprint." |
| 59 | + echo "Press any key to exit..." |
| 60 | + read |
| 61 | + exit 1 |
| 62 | +else |
| 63 | + echo "✅ Web version of the blueprint generated successfully." |
| 64 | +fi |
| 65 | + |
| 66 | +# Check declarations |
| 67 | +echo "Checking if Lean declarations in the blueprint match the codebase..." |
| 68 | +if ! lake exe checkdecls blueprint/lean_decls; then |
| 69 | + echo "❌ Error: Some declarations in the blueprint do not match Lean declarations in the codebase." |
| 70 | + echo "Press any key to exit..." |
| 71 | + read |
| 72 | + exit 1 |
| 73 | +else |
| 74 | + echo "✅ All declarations match successfully." |
| 75 | +fi |
| 76 | + |
| 77 | +# Final message on test completion |
| 78 | +echo "🎉 All steps completed successfully! You are ready to push." |
0 commit comments