|
| 1 | +name: Multiplatform tests |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + # trigger only on main branch |
| 7 | + branches: |
| 8 | + - main |
| 9 | + # trigger only on changes to the following files |
| 10 | + paths: |
| 11 | + - "kilroy_module_pytorch_py_sdk/src/**" |
| 12 | + - "kilroy_module_pytorch_py_sdk/tests/**" |
| 13 | + - "kilroy_module_pytorch_py_sdk/poetry.lock" |
| 14 | + - "kilroy_module_pytorch_py_sdk/pyproject.toml" |
| 15 | + - "environment.yml" |
| 16 | + - "requirements.txt" |
| 17 | + - ".github/workflows/test-multiplatform.yml" |
| 18 | + pull_request: |
| 19 | + # trigger only on main branch |
| 20 | + branches: |
| 21 | + - main |
| 22 | + # trigger only on changes to the following files |
| 23 | + paths: |
| 24 | + - "kilroy_module_pytorch_py_sdk/src/**" |
| 25 | + - "kilroy_module_pytorch_py_sdk/tests/**" |
| 26 | + - "kilroy_module_pytorch_py_sdk/poetry.lock" |
| 27 | + - "kilroy_module_pytorch_py_sdk/pyproject.toml" |
| 28 | + - "environment.yml" |
| 29 | + - "requirements.txt" |
| 30 | + - ".github/workflows/test-multiplatform.yml" |
| 31 | + |
| 32 | +# env for all jobs |
| 33 | +env: |
| 34 | + CONDA_CACHE_DIR: ~/conda_pkgs_dir |
| 35 | + POETRY_CACHE_DIR: ~/.cache/pypoetry |
| 36 | + PIP_CACHE_DIR: ~/.cache/pip |
| 37 | + # increase this value to manually reset cache |
| 38 | + CACHE_NUMBER: 0 |
| 39 | + |
| 40 | +jobs: |
| 41 | + test: |
| 42 | + name: Run tests |
| 43 | + strategy: |
| 44 | + # don't stop all tests if one fails |
| 45 | + fail-fast: false |
| 46 | + matrix: |
| 47 | + # better to use pinned versions here |
| 48 | + config: |
| 49 | + - { os: ubuntu-20.04, shell: bash -l } |
| 50 | + - { os: macos-10.15, shell: bash -l } |
| 51 | + - { os: windows-2019, shell: cmd /C CALL } |
| 52 | + runs-on: ${{ matrix.config.os }} |
| 53 | + defaults: |
| 54 | + run: |
| 55 | + # necessary for conda to work |
| 56 | + shell: ${{ matrix.config.shell }} {0} |
| 57 | + steps: |
| 58 | + - # get repository code |
| 59 | + name: Checkout code |
| 60 | + uses: actions/checkout@v2 |
| 61 | + - # get conda, poetry and pip cache (persistent between runs) |
| 62 | + name: Cache packages |
| 63 | + uses: actions/cache@v2 |
| 64 | + with: |
| 65 | + path: | |
| 66 | + ${{ env.CONDA_CACHE_DIR }} |
| 67 | + ${{ env.POETRY_CACHE_DIR }} |
| 68 | + ${{ env.PIP_CACHE_DIR }} |
| 69 | + key: ${{ runner.os }}-pkgs-${{ env.CACHE_NUMBER }} |
| 70 | + - name: Set up Python |
| 71 | + uses: actions/setup-python@v2 |
| 72 | + with: |
| 73 | + python-version: "3.9.7" |
| 74 | + - name: Set up pip cache |
| 75 | + run: python3 -m pip config set global.cache-dir ${{ env.PIP_CACHE_DIR }} |
| 76 | + - name: Install poetry |
| 77 | + run: python3 -m pip install -r requirements.txt |
| 78 | + - name: Set up poetry cache |
| 79 | + run: poetry config cache-dir ${{ env.POETRY_CACHE_DIR }} |
| 80 | + - # create and activate conda environment |
| 81 | + name: Set up environment |
| 82 | + uses: conda-incubator/setup-miniconda@v2 |
| 83 | + with: |
| 84 | + activate-environment: kilroy-module-pytorch-py-sdk |
| 85 | + environment-file: environment.yml |
| 86 | + # necessary for caching to work |
| 87 | + use-only-tar-bz2: true |
| 88 | + - # install only dependencies |
| 89 | + name: Install dependencies |
| 90 | + working-directory: kilroy_module_pytorch_py_sdk |
| 91 | + run: poetry install --no-root --extras test |
| 92 | + - # workaround for non-editable install, waiting for https://github.com/python-poetry/poetry/issues/1382 |
| 93 | + name: Build package |
| 94 | + working-directory: kilroy_module_pytorch_py_sdk |
| 95 | + run: poetry build -f wheel |
| 96 | + - # use pip to install wheel produced in previous step |
| 97 | + name: Install package |
| 98 | + working-directory: kilroy_module_pytorch_py_sdk |
| 99 | + # python from conda should be called just by 'python', not 'python3' |
| 100 | + run: python -m pip install --no-deps --no-index --no-cache-dir --find-links=dist kilroy-module-pytorch-py-sdk[test] |
| 101 | + - name: Run tests |
| 102 | + run: pytest kilroy_module_pytorch_py_sdk |
0 commit comments