|
| 1 | +name: Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main, develop ] |
| 6 | + pull_request: |
| 7 | + branches: [ main, develop ] |
| 8 | + |
| 9 | +jobs: |
| 10 | + unit-tests: |
| 11 | + name: Unit Tests - Python ${{ matrix.python-version }} |
| 12 | + runs-on: ubuntu-latest |
| 13 | + strategy: |
| 14 | + fail-fast: false |
| 15 | + matrix: |
| 16 | + python-version: ['3.8', '3.9', '3.10'] |
| 17 | + |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v3 |
| 20 | + |
| 21 | + - name: Set up Python ${{ matrix.python-version }} |
| 22 | + uses: actions/setup-python@v4 |
| 23 | + with: |
| 24 | + python-version: ${{ matrix.python-version }} |
| 25 | + |
| 26 | + - name: Cache pip packages |
| 27 | + uses: actions/cache@v3 |
| 28 | + with: |
| 29 | + path: ~/.cache/pip |
| 30 | + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} |
| 31 | + restore-keys: | |
| 32 | + ${{ runner.os }}-pip- |
| 33 | + |
| 34 | + - name: Install dependencies |
| 35 | + run: | |
| 36 | + python -m pip install --upgrade pip |
| 37 | + pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu |
| 38 | + pip install -r requirements.txt |
| 39 | + pip install pytest pytest-cov pytest-xdist pytest-timeout |
| 40 | + pip install -e . |
| 41 | + |
| 42 | + - name: Run unit tests |
| 43 | + run: | |
| 44 | + pytest tests/test_distributed.py -v \ |
| 45 | + --cov=src \ |
| 46 | + --cov-report=xml \ |
| 47 | + --cov-report=term \ |
| 48 | + --timeout=300 |
| 49 | + |
| 50 | + - name: Upload coverage |
| 51 | + uses: codecov/codecov-action@v3 |
| 52 | + with: |
| 53 | + file: ./coverage.xml |
| 54 | + flags: unittests |
| 55 | + name: codecov-${{ matrix.python-version }} |
| 56 | + |
| 57 | + integration-tests: |
| 58 | + name: Integration Tests |
| 59 | + runs-on: ubuntu-latest |
| 60 | + |
| 61 | + steps: |
| 62 | + - uses: actions/checkout@v3 |
| 63 | + |
| 64 | + - name: Set up Python |
| 65 | + uses: actions/setup-python@v4 |
| 66 | + with: |
| 67 | + python-version: '3.10' |
| 68 | + |
| 69 | + - name: Install dependencies |
| 70 | + run: | |
| 71 | + pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu |
| 72 | + pip install -r requirements.txt |
| 73 | + pip install pytest pytest-timeout |
| 74 | + pip install -e . |
| 75 | + |
| 76 | + - name: Run integration tests |
| 77 | + run: | |
| 78 | + pytest tests/test_integration.py -v --timeout=600 |
| 79 | + |
| 80 | + - name: Upload test artifacts |
| 81 | + if: failure() |
| 82 | + uses: actions/upload-artifact@v3 |
| 83 | + with: |
| 84 | + name: integration-test-logs |
| 85 | + path: logs/ |
| 86 | + |
| 87 | + performance-tests: |
| 88 | + name: Performance Tests |
| 89 | + runs-on: [self-hosted, gpu] |
| 90 | + if: github.event_name == 'pull_request' |
| 91 | + |
| 92 | + steps: |
| 93 | + - uses: actions/checkout@v3 |
| 94 | + |
| 95 | + - name: Set up Python |
| 96 | + uses: actions/setup-python@v4 |
| 97 | + with: |
| 98 | + python-version: '3.10' |
| 99 | + |
| 100 | + - name: Install dependencies |
| 101 | + run: | |
| 102 | + pip install torch torchvision --index-url https://download.pytorch.org/whl/cu118 |
| 103 | + pip install -r requirements.txt |
| 104 | + pip install pytest pytest-benchmark |
| 105 | + pip install -e . |
| 106 | + |
| 107 | + - name: Run performance tests |
| 108 | + run: | |
| 109 | + pytest tests/test_performance.py -v -m "not slow" |
| 110 | + |
| 111 | + - name: Generate performance report |
| 112 | + run: | |
| 113 | + python benchmarks/run_benchmark.py \ |
| 114 | + --gpus 1 2 \ |
| 115 | + --strategies ddp \ |
| 116 | + --output-dir performance-results |
| 117 | + |
| 118 | + - name: Upload performance results |
| 119 | + uses: actions/upload-artifact@v3 |
| 120 | + with: |
| 121 | + name: performance-results |
| 122 | + path: performance-results/ |
| 123 | + |
| 124 | + compatibility-tests: |
| 125 | + name: PyTorch Compatibility |
| 126 | + runs-on: ubuntu-latest |
| 127 | + strategy: |
| 128 | + matrix: |
| 129 | + pytorch-version: ['2.0.0', '2.1.0', 'latest'] |
| 130 | + |
| 131 | + steps: |
| 132 | + - uses: actions/checkout@v3 |
| 133 | + |
| 134 | + - name: Set up Python |
| 135 | + uses: actions/setup-python@v4 |
| 136 | + with: |
| 137 | + python-version: '3.10' |
| 138 | + |
| 139 | + - name: Install PyTorch ${{ matrix.pytorch-version }} |
| 140 | + run: | |
| 141 | + if [ "${{ matrix.pytorch-version }}" = "latest" ]; then |
| 142 | + pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu |
| 143 | + else |
| 144 | + pip install torch==${{ matrix.pytorch-version }} torchvision --index-url https://download.pytorch.org/whl/cpu |
| 145 | + fi |
| 146 | + |
| 147 | + - name: Install framework |
| 148 | + run: | |
| 149 | + pip install -r requirements.txt |
| 150 | + pip install -e . |
| 151 | + |
| 152 | + - name: Run compatibility tests |
| 153 | + run: | |
| 154 | + python -c "from src import DistributedTrainer; print('✓ Import successful')" |
| 155 | + python -c "import torch; print(f'PyTorch {torch.__version__}')" |
| 156 | +
|
| 157 | + docker-build-test: |
| 158 | + name: Docker Build Test |
| 159 | + runs-on: ubuntu-latest |
| 160 | + |
| 161 | + steps: |
| 162 | + - uses: actions/checkout@v3 |
| 163 | + |
| 164 | + - name: Set up Docker Buildx |
| 165 | + uses: docker/setup-buildx-action@v2 |
| 166 | + |
| 167 | + - name: Build Docker image |
| 168 | + uses: docker/build-push-action@v4 |
| 169 | + with: |
| 170 | + context: . |
| 171 | + push: false |
| 172 | + tags: distributed-training:test |
| 173 | + cache-from: type=gha |
| 174 | + cache-to: type=gha,mode=max |
| 175 | + |
| 176 | + - name: Test Docker image |
| 177 | + run: | |
| 178 | + docker run --rm distributed-training:test python -c "from src import DistributedTrainer; print('✓ Docker image works')" |
0 commit comments