Skip to content

add test

add test #1323

Workflow file for this run

name: CI testing
# see: https://help.github.com/en/actions/reference/events-that-trigger-workflows
on: # Trigger the workflow on push or pull request, but only for the main branch
push: {}
pull_request:
branches: [main]
defaults:
run:
shell: bash
jobs:
pytest:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-13, windows-latest]
python-version: [3.9]
requires: ["oldest", "latest"]
# Timeout: https://stackoverflow.com/a/59076067/4521646
timeout-minutes: 35
env:
TORCH_URL: "https://download.pytorch.org/whl/cpu/torch_stable.html"
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# Github Actions: Run step on specific OS: https://stackoverflow.com/a/57948488/4521646
#- name: Setup macOS
# if: runner.os == 'macOS'
# run: |
# brew install libomp # https://github.com/pytorch/pytorch/issues/20030
- name: Set min. dependencies
if: matrix.requires == 'oldest'
run: |
for fpath in ('requirements.txt', 'requirements/test.txt'):
req = open(fpath).read().replace('>=', '==')
open(fpath, 'w').write(req)
shell: python
- name: Display dependencies
run: |
cat requirements.txt
cat requirements/test.txt
- name: Get pip cache dir
id: pip-cache
run: echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: Cache pip
uses: actions/cache@v4
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.requires }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: ${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.requires }}-pip-
- name: Install package & dependencies on Ubuntu
if: matrix.os == 'ubuntu-latest'
run: |
pip --version
pip install -e '.[extras]' -r requirements/test.txt -U -q --find-links $TORCH_URL
pip list
- name: Install package & dependencies
if: matrix.os != 'ubuntu-latest'
run: |
pip --version
pip install -e . -r requirements/test.txt -U -q --find-links $TORCH_URL
pip list
- name: Tests
run: coverage run --source litdata -m pytest tests -v
- name: Statistics
if: success()
run: |
coverage report
coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
flags: unittests
env_vars: OS,PYTHON
name: codecov-umbrella
fail_ci_if_error: false