Fix build failure handling and restore ubuntu-22.04 #35
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: Build and Test | |
| on: | |
| push: | |
| branches: [ main, main-dev, test ] | |
| pull_request: | |
| branches: [ main, main-dev, test ] | |
| workflow_dispatch: # 允许手动触发 | |
| jobs: | |
| test-deployment: | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive # 初始化所有 submodules | |
| - name: Set up Python 3.10 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.10' | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| build-essential \ | |
| cmake \ | |
| git \ | |
| pkg-config \ | |
| libgflags-dev \ | |
| libboost-all-dev \ | |
| libomp-dev \ | |
| wget \ | |
| curl | |
| - name: Clean old build artifacts | |
| run: | | |
| # 清理可能存在的旧构建文件 | |
| rm -rf algorithms_impl/PyCANDYAlgo*.so | |
| rm -rf algorithms_impl/build | |
| - name: Run deployment script | |
| run: | | |
| chmod +x deploy.sh | |
| ./deploy.sh | |
| timeout-minutes: 60 | |
| - name: Verify Python packages | |
| run: | | |
| source sage-db-bench/bin/activate | |
| # 设置库路径 | |
| TORCH_LIB=$(python -c "import torch; import os; print(os.path.join(os.path.dirname(torch.__file__), 'lib'))") | |
| export LD_LIBRARY_PATH="$TORCH_LIB:$LD_LIBRARY_PATH" | |
| # 测试导入 | |
| python -c "import PyCANDYAlgo; print('✓ PyCANDYAlgo imported')" | |
| python -c "import pyvsag; print('✓ pyvsag imported')" | |
| python -c "import numpy, torch, yaml; print('✓ Core dependencies OK')" | |
| - name: Run unit tests | |
| run: | | |
| source sage-db-bench/bin/activate | |
| pytest tests/ -v --tb=short || true | |
| - name: Check algorithm availability | |
| run: | | |
| source sage-db-bench/bin/activate | |
| python -c " | |
| from bench.algorithms import get_available_algorithms | |
| algos = get_available_algorithms() | |
| print(f'Available algorithms: {len(algos)}') | |
| for algo in algos: | |
| print(f' - {algo}') | |
| " || echo "Algorithm check skipped" | |
| - name: Upload build logs on failure | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-logs | |
| path: | | |
| algorithms_impl/build.log | |
| algorithms_impl/build/CMakeFiles/*.log | |
| retention-days: 7 | |
| lint-and-format: | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python 3.10 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.10' | |
| - name: Install linting tools | |
| run: | | |
| pip install flake8 black isort mypy | |
| - name: Run flake8 | |
| run: | | |
| flake8 bench/ datasets/ --count --select=E9,F63,F7,F82 --show-source --statistics || true | |
| - name: Check code formatting | |
| run: | | |
| black --check bench/ datasets/ || true | |
| - name: Check import sorting | |
| run: | | |
| isort --check-only bench/ datasets/ || true |