docs: 更新英文和繁体中文文档 #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| pull_request: | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Setup CMake | |
| uses: jwlawson/actions-setup-cmake@v2 | |
| with: | |
| cmake-version: "3.16.3" | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y build-essential cmake ninja-build | |
| - name: Initialize Git submodules | |
| run: | | |
| git submodule update --init --recursive | |
| - name: Configure CMake | |
| run: | | |
| cmake -B build -DCMAKE_BUILD_TYPE=Debug -G "Unix Makefiles" . | |
| - name: Build Lamina | |
| run: | | |
| echo "Building Lamina interpreter with CMake..." | |
| cmake --build build --parallel | |
| echo "✅ Build successful!" | |
| - name: Basic functionality test | |
| working-directory: build/bin | |
| env: | |
| LD_LIBRARY_PATH: . | |
| run: | | |
| echo "Running basic tests..." | |
| # Ensure Lamina is executable | |
| chmod +x ./lamina | |
| # Test 1: Hello World | |
| echo 'print("Hello, Lamina!");' > test1.lm | |
| ./lamina test1.lm | |
| # Test 2: Basic arithmetic | |
| echo 'var x = 2 + 3 * 4;' > test2.lm | |
| echo 'print("2 + 3 * 4 =", x);' >> test2.lm | |
| ./lamina test2.lm | |
| # Test 3: Precise fractions | |
| echo 'var fraction = 16 / 9;' > test3.lm | |
| echo 'print("16/9 =", fraction);' >> test3.lm | |
| ./lamina test3.lm | |
| # Test 4: Functions | |
| echo 'func add(a, b) { return a + b; }' > test4.lm | |
| echo 'var result = add(10, 20);' >> test4.lm | |
| echo 'print("add(10, 20) =", result);' >> test4.lm | |
| ./lamina test4.lm | |
| echo "✅ All basic tests passed!" | |
| - name: Test example programs | |
| working-directory: build/bin | |
| run: | | |
| echo "Testing example programs..." | |
| if [ -d "../../examples" ]; then | |
| for example in ../../examples/*.lm; do | |
| if [ -f "$example" ]; then | |
| echo "Testing $(basename "$example")..." | |
| ./lamina "$example" || echo "⚠️ Warning: $example execution failed" | |
| fi | |
| done | |
| else | |
| echo "ℹ️ No examples directory found" | |
| fi | |
| - name: Check for memory leaks (with valgrind) | |
| working-directory: build/bin | |
| run: | | |
| echo "Installing valgrind for memory leak detection..." | |
| sudo apt-get install -y valgrind | |
| echo "Running memory leak test..." | |
| echo 'var x = 42; print("x =", x);' > memtest.lm | |
| if valgrind --leak-check=full --error-exitcode=1 ./lamina memtest.lm 2>&1; then | |
| echo "✅ No memory leaks detected" | |
| else | |
| echo "⚠️ Memory leaks detected, but continuing..." | |
| fi |