Skip to content

willxxy is running tests 🚀 #230

willxxy is running tests 🚀

willxxy is running tests 🚀 #230

name: ECG-Bench CI/CD
run-name: ${{ github.actor }} is running tests 🚀
permissions:
contents: read
on: [push, pull_request]
jobs:
Build-and-Test:
runs-on: ubuntu-latest
steps:
- name: Check out repository code with submodules
uses: actions/checkout@v4
with:
submodules: recursive # This ensures git submodules are checked out too
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
# Do not use the built-in caching as we'll handle it ourselves more precisely
- name: Get pip cache directory
id: pip-cache-dir
run: |
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: Setup pip cache
uses: actions/cache@v3
id: pip-cache
with:
path: |
${{ steps.pip-cache-dir.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache PyTorch and special dependencies
uses: actions/cache@v3
id: torch-cache
with:
path: |
${{ steps.pip-cache-dir.outputs.dir }}/**/torch*
${{ steps.pip-cache-dir.outputs.dir }}/**/nvidia*
${{ steps.pip-cache-dir.outputs.dir }}/**/flash-attn*
key: ${{ runner.os }}-torch-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('.github/workflows/github-actions-demo.yml') }}
restore-keys: |
${{ runner.os }}-torch-
- name: Install PyTorch
run: |
python -m pip install --upgrade pip
# Install PyTorch with specific CUDA support and cache
echo "Installing PyTorch (Cached: ${{ steps.torch-cache.outputs.cache-hit == 'true' }})"
pip install torch==2.3.1 torchvision==0.18.1 torchaudio==2.3.1 --index-url https://download.pytorch.org/whl/cu121
- name: Install Transformers from submodule
run: |
# Check if transformers directory exists as a submodule
if [ -d "transformers" ] && [ -f "transformers/setup.py" ]; then
echo "Installing Transformers from local submodule"
cd transformers && pip install -e . && cd ..
# Verify installation
python -c "import transformers; print(f'Transformers installed from: {transformers.__file__}')"
else
echo "WARNING: Transformers submodule not found or incomplete"
find . -name "transformers" -type d
fi
- name: Install Flash Attention and other special dependencies
run: |
# Install build dependencies for Flash Attention
pip install ninja
# Try pre-built wheel if available (more reliable)
echo "Installing Flash Attention (Cached: ${{ steps.torch-cache.outputs.cache-hit == 'true' }})"
pip install flash-attn==2.7.4.post1 --no-build-isolation || \
# Fall back to installing from source with specific build flags
TORCH_CUDA_ARCH_LIST="8.0;8.6" pip install flash-attn==2.7.4.post1 --no-cache-dir || \
# Final fallback - skip if installation fails
echo "Flash Attention installation failed, continuing without it"
# Install LLM Blender and TRL packages
pip install git+https://github.com/yuchenlin/LLM-Blender.git || echo "LLM-Blender installation failed, continuing"
pip install "trl[judges]" || echo "TRL installation failed, continuing"
- name: Install remaining dependencies
run: |
echo "Installing dependencies (Cached: ${{ steps.pip-cache.outputs.cache-hit == 'true' }})"
if [ -f requirements.txt ]; then
# Install remaining requirements but skip already installed packages
pip install -r requirements.txt --no-deps
fi
pip install pytest pytest-xdist
- name: Create setup.py if needed
run: |
if [ ! -f "setup.py" ]; then
echo "WARNING: setup.py not found, creating a minimal one"
echo "from setuptools import setup, find_packages" > setup.py
echo "setup(name=\"ecg_bench\", version=\"0.1.0\", packages=find_packages())" >> setup.py
cat setup.py
fi
- name: Install project in development mode
run: |
# First, verify the project structure
ls -la
# Install in dev mode
pip install -e .
# Try to verify installation
python -c "import ecg_bench; print('ECG-Bench package installed successfully')" || echo "Warning: Could not import ecg_bench package"
- name: List installed packages
run: |
pip list
- name: List project structure
run: |
ls -la
find . -name "*.py" | grep -v "__pycache__" | sort
- name: Run core component tests
run: |
# Run core component tests only
pytest -xvs tests/test_core_components.py || true
- name: Run model tests
run: |
# Run model tests
pytest -xvs tests/test_models.py || true
- name: Skip data loader tests
run: |
echo "Skipping data loader tests in CI environment"
echo "These tests are still available for local testing with 'pytest tests/test_data_loaders.py'"
- name: Run GPU compatibility tests (if available)
run: |
if [ $(python -c "import torch; print(torch.cuda.is_available())") == "True" ]; then
pytest -xvs tests/test_gpu.py
else
echo "CUDA not available, skipping GPU tests"
fi
- name: Run transformers tests (if available)
run: |
if [ -d "transformers" ]; then
pytest -xvs tests/test_transformers.py
else
echo "Transformers directory not found, skipping transformers tests"
fi