Skip to content

chore: update pyproject #21

chore: update pyproject

chore: update pyproject #21

name: Running the examples
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
run_examples:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [ '3.9', '3.10', '3.11', '3.12', '3.13']
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
uses: snok/install-poetry@76e04a911780d5b312d89783f7b1cd627778900a # v1.4.1
- name: Build and install client
run: |
touch README-PYPI.md # Create this file since the client is not built from Speakeasy
poetry build
python3 -m pip install dist/mistralai-*.whl
- name: Set VERSION
run: |
VERSION=$(echo ${{ matrix.python-version }} | tr -d .)
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Set MISTRAL_API_KEY using VERSION
run: |
echo "MISTRAL_API_KEY=${{ secrets[format('CI_MISTRAL_API_KEY_PYTHON_{0}', env.VERSION)] }}" >> $GITHUB_ENV
- name: Run the example scripts
run: |
failed=0
for file in examples/*.py; do
if [ -f "$file" ] && [ "$file" != "examples/chatbot_with_streaming.py" ]; then
echo "Running $file"
# Do not fail if the script fails, but save it in the failed variable
python3 "$file" > /dev/null || failed=1
fi
done
# If one of the example script failed then exit
if [ $failed -ne 0 ]; then
exit 1
fi
env:
MISTRAL_AGENT_ID: ${{ secrets.CI_AGENT_ID }}
MISTRAL_API_KEY: ${{ env.MISTRAL_API_KEY }}