-
-
Notifications
You must be signed in to change notification settings - Fork 291
299 lines (276 loc) · 9.97 KB
/
build-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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# https://docs.github.com/en/actions/using-workflows/reusing-workflows#calling-a-reusable-workflow
# https://docs.github.com/fr/actions/using-workflows/workflow-syntax-for-github-actions#exemple--inclusion-de-chemins-dacc%C3%A8s
name: Full CI
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
inputs:
run-integration-tests:
description: 'If integration test should be run'
required: true
type: boolean
default: false
use-cache:
description: 'If cache should be used'
required: true
type: boolean
default: true
is-dispatch:
description: 'Just to identify manual dispatch'
required: true
type: boolean
default: true
workflow_call:
inputs:
run-integration-tests:
description: 'If integration test should be run'
required: true
type: boolean
default: false
use-cache:
description: 'If cache should be used'
required: true
type: boolean
default: false
# Concurrency : auto-cancel "old" jobs ie when pushing again
# https://docs.github.com/fr/actions/using-jobs/using-concurrency
concurrency:
group: ${{ github.workflow }}-${{ inputs.run-integration-tests }}-${{ inputs.is-dispatch }}-${{ github.ref || github.run_id }}
cancel-in-progress: true
env:
GSK_DISABLE_ANALYTICS: true
defaults:
run:
shell: bash
jobs:
build-python:
name: "Python ${{ matrix.python-version }}${{ matrix.pandas_v1 && ' (Pandas V1)' || ''}}${{ matrix.pydantic_v1 && ' (Pydantic V1)' || ''}} ${{ matrix.langchain_minimal && ' (Minimal langchain)' || ''}} on ${{ matrix.os }}"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false # Do not stop when any job fails
matrix:
python-version: [ "3.9", "3.10", "3.11" ]
os: [ubuntu-latest]
pydantic_v1: [false]
pandas_v1: [false]
langchain_minimal: [false]
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
include:
- python-version: "3.10"
os: windows-2019
pydantic_v1: false
pandas_v1: false
langchain_minimal: false
- python-version: "3.10"
os: windows-2022
pydantic_v1: false
pandas_v1: false
langchain_minimal: false
- python-version: "3.10"
os: macos-latest
pydantic_v1: false
pandas_v1: false
langchain_minimal: false
- python-version: "3.10"
os: ubuntu-latest
pydantic_v1: true
pandas_v1: false
langchain_minimal: false
- python-version: "3.10"
os: ubuntu-latest
pydantic_v1: false
pandas_v1: true
langchain_minimal: false
- python-version: "3.10"
os: ubuntu-latest
pydantic_v1: false
pandas_v1: false
langchain_minimal: true
continue-on-error: false # https://ncorti.com/blog/howto-github-actions-build-matrix
steps:
- name: Checkout code
uses: actions/[email protected]
with:
fetch-depth: 0
- name: Setup PDM
uses: pdm-project/setup-pdm@v3
with:
python-version: ${{ matrix.python-version }}
cache: true
- name: Cache Giskard test resources
uses: actions/cache@v3
if: ${{ github.event_name == 'pull_request' || inputs.use-cache }}
with:
path: ~/.giskard
key: ${{ matrix.os }}-${{ matrix.python-version }}-python-test-resources-${{ hashFiles('tests/fixtures/**/*py')}}
restore-keys: ${{ matrix.os }}-${{ matrix.python-version }}-python-giskard-test-resources
- name: Install dependencies
run: pdm install -G :all
- name: Lint code
run: pdm run lint
- name: Re-install lightgbm from sources for MacOS
if: ${{ matrix.os == 'macos-latest' }}
run: |
pdm run pip uninstall lightgbm -y
pdm run pip install --no-binary lightgbm lightgbm --config-settings=cmake.define.USE_OPENMP=OFF
- name: Install pydantic v1
if: ${{ matrix.pydantic_v1 }}
run: |
pdm run pip uninstall pydantic pydantic_core -y
pdm run pip install "pydantic>=1,<2"
- name: Check Pydantic installed version
run: |
pdm run pip freeze | grep '^pydantic'
pdm run pip freeze | grep -q '^pydantic==${{ matrix.pydantic_v1 && '1' || '2' }}\.'
- name: Install langchain minimal version
if: ${{ matrix.langchain_minimal }}
run: |
pdm run pip uninstall langchain -y
pdm run pip install "langchain==0.0.275"
- name: Check langchain installed version
if: ${{ matrix.langchain_minimal }}
run: |
pdm run pip freeze | grep '^langchain'
pdm run pip freeze | grep -q '^langchain==0.0.275'
- name: Install pandas v1
if: ${{ matrix.pandas_v1 }}
run: |
pdm run pip uninstall pandas -y
pdm run pip install "pandas<2"
- name: Check Pandas installed version
run: |
pdm run pip freeze | grep '^pandas'
pdm run pip freeze | grep -q '^pandas==${{ matrix.pandas_v1 && '1' || '2' }}\.'
- name: Test code (concurrency)
run: pdm test-worker
- name: Test code
run: pdm test-fast
env:
PYTEST_XDIST_AUTO_NUM_WORKERS: 2
- name: SonarCloud Scan
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10' && !matrix.langchain_minimal && !matrix.pandas_v1 && !matrix.pydantic_v1 && (github.event.ref == 'refs/heads/main' || github.event_name == 'pull_request')}}
uses: SonarSource/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: Build
run: pdm build
- name: "Python client: archive built artifacts"
if: ${{ github.event_name == 'push' && matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10' }}
uses: actions/upload-artifact@v3
with:
path: dist/*whl
- name: Run integration tests for python
if: ${{ inputs.run-integration-tests }}
env:
PYTEST_XDIST_AUTO_NUM_WORKERS: 2
run: pdm test-slow tests/
- name: "Memory csv"
if: ${{ always() && matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10' && !matrix.langchain_minimal && !matrix.pandas_v1 && !matrix.pydantic_v1 }}
uses: actions/upload-artifact@v3
with:
path: memory*.csv
name: memory-usage
retention-days: 7
install-poetry:
name: "Check if wheel can be installed with using Poetry"
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Setup PDM
uses: pdm-project/setup-pdm@v3
with:
python-version: '3.10'
cache: false
- name: Build wheel
run: pdm build
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Create new project and install server wheel (Poetry)
run: |
poetry new ./install-test
cd ./install-test
sed -i 's/^\(python *= *\).*$/\1">=3.10,<3.12"/' pyproject.toml
poetry add "$(ls ../dist/*.whl)[hub]"
- name: Create new project, install wheel and import (Poetry)
run: |
poetry new ./install-run
cd ./install-run
sed -i 's/^\(python *= *\).*$/\1">=3.10,<3.12"/' pyproject.toml
poetry add "$(ls ../dist/*.whl)"
poetry run python -c "import giskard"
install-pip:
name: "Check if wheel can be installed with pip"
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Setup PDM
uses: pdm-project/setup-pdm@v3
with:
python-version: '3.10'
cache: false
- name: Build wheel
run: pdm build
- name: Create new project, install wheel and import (Pip)
run: |
python -m venv .venv-test-pip
source .venv-test-pip/bin/activate
python -m pip install "$(ls ./dist/*.whl)"
python -c "import giskard"
install-pdm:
name: "Check if wheel can be installed with PDM"
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Setup PDM
uses: pdm-project/setup-pdm@v3
with:
python-version: '3.10'
cache: false
- name: Build wheel
run: pdm build
- name: Create new project, install server wheel (PDM)
run: |
mkdir ./install-test
cd ./install-test
pdm init --python 3.10 -n .
sed -i 's/^\(requires-python *= *\).*$/\1">=3.10,<3.12"/' pyproject.toml
pdm add "$(ls ../dist/*.whl)[hub]"
pdm run python -c "import giskard"
- name: Create new project, install wheel and import (PDM)
run: |
mkdir ./install-run
cd ./install-run
pdm init --python 3.10 -n .
sed -i 's/^\(requires-python *= *\).*$/\1">=3.10,<3.12"/' pyproject.toml
pdm add "$(ls ../dist/*.whl)"
pdm run python -c "import giskard"
check-doc:
name: "Build and check doc"
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/[email protected]
with:
fetch-depth: 0
- name: Setup PDM
uses: pdm-project/setup-pdm@v3
with:
python-version: "3.10"
cache: true
- name: Set up Pandoc (needed for doc)
uses: r-lib/actions/setup-pandoc@v2
with:
pandoc-version: '3.1.7' # https://github.com/jgm/pandoc/releases
- name: Install dependencies
run: pdm install -G :all
- name: Build doc
run: pdm doc
- name: Check doc
run: pdm check-doc