From 4f1027c562695e368c0db2a40c5762d82cfa6757 Mon Sep 17 00:00:00 2001 From: Oleksii Shmalko Date: Fri, 23 Aug 2024 21:24:27 +0300 Subject: [PATCH] chore(python): run pytest with mock server --- .github/workflows/python.yml | 25 ++++++++++++++++--------- package.json | 2 +- python-sdk/Cargo.toml | 1 + 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 2ffc3894..8b49035e 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -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: @@ -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 @@ -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 }} @@ -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 @@ -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 }} @@ -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 }} @@ -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 diff --git a/package.json b/package.json index aae281b6..3b88747b 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/python-sdk/Cargo.toml b/python-sdk/Cargo.toml index 4eb02540..07603a59 100644 --- a/python-sdk/Cargo.toml +++ b/python-sdk/Cargo.toml @@ -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.