-
Notifications
You must be signed in to change notification settings - Fork 0
143 lines (132 loc) · 4.47 KB
/
test-python.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
name: Test Python bindings
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
RUST_BACKTRACE: full
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
jobs:
lint-python:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install rust stable
uses: dtolnay/rust-toolchain@stable
- name: Cache rust
uses: Swatinem/rust-cache@v2
with:
key: ${{ runner.os }}-rust-${{ hashFiles('**/Cargo.toml') }}
- uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
- name: Update pip
run: python -m pip install --upgrade pip
- name: Build and install package
run: make build-python PYTHON_INTERPRETER=python
- name: Run linters
run: make lint-python PYTHON_INTERPRETER=python
external-build-python:
uses: ./.github/workflows/reusable-build-python.yml
with:
WORKING_DIRECTORY: "bindings/python"
secrets: inherit
test-python:
needs: [external-build-python]
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-13, macos-latest, windows-latest ] # at the moment macos-latest is exclusive M1 chip
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
lfs: false
- name: Install rust stable
uses: dtolnay/rust-toolchain@stable
- name: Cache rust
uses: Swatinem/rust-cache@v2
with:
key: ${{ runner.os }}-rust-${{ hashFiles('**/Cargo.toml') }}
- uses: actions/download-artifact@v4
with:
# for macos-13 get macos-latest artifacts
pattern: wheels-${{ matrix.os == 'macos-13' && 'macos-latest' || matrix.os }}-*
merge-multiple: true
path: dist
- name: Show dist files
shell: bash
run: ls -lah ./dist
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Test installation from source (editable mode) # also will populate the fast_aug module with so file
shell: bash
run: |
make build-python PYTHON_INTERPRETER=python
- name: Run python and rust tests (install from dist)
shell: bash
run: |
if [[ "${{ runner.os }}" == "Windows" ]]; then
DIST_PATH="$(cygpath -u "${{ github.workspace }}")/dist"
else
DIST_PATH="${{ github.workspace }}/dist"
fi
make test-python PYTHON_INTERPRETER=python PYTHON_INSTALL_FROM_DIST=$DIST_PATH
test-profile-python:
runs-on: macos-latest # not working on linux, kernel virtualization blocked
steps:
- uses: actions/checkout@v4
with:
lfs: false
- name: Install rust stable
uses: dtolnay/rust-toolchain@stable
- name: Cache rust
uses: Swatinem/rust-cache@v2
with:
key: ${{ runner.os }}-rust-${{ hashFiles('**/Cargo.toml') }}
- uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
- name: Update pip
run: python -m pip install --upgrade pip
- name: Run profiling in release mode
run: sudo make profile-python PYTHON_INTERPRETER=python
- name: Upload profiling results
uses: actions/upload-artifact@v4
with:
name: python-profiling-results
path: |
# benchmarking results and flamegraph
bindings/python/flamegraph*.svg
bindings/python/python-bench*.svg
if-no-files-found: error
test-compare-python:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
lfs: false
- name: Install rust stable
uses: dtolnay/rust-toolchain@stable
- name: Cache rust
uses: Swatinem/rust-cache@v2
with:
key: ${{ runner.os }}-rust-${{ hashFiles('**/Cargo.toml') }}
- uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
- name: Update pip
run: python -m pip install --upgrade pip
- name: Build and install spaCy
run: python -m pip install spacy && python -m spacy download en_core_web_sm
- name: Run comparison (just to check that it works)
run: make compare-python PYTHON_INTERPRETER=python PYTHON_COMPARE_REPETITIONS=1