-
Notifications
You must be signed in to change notification settings - Fork 275
144 lines (125 loc) · 4.74 KB
/
tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: tests
on:
push:
paths-ignore:
- "website/**"
- "*.md"
pull_request:
types: [opened, synchronize, reopened, edited]
paths-ignore:
- "website/**"
- "*.md"
jobs:
validate:
name: Validate
if: github.repository_owner == 'explosion'
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@v4
- name: Configure Python version
uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: black
run: |
python -m pip install black -c requirements.txt
python -m black thinc --check
- name: isort
run: |
python -m pip install isort -c requirements.txt
python -m isort thinc --check
- name: flake8
run: |
python -m pip install flake8==5.0.4
python -m flake8 thinc --count --select=E901,E999,F821,F822,F823,W605 --show-source --statistics
tests:
name: Test
needs: Validate
if: github.repository_owner == 'explosion'
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-13]
python_version: ["3.12"]
include:
- os: windows-latest
python_version: "3.9"
- os: macos-13
python_version: "3.10"
- os: ubuntu-latest
python_version: "3.11"
runs-on: ${{ matrix.os }}
env:
NOTEBOOK_KERNEL: "thinc-notebook-tests"
steps:
- name: Check out repo
uses: actions/checkout@v4
- name: Configure Python version
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python_version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
pip install -r requirements.txt
- name: Build sdist
run: |
python setup.py build_ext --inplace
python setup.py sdist --formats=gztar
- name: Run mypy
run: python -m mypy thinc --no-implicit-reexport
- name: Delete source directory
run: rm -rf thinc
shell: bash
- name: Uninstall all packages
run: |
python -m pip freeze
pip freeze --exclude pywin32 > installed.txt
pip uninstall -y -r installed.txt
- name: Install from sdist
run: |
SDIST=$(python -c "import os;print(os.listdir('./dist')[-1])" 2>&1)
PIP_CONSTRAINT="build-constraints.txt" pip install dist/$SDIST
shell: bash
- name: Test import
run: python -c "import thinc"
- name: Install test requirements
run: |
pip install -r requirements.txt
- name: Install notebook test requirements
run: |
pip install ipykernel pydot graphviz
python -m ipykernel install --name thinc-notebook-tests --user
if: matrix.python_version != '3.12'
- name: Run tests without extras
run: |
python -m pytest --pyargs thinc -Werror --cov=thinc --cov-report=term
# TODO: Update for numpy v2
# Notes on numpy requirements hacks:
# 1. torch does not have a direct numpy requirement but is compiled
# against a newer version than the oldest supported numpy for windows and
# python 3.10; this version of numpy would not work with
# tensorflow~=2.5.0 as specified above, but there is no release for
# python 3.10 anyway
# 2. restrict to numpy<1.24.0 due to mxnet incompatibility
# 3. forbid torch!=1.13.0 due to segfaults with numpy<1.24.0
# Note: some of these pip install commands are known to fail for some platforms.
# To continue despite errors as in azure pipelines, remove -e from the default
# bash flags.
#- name: Install extras for testing
# run: |
# #pip install "protobuf~=3.20.0" "tensorflow~=2.5.0"
# #pip install "mxnet; sys_platform != 'win32' and python_version < '3.12'"
# pip install "torch!=1.13.0; sys_platform!='darwin'" --extra-index-url https://download.pytorch.org/whl/cpu
# # there is a bug related to MPS devices in github macos runners that
# # will be fixed in torch v2.1.1
# # https://github.com/pytorch/pytorch/pull/111576
# pip install "torch>=2.1.1; sys_platform=='darwin'" --extra-index-url https://download.pytorch.org/whl/cpu
# #pip install "numpy~=1.23.0; python_version=='3.10' and sys_platform=='win32'"
# #pip install "numpy<1.24.0"
# pip install -r requirements.txt
# pip uninstall -y mypy
# shell: bash --noprofile --norc -o pipefail {0}
##- name: Run tests with extras
# run: python -m pytest --pyargs thinc --cov=thinc --cov-report=term -p thinc.tests.enable_tensorflow