Skip to content

Client test

Client test #2

name: Python API Client Tests
on:
push:
paths:
- 'tests/test_api_client.py'
- 'tests/requirements.txt'
- '.github/workflows/python-api-client-tests.yaml'
pull_request:
paths:
- 'tests/test_api_client.py'
- 'tests/requirements.txt'
- '.github/workflows/python-api-client-tests.yaml'
env:
CARGO_TERM_COLOR: always
RUST_LOG: debug
CARGO_TERM_VERBOSE: true
API_SERVICE_URL: http://localhost:8000
PORT: 8000
jobs:
python-api-tests:
name: Run Python API Client Tests
runs-on: ubuntu-latest
services:
redis:
image: redis
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
submodules: recursive
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: "python-api-tests"
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'pip'
- name: Build Test Server
run: |
cd golem-worker-service-base
cargo build --test api_gateway_end_to_end_tests --features test-utils
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r tests/requirements.txt
- name: Start Test Server
run: |
cd golem-worker-service-base
RUST_LOG=debug RUST_BACKTRACE=1 cargo test --test api_gateway_end_to_end_tests -- --test-threads=1 --nocapture &
echo "Waiting for server to be ready..."
timeout 30 bash -c 'until curl -s http://localhost:8000/health > /dev/null 2>&1; do sleep 1; done'
- name: Run Python API Tests
run: |
cd tests
PYTHONPATH=${{ github.workspace }} pytest test_api_client.py -v --log-cli-level=DEBUG
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: |
test-output/openapi.json
test-output/openapi.yaml