Updated upload artifact workflows. #2
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: Tests | |
| on: | |
| push: | |
| branches: [ main, dev/jmlr ] | |
| pull_request: | |
| branches: [ main, dev/jmlr ] | |
| workflow_call: | |
| jobs: | |
| test: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| python-version: ["3.9", "3.10", "3.11"] | |
| pytorch-version: ["2.0.0", "2.1.0", "2.2.0"] | |
| exclude: | |
| # Exclude some combinations to reduce CI load | |
| - os: windows-latest | |
| python-version: "3.9" | |
| - os: macos-latest | |
| python-version: "3.9" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| # with: | |
| # fetch-depth: 0 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Cache pip dependencies | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip-${{ matrix.python-version }}- | |
| ${{ runner.os }}-pip- | |
| - name: Install PyTorch ${{ matrix.pytorch-version }} | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install torch==${{ matrix.pytorch-version }} --index-url https://download.pytorch.org/whl/cpu | |
| - name: Install package, dev, and test dependencies | |
| run: pip install -e ".[dev, tests]" | |
| # - name: Install additional test dependencies | |
| # run: pip install pytest-xdist pytest-timeout | |
| - name: Run unit and gpu tests with coverage | |
| # Automatically uses pytest configuration from pyproject.toml | |
| run: pytest | |
| env: | |
| PYTORCH_VERSION: ${{ matrix.pytorch-version }} | |
| # run: | | |
| # pytest tests/unit/ -v \ | |
| # --cov=torchsom \ | |
| # --cov-report=xml \ | |
| # --cov-report=html \ | |
| # --cov-report=term-missing \ | |
| # --cov-config=pyproject.toml \ | |
| # --junit-xml=junit.xml \ | |
| # --timeout=300 \ | |
| # -n auto \ | |
| # -m "unit or gpu" | |
| - name: Upload coverage to Codecov | |
| if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10' && matrix.pytorch-version == '2.1.0' | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| files: coverage.xml | |
| flags: unittests | |
| name: codecov-umbrella | |
| fail_ci_if_error: false | |
| - name: Upload test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: test-results-${{ matrix.os }}-py${{ matrix.python-version }}-torch${{ matrix.pytorch-version }} | |
| path: | | |
| coverage.xml | |
| htmlcov/ | |
| junit.xml | |
| test-gpu: | |
| runs-on: self-hosted | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ["3.10"] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install CUDA PyTorch | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install torch --index-url https://download.pytorch.org/whl/cu118 | |
| - name: Install package, dev, and test dependencies | |
| run: pip install -e ".[dev, tests]" | |
| - name: Run GPU tests | |
| run: | | |
| pytest tests/unit/ -v \ | |
| --cov=torchsom \ | |
| --cov-report=xml \ | |
| --cov-report=term-missing \ | |
| --junit-xml=junit-gpu.xml \ | |
| --timeout=600 \ | |
| -m "gpu" | |
| env: | |
| CUDA_VISIBLE_DEVICES: 0 | |
| - name: Upload GPU test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: gpu-test-results | |
| path: | | |
| coverage.xml | |
| junit-gpu.xml | |
| integration-tests: | |
| runs-on: ubuntu-latest | |
| needs: test | |
| if: github.event_name == 'push' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python 3.10 | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.10" | |
| - name: Install package, dev, and test dependencies | |
| run: pip install -e ".[dev, tests]" | |
| - name: Run integration tests | |
| run: | | |
| pytest tests/ -v \ | |
| --cov=torchsom \ | |
| --cov-report=xml \ | |
| --cov-report=term-missing \ | |
| --junit-xml=junit-integration.xml \ | |
| --timeout=600 \ | |
| -m "integration" | |
| continue-on-error: true | |
| - name: Upload integration test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: integration-test-results | |
| path: | | |
| coverage.xml | |
| junit-integration.xml |