Skip to content

Commit 9c37e23

Browse files
authored
[CI] Run examples in the CI to look for regressions (#193)
1 parent f8dd253 commit 9c37e23

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Running the examples
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
run_examples:
13+
runs-on: ubuntu-latest
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v3
22+
23+
- name: Set up Python ${{ matrix.python-version }}
24+
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
28+
- name: Install Poetry
29+
uses: snok/install-poetry@76e04a911780d5b312d89783f7b1cd627778900a # v1.4.1
30+
with:
31+
version: ${{ matrix.python-version == '3.8' && '1.8.5' || '2.1.1' }}
32+
33+
- name: Build and install client
34+
run: |
35+
touch README-PYPI.md # Create this file since the client is not built from Speakeasy
36+
poetry build
37+
python3 -m pip install dist/mistralai-*.whl
38+
39+
- name: Set VERSION
40+
run: |
41+
VERSION=$(echo ${{ matrix.python-version }} | tr -d .)
42+
echo "VERSION=$VERSION" >> $GITHUB_ENV
43+
44+
- name: Set MISTRAL_API_KEY using VERSION
45+
run: |
46+
echo "MISTRAL_API_KEY=${{ secrets[format('CI_MISTRAL_API_KEY_PYTHON_{0}', env.VERSION)] }}" >> $GITHUB_ENV
47+
48+
- name: Run the example scripts
49+
run: |
50+
failed=0
51+
for file in examples/*.py; do
52+
if [ -f "$file" ] && [ "$file" != "examples/chatbot_with_streaming.py" ]; then
53+
echo "Running $file"
54+
# Do not fail if the script fails, but save it in the failed variable
55+
python3 "$file" > /dev/null || failed=1
56+
fi
57+
done
58+
# If one of the example script failed then exit
59+
if [ $failed -ne 0 ]; then
60+
exit 1
61+
fi
62+
env:
63+
MISTRAL_AGENT_ID: ${{ secrets.CI_AGENT_ID }}
64+
MISTRAL_API_KEY: ${{ env.MISTRAL_API_KEY }}

0 commit comments

Comments
 (0)