-
-
Notifications
You must be signed in to change notification settings - Fork 513
368 lines (332 loc) 路 12.7 KB
/
Copy pathbuild-python.yml
File metadata and controls
368 lines (332 loc) 路 12.7 KB
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
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
# 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
GISKARD_DEV_MODE: true
GSK_DISABLE_SENTRY: 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", "3.12"]
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" # Deactivating windows-2019, since it's trying to use python 3.7 to install PDM. Maybe try to reactivate later ?
# 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: Check disk space
run: |
df -h
- name: Free disk space
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
sudo swapoff -a
sudo rm -f /swapfile
sudo rm -rf /usr/local/lib/android
sudo apt update && sudo apt remove -y \
google-cloud-cli microsoft-edge-stable dotnet-sdk-* llvm-* google-chrome-stable temurin-*
sudo apt autoremove -y
sudo apt autoclean -y
- name: Check new disk space
run: |
df -h
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup UV
uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0
with:
python-version: ${{ matrix.python-version }}
- name: Cache Giskard test resources
uses: actions/cache@v4
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: Check again new disk space
run: |
df -h
- name: Install dependencies (Windows)
if: ${{ matrix.os == 'windows-2022' }}
run: |
uv sync --all-groups --extra llm --extra talk
uv pip list
- name: Install dependencies
if: ${{ matrix.os != 'windows-2022' }}
run: |
uv sync --all-groups --extra llm --extra talk --extra tensorflow
uv pip list
- name: Check yet again new disk space
run: |
df -h
- name: Re-install lightgbm from sources for MacOS
if: ${{ matrix.os == 'macos-latest' }}
run: |
uv run pip uninstall lightgbm -y
uv run pip install --no-binary lightgbm lightgbm --config-settings=cmake.define.USE_OPENMP=OFF
brew install libomp
- name: Install pydantic v1
if: ${{ matrix.pydantic_v1 }}
run: |
uv pip uninstall pydantic pydantic_core -y
uv pip install "pydantic>=1,<2"
- name: Check Pydantic installed version
run: |
uv pip list | grep -i pydantic
uv run python -c "import pydantic; assert pydantic.__version__.startswith('${{ matrix.pydantic_v1 && '1' || '2' }}.'), f'Wrong pydantic version: {pydantic.__version__}'"
- name: Install langchain minimal version
if: ${{ matrix.langchain_minimal }}
run: |
uv pip uninstall langchain -y
uv pip install "langchain==0.0.275"
- name: Check langchain installed version
if: ${{ matrix.langchain_minimal }}
run: |
uv pip list | grep -i langchain
uv run python -c "import langchain; assert langchain.__version__ == '0.0.275'"
- name: Install pandas v1
if: ${{ matrix.pandas_v1 }}
run: |
uv pip uninstall pandas -y
uv pip install "pandas>=1.0,<2.0"
- name: Check Pandas installed version
run: |
uv pip list | grep -i pandas
uv run python -c "import pandas; version = pandas.__version__; print(f'pandas version: {version}'); assert version.startswith('${{ matrix.pandas_v1 && '1' || '2' }}.'), f'Expected pandas v${{ matrix.pandas_v1 && '1' || '2' }}.x, got {version}'"
- name: Lint code
run: uv run ruff check giskard tests
- name: Test code
run: uv run pytest -c pyproject.toml --cov=giskard --cov-report=xml --cov-append --disable-warnings --no-header -vv --durations=0 -n auto -m 'not slow' --use-subprocess tests
env:
PYTEST_XDIST_AUTO_NUM_WORKERS: 2
- name: SonarQube 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' && github.event.pull_request.head.repo.full_name == github.repository) }}
uses: SonarSource/sonarqube-scan-action@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: Build
run: uv build
- name: "Python client: archive built artifacts"
# Upload needs to be done only once by workflo run, so we need to select one only in the matrix
if: ${{ github.event_name == 'push' && matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10' && !matrix.langchain_minimal && !matrix.pandas_v1 && !matrix.pydantic_v1 }}
uses: actions/upload-artifact@v4
with:
path: dist/*whl
- name: Run integration tests for python
if: ${{ inputs.run-integration-tests }}
env:
PYTEST_XDIST_AUTO_NUM_WORKERS: 2
run: uv run pytest -c pyproject.toml --cov=giskard --cov-report=xml --cov-append --disable-warnings --no-header -vv --durations=0 -m 'slow' --use-subprocess 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@v4
with:
path: memory*.csv
name: memory-usage
retention-days: 7
retry-on-failure:
if: failure() && fromJSON(github.run_attempt) < 2
needs: [build-python]
runs-on: ubuntu-latest
steps:
- env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ github.token }}
run: gh workflow run retry-workflow.yml --ref ${{ github.ref }} -F run_id=${{ github.run_id }}
install-poetry:
name: "Check if wheel can be installed with using Poetry"
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup UV
uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0
with:
python-version: "3.10"
- name: Build wheel
run: uv build
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Create new project, install wheel and import (Poetry)
run: |
poetry new ./install-run
cd ./install-run
sed -i -E 's|(python\s*=\s*)".*"|\1">=3.10,<3.13"|' pyproject.toml
rm -f poetry.lock
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/checkout@v4
- name: Setup UV
uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0
with:
python-version: "3.10"
- name: Build wheel
run: uv 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-uv:
name: "Check if wheel can be installed with UV"
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup UV
uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0
with:
python-version: "3.10"
- name: Build wheel
run: uv build
- name: Create new project, install wheel and import (UV)
run: |
mkdir -p /tmp/install-run
cd /tmp/install-run
cat > pyproject.toml << 'EOF'
[project]
name = "install-run"
version = "0.1.0"
requires-python = ">=3.10,<3.13"
dependencies = []
EOF
uv add "$(ls ${{ github.workspace }}/dist/*.whl)"
uv run python -c "import giskard"
check-doc:
name: "Build and check doc"
runs-on: ubuntu-latest
steps:
- name: Check disk space
run: |
df -h
- name: Free disk space
run: |
sudo swapoff -a
sudo rm -f /swapfile
sudo rm -rf /usr/local/lib/android
# Only remove Docker images if any exist
IMAGES=$(docker image ls -aq)
if [ -n "$IMAGES" ]; then
docker rmi $IMAGES
fi
sudo apt update && sudo apt remove -y \
google-cloud-cli \
microsoft-edge-stable \
dotnet-sdk-* \
llvm-* \
google-chrome-stable \
temurin-*
sudo apt autoremove -y
sudo apt autoclean -y
- name: Check new disk space
run: |
df -h
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup UV
uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0
with:
python-version: "3.10"
- 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: uv sync --all-groups --extra llm --extra talk --extra tensorflow
- name: Check new disk space
run: |
df -h
- name: Build doc
run: uv run sphinx-build docs docs/_build/html
- name: Check doc
run: uv run python ./docs/scrapper.py