Skip to content

Commit

Permalink
chore(python): run pytest with mock server
Browse files Browse the repository at this point in the history
  • Loading branch information
rasendubi committed Aug 23, 2024
1 parent e30c240 commit 4f1027c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
25 changes: 16 additions & 9 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# Manually modified:
# - tag filter in Release job to only trigger on python-sdk@ tags
# - added checkout with submodules
# - replaced `pytest` with `npm run with-server test:python`
name: Python SDK

on:
Expand Down Expand Up @@ -67,7 +68,8 @@ jobs:
source .venv/bin/activate
pip install eppo-server-sdk --find-links dist --force-reinstall
pip install pytest
cd ./python-sdk && pytest
npm ci
npm run with-server test:python
- name: pytest
if: ${{ !startsWith(matrix.platform.target, 'x86') && matrix.platform.target != 'ppc64' }}
uses: uraimo/run-on-arch-action@v2
Expand All @@ -77,12 +79,13 @@ jobs:
githubToken: ${{ github.token }}
install: |
apt-get update
apt-get install -y --no-install-recommends python3 python3-pip
apt-get install -y --no-install-recommends python3 python3-pip nodejs
pip3 install -U pip pytest
run: |
set -e
pip3 install eppo-server-sdk --find-links dist --force-reinstall
cd ./python-sdk && pytest
npm ci
npm run with-server test:python
musllinux:
runs-on: ${{ matrix.platform.runner }}
Expand Down Expand Up @@ -124,12 +127,13 @@ jobs:
options: -v ${{ github.workspace }}:/io -w /io
run: |
set -e
apk add py3-pip py3-virtualenv
apk add py3-pip py3-virtualenv nodejs npm
python3 -m virtualenv .venv
source .venv/bin/activate
pip install eppo-server-sdk --no-index --find-links dist --force-reinstall
pip install pytest
cd ./python-sdk && pytest
npm ci
npm run with-server test:python
- name: pytest
if: ${{ !startsWith(matrix.platform.target, 'x86') }}
uses: uraimo/run-on-arch-action@v2
Expand All @@ -138,14 +142,15 @@ jobs:
distro: alpine_latest
githubToken: ${{ github.token }}
install: |
apk add py3-virtualenv
apk add py3-virtualenv nodejs npm
run: |
set -e
python3 -m virtualenv .venv
source .venv/bin/activate
pip install pytest
pip install eppo-server-sdk --find-links dist --force-reinstall
cd ./python-sdk && pytest
npm ci
npm run with-server test:python
windows:
runs-on: ${{ matrix.platform.runner }}
Expand Down Expand Up @@ -184,7 +189,8 @@ jobs:
source .venv/Scripts/activate
pip install eppo-server-sdk --find-links dist --force-reinstall
pip install pytest
cd ./python-sdk && pytest
npm ci
npm run with-server test:python
macos:
runs-on: ${{ matrix.platform.runner }}
Expand Down Expand Up @@ -220,7 +226,8 @@ jobs:
source .venv/bin/activate
pip install eppo-server-sdk --find-links dist --force-reinstall
pip install pytest
cd ./python-sdk && pytest
npm ci
npm run with-server test:python
sdist:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"scripts": {
"test": "npm run with-server 'npm-run-all test:*'",
"test:rust": "cargo test",
"test:python": "cd python-sdk && maturin develop && pytest",
"test:python": "cd python-sdk && pytest",
"test:ruby": "cd ruby-sdk && bundle exec rake test",
"with-server": "start-server-and-test start-mock-server http://127.0.0.1:8378",
"start-mock-server": "npm start --prefix ./mock-server"
Expand Down
1 change: 1 addition & 0 deletions python-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pyo3-log = "0.11.0"
serde-pyobject = "0.4.0"
serde_json = "1.0.125"

[target.'cfg(target_os = "linux")'.dependencies]
# We don't use reqwest directly, so the following overrides it to
# enable feature flag. native-tls-vendored is required to vendor
# OpenSSL on linux builds, so we don't depend on shared libraries.
Expand Down

0 comments on commit 4f1027c

Please sign in to comment.