|
| 1 | +name: CI testing |
| 2 | + |
| 3 | +# see: https://help.github.com/en/actions/reference/events-that-trigger-workflows |
| 4 | +on: # Trigger the workflow on push or pull request, but only for the main branch |
| 5 | + push: {} |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +defaults: |
| 10 | + run: |
| 11 | + shell: bash |
| 12 | + |
| 13 | +jobs: |
| 14 | + pytest: |
| 15 | + runs-on: ${{ matrix.os }} |
| 16 | + strategy: |
| 17 | + fail-fast: false |
| 18 | + matrix: |
| 19 | + os: [ubuntu-latest, macOS-latest, windows-latest] |
| 20 | + python-version: [3.9] |
| 21 | + requires: ["oldest", "latest"] |
| 22 | + |
| 23 | + # Timeout: https://stackoverflow.com/a/59076067/4521646 |
| 24 | + timeout-minutes: 35 |
| 25 | + env: |
| 26 | + TORCH_URL: "https://download.pytorch.org/whl/cpu/torch_stable.html" |
| 27 | + |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@v4 |
| 30 | + - name: Set up Python ${{ matrix.python-version }} |
| 31 | + uses: actions/setup-python@v5 |
| 32 | + with: |
| 33 | + python-version: ${{ matrix.python-version }} |
| 34 | + |
| 35 | + # Github Actions: Run step on specific OS: https://stackoverflow.com/a/57948488/4521646 |
| 36 | + #- name: Setup macOS |
| 37 | + # if: runner.os == 'macOS' |
| 38 | + # run: | |
| 39 | + # brew install libomp # https://github.com/pytorch/pytorch/issues/20030 |
| 40 | + |
| 41 | + - name: Set min. dependencies |
| 42 | + if: matrix.requires == 'oldest' |
| 43 | + run: | |
| 44 | + for fpath in ('requirements.txt', '_requirements/test.txt'): |
| 45 | + req = open(fpath).read().replace('>=', '==') |
| 46 | + open(fpath, 'w').write(req) |
| 47 | + shell: python |
| 48 | + |
| 49 | + - name: Get pip cache dir |
| 50 | + id: pip-cache |
| 51 | + run: echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT |
| 52 | + |
| 53 | + - name: Cache pip |
| 54 | + uses: actions/cache@v4 |
| 55 | + with: |
| 56 | + path: ${{ steps.pip-cache.outputs.dir }} |
| 57 | + key: ${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.requires }}-pip-${{ hashFiles('requirements.txt') }} |
| 58 | + restore-keys: ${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.requires }}-pip- |
| 59 | + |
| 60 | + - name: Install package & dependencies |
| 61 | + run: | |
| 62 | + pip --version |
| 63 | + pip install -e '.[test]' -U -q --find-links $TORCH_URL |
| 64 | + pip list |
| 65 | +
|
| 66 | + - name: Tests |
| 67 | + run: | |
| 68 | + coverage run --source pl_sandbox -m pytest src tests -v |
| 69 | +
|
| 70 | + - name: Statistics |
| 71 | + if: success() |
| 72 | + run: | |
| 73 | + coverage report |
| 74 | + coverage xml |
| 75 | +
|
| 76 | + - name: Upload coverage to Codecov |
| 77 | + uses: codecov/codecov-action@v4 |
| 78 | + with: |
| 79 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 80 | + file: ./coverage.xml |
| 81 | + flags: unittests |
| 82 | + env_vars: OS,PYTHON |
| 83 | + name: codecov-umbrella |
| 84 | + fail_ci_if_error: false |
0 commit comments