Skip to content

CI: fix macOS and Windows builds #109

CI: fix macOS and Windows builds

CI: fix macOS and Windows builds #109

Workflow file for this run

name: tests
on:
push:
paths-ignore:
- "*.md"
pull_request:
types: [opened, synchronize, reopened, edited]
paths-ignore:
- "*.md"
env:
MODULE_NAME: "spacy_transformers"
RUN_MYPY: "true"
jobs:
tests:
name: Test
if: github.repository_owner == 'explosion'
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python_version: ["3.12"]
include:
- os: macos-13
python_version: "3.7"
- os: windows-latest
python_version: "3.8"
- os: ubuntu-latest
python_version: "3.9"
- os: macos-13
python_version: "3.10"
- os: windows-latest
python_version: "3.11"
runs-on: ${{ matrix.os }}
steps:
- name: Check out repo
uses: actions/checkout@v3
- name: Configure Python version
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python_version }}
- name: Install oldest supported torch for python 3.6
if: matrix.python_version == '3.6'
run: |
python -m pip install "torch==1.8.1+cpu" -f https://download.pytorch.org/whl/torch_stable.html
# Remove when https://github.com/pytorch/pytorch/issues/124897 is fixed.
- name: Install torch 2.2.2
if: matrix.python_version != '3.6' && matrix.os == 'windows-latest'
run: |
python -m pip install "torch==2.2.2+cpu" -f https://download.pytorch.org/whl/torch_stable.html
- name: Install dependencies
run: |
python -m pip install -U build pip setuptools wheel
python -m pip install -r requirements.txt
- name: Build sdist
run: |
python -m build --sdist
- name: Run mypy
if: env.RUN_MYPY == 'true' && matrix.python_version != '3.6'
shell: bash
run: |
python -m mypy $MODULE_NAME
- name: Delete source directory
shell: bash
run: |
rm -rf $MODULE_NAME
- name: Uninstall all packages
run: |
python -m pip freeze --exclude pywin32 --exclude torch
python -m pip freeze --exclude pywin32 --exclude torch > installed.txt
python -m pip uninstall -y -r installed.txt
- name: Install oldest supported torch for python 3.6
if: matrix.python_version == '3.6'
run: |
python -m pip install "torch==1.8.1+cpu" -f https://download.pytorch.org/whl/torch_stable.html
- name: Install newest torch for python 3.7+
if: matrix.python_version != '3.6'
run: |
python -m pip install torch --index-url https://download.pytorch.org/whl/cpu
- name: Install from sdist
shell: bash
run: |
SDIST=$(python -c "import os;print(os.listdir('./dist')[-1])" 2>&1)
python -m pip install dist/$SDIST
- name: Run tests
shell: bash
run: |
python -m pip install -r requirements.txt
python -m pytest --pyargs $MODULE_NAME --cov=$MODULE_NAME
- name: Test backwards compatibility for v1.0 models
if: matrix.python_version == '3.9'
run: |
python -m pip install https://github.com/explosion/spacy-models/releases/download/en_core_web_trf-3.1.0/en_core_web_trf-3.1.0-py3-none-any.whl --no-deps
python -c "import spacy; nlp = spacy.load('en_core_web_trf'); doc = nlp('test')"
- name: Test backwards compatibility for v1.1 models
if: matrix.python_version == '3.9'
run: |
python -m pip install https://github.com/explosion/spacy-models/releases/download/en_core_web_trf-3.4.0/en_core_web_trf-3.4.0-py3-none-any.whl --no-deps
python -c "import spacy; nlp = spacy.load('en_core_web_trf'); doc = nlp('test')"